@Before public void setUp() { try { deployer.deploy("deployment"); // The failing configurator provokes a RuntimeException in a servlet context listener. // Apparently such an exception needs not cancel the deployment of a Java EE application. // That means deployment fails for some servers and for others not. // => we don't care if there is an exception here or not }catch (Exception e) { } }
/** * Note that this test method depends on (must be run after) {@link #deployArchives()}. * * @param fooContext * @param barContext * @throws Exception */ @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "f") public void testApplicationContextDestroyed(@ArquillianResource @OperateOnDeployment(FOO) URL fooContext, @ArquillianResource @OperateOnDeployment(BAR) URL barContext) throws Exception { // Init foo - set bar archive deployment url WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(true); webClient.getPage(fooContext + "init?url=" + URLEncoder.encode(barContext.toExternalForm(), "UTF-8")); // Undeploy foo deployer.undeploy(FOO); // Get bar info TextPage info = webClient.getPage(barContext + "info?action=get"); assertEquals(info.getContent(), "true"); // Undeploy bar deployer.undeploy(BAR); }
@Test public final void test() { System.out.println("testing " + version + "/" + type + "/" + suite + "/" + name + " with url " + deploymentURL); // for (String deployment : deployments) { deployer.deploy(deployment); } // try { new Conversation(deploymentURL, name).performInteractions(); } finally { for (String deployment : deployments) { deployer.undeploy(deployment); } } } }
public void getDeployment(@Observes GetDeploymentCommand event) { byte[] deploymentContent = asByteArray( deployerInst.get().getDeployment( event.getDeploymentName())); event.setResult(deploymentContent); } }
/** * Note that this test method depends on (must be run after) {@link #deployArchives()}. * * @param alphaContext * @param bravoContext * @throws Exception */ @Test(groups = INTEGRATION, dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = SESSION_CONTEXT_EE, id = "ac") public void testApplicationContextDestroyed(@ArquillianResource @OperateOnDeployment(ALPHA_DEPLOYMENT_NAME) URL alphaContext, @ArquillianResource @OperateOnDeployment(BRAVO_ARCHIVE_NAME) URL bravoContext) throws Exception { // Init SessionScopedTestFlagClient - set bravo archive deployment url WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(true); webClient.getPage(alphaContext + "init?url=" + URLEncoder.encode(bravoContext.toExternalForm(), "UTF-8")); deployer.undeploy(ALPHA_DEPLOYMENT_NAME); TextPage info = webClient.getPage(bravoContext + "info?action=get"); assertEquals(info.getContent(), "true"); deployer.undeploy(BRAVO_ARCHIVE_NAME); }
private void deployFailingDeployment() { Exception caughtException = null; try { deployer.deploy( FAILING_DEPLOYMENT ); } catch (Exception e) { caughtException = e; } if ( caughtException == null ) { try { deployer.undeploy( FAILING_DEPLOYMENT ); } catch (RuntimeException e) { log.warn( "Error undeploying a deployment", e ); } Assert.fail( "Deployment " + FAILING_DEPLOYMENT + " should have failed, but it didn't." + " There is something wrong with this test." ); } }
public void getDeployment(@Observes GetDeploymentCommand event) { byte[] deploymentContent = asByteArray( deployerInst.get().getDeployment( event.getDeploymentName())); event.setResult(deploymentContent); } }
@Test public void testXmlInvalid() { try { deployer.deploy(DEPLOYMENT); Assert.fail("exception expected"); }catch (Exception e) { // expected } }
public void undeploy(@Observes UnDeployDeploymentCommand event) { deployerInst.get().undeploy(event.getDeploymentName()); event.setResult("SUCCESS"); }
ResourceIdentity identityF = ResourceIdentity.create(RESOURCE_F, Version.emptyVersion); builderF.addIdentityCapability(identityF); builderF.addContentCapability(deployer.getDeployment(CONTENT_F1), null, Collections.singletonMap(CAPABILITY_INCLUDE_RUNTIME_TYPE_DIRECTIVE, RuntimeType.TOMCAT.name())); builderF.addContentCapability(deployer.getDeployment(CONTENT_F2), null, Collections.singletonMap(CAPABILITY_INCLUDE_RUNTIME_TYPE_DIRECTIVE, RuntimeType.WILDFLY.name())); builderF.addContentCapability(deployer.getDeployment(CONTENT_F3), null, Collections.singletonMap(CAPABILITY_INCLUDE_RUNTIME_TYPE_DIRECTIVE, RuntimeType.KARAF.name())); builderG.addContentCapability(deployer.getDeployment(CONTENT_G1), null, Collections.singletonMap(CAPABILITY_INCLUDE_RUNTIME_TYPE_DIRECTIVE, RuntimeType.TOMCAT.name())); builderG.addContentCapability(deployer.getDeployment(CONTENT_G2), null, Collections.singletonMap(CAPABILITY_INCLUDE_RUNTIME_TYPE_DIRECTIVE, RuntimeType.WILDFLY.name())); builderG.addContentCapability(deployer.getDeployment(CONTENT_G3), null, Collections.singletonMap(CAPABILITY_INCLUDE_RUNTIME_TYPE_DIRECTIVE, RuntimeType.KARAF.name()));
@Test @InSequence(1) public void testPriorityOnTimerStartEvent() { // when try { deployer.deploy("timerStart"); } catch (Exception e) { e.printStackTrace(); Assert.fail("deployment should be successful, i.e. bean for timer start event should get resolved"); } }
public void undeploy(@Observes UnDeployDeploymentCommand event) { deployerInst.get().undeploy(event.getDeploymentName()); event.setResult("SUCCESS"); }
Provisioner provisioner = ServiceLocator.getRequiredService(Provisioner.class); ResourceIdentity identityB = ResourceIdentity.fromString(RESOURCE_B); ResourceBuilder builderB = provisioner.getContentResourceBuilder(identityB, deployer.getDeployment(RESOURCE_B)); ResourceIdentity identityB1 = ResourceIdentity.fromString(RESOURCE_B1); ResourceBuilder builderB1 = provisioner.getContentResourceBuilder(identityB1, deployer.getDeployment(RESOURCE_B1)); handles.add(provisioner.installSharedResource(builderB.getResource())); handles.add(provisioner.installResource(builderB1.getResource()));
@Test public void test() { try { deployer.deploy(DEPLOYMENT); Assert.fail("failure expected"); } catch (Exception e) { // expected } }
/** * Note that this test method depends on (must be run after) * * @throws Exception */ @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = SHUTDOWN, id = "a"), @SpecAssertion(section = SHUTDOWN, id = "b"), @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "ja"), @SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ga"), @SpecAssertion(section = BEFORE_SHUTDOWN, id = "a") }) public void testShutdown(@ArquillianResource @OperateOnDeployment(FOO) URL fooContext, @ArquillianResource @OperateOnDeployment(INFO) URL infoContext) throws Exception { // Init foo - set info archive deployment url WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(true); webClient.getPage(fooContext + "init?url=" + URLEncoder.encode(infoContext.toExternalForm(), "UTF-8")); // Undeploy foo deployer.undeploy(FOO); // 1. Destroy contexts (the order is not set) // 2. BeforeShutdown event TextPage info = webClient.getPage(infoContext + "info?action=get"); ActionSequence actual = ActionSequence.buildFromCsvData(info.getContent()); assertTrue(actual.endsWith(BeforeShutdown.class.getName())); actual.assertDataContainsAll(RequestScoped.class.getName(), SessionScoped.class.getName(), ApplicationScoped.class.getName(), ConversationScoped.class.getName(), Foo.class.getName(), Bar.class.getName(), Baz.class.getName(), Qux.class.getName()); // Undeploy info deployer.undeploy(INFO); }
/** * Provision a resource from an input stream. * * The client controlls the resource identity * The installed resource is self sufficient - no additional dependency mapping needed. */ @Test public void testProvisionStreamResource() throws Exception { Provisioner provisioner = ServiceLocator.getRequiredService(Provisioner.class); ResourceIdentity identityA = ResourceIdentity.fromString(RESOURCE_A); ResourceBuilder builderA = provisioner.getContentResourceBuilder(identityA, deployer.getDeployment(RESOURCE_A)); ResourceHandle handle = provisioner.installResource(builderA.getResource()); try { // Verify that the module got installed Runtime runtime = RuntimeLocator.getRequiredRuntime(); Module module = runtime.getModule(identityA); Assert.assertNotNull("Module not null", module); Assert.assertEquals("ACTIVE " + module, State.ACTIVE, module.getState()); // Verify that the module activator was called MBeanServer server = ServiceLocator.getRequiredService(MBeanServer.class); Assert.assertTrue("MBean registered", server.isRegistered(getObjectName(module))); Assert.assertEquals("ACTIVE", server.getAttribute(getObjectName(module), "ModuleState")); } finally { handle.uninstall(); } }
@Test @RunAsClient public void testDeploymentFails(){ try { deployer.deploy(DEPLOYMENT_WITH_EJB_PA); Assert.fail("Deployment exception expected"); } catch(Exception e) { // expected } try { deployer.deploy(DEPLOYMENT_WITH_SERVLET_PA); Assert.fail("Deployment exception expected"); } catch(Exception e) { // expected } }
@Test @InSequence(2) public void testEnhancedListenerNotDestroyingWeldIfListenerRegistered(@ArquillianResource @OperateOnDeployment(TEST) URL testContext, @ArquillianResource @OperateOnDeployment(ASSERT) URL assertContext) throws IOException { // Init foo - set info archive deployment url WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(true); webClient.getPage(testContext + "init?url=" + URLEncoder.encode(assertContext.toExternalForm(), "UTF-8")); // Undeploy TEST deployer.undeploy(TEST); // Test that Foo is destroyed after TestListener is notified TextPage info = webClient.getPage(assertContext + "info?action=get"); List<String> data = ActionSequence.buildFromCsvData(info.getContent()).getData(); assertEquals(2, data.size()); assertEquals(TestListener.class.getSimpleName(), data.get(0)); assertEquals(Foo.class.getSimpleName(), data.get(1)); // Undeploy ASSERT deployer.undeploy(ASSERT); } }
Map<String, Object> attsD = builderD.addIdentityCapability(residD).getAttributes(); attsD.put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_D + ".war"); builderD.addContentCapability(deployer.getDeployment(RESOURCE_D)); Resource resD = builderD.getResource();
@Test @RunAsClient public void testDeployDroolsFails() { try { deployer.deploy("deployment"); Assert.fail("exception expected"); }catch (Exception e) { // expected } }