public Archive<?> generateDeployment(TestDeployment testDeployment, Collection<ProtocolArchiveProcessor> processors) { JavaArchive protocol = new ProtocolDeploymentAppender().createAuxiliaryArchive(); Archive<?> applicationArchive = testDeployment.getApplicationArchive(); Collection<Archive<?>> auxiliaryArchives = testDeployment.getAuxiliaryArchives(); Processor processor = new Processor(testDeployment, processors); if (Validate.isArchiveOfType(EnterpriseArchive.class, applicationArchive)) { return handleArchive(applicationArchive.as(EnterpriseArchive.class), auxiliaryArchives, protocol, processor, testDeployment); } if (Validate.isArchiveOfType(WebArchive.class, applicationArchive)) { return handleArchive(applicationArchive.as(WebArchive.class), auxiliaryArchives, protocol, processor); } if (Validate.isArchiveOfType(JavaArchive.class, applicationArchive)) { return handleArchive(applicationArchive.as(JavaArchive.class), auxiliaryArchives, protocol, processor); } throw new IllegalArgumentException(ServletProtocolDeploymentPackager.class.getName() + " can not handle archive of type " + applicationArchive.getClass().getName()); }
public Archive<?> generateDeployment(TestDeployment testDeployment, Collection<ProtocolArchiveProcessor> processors) { WebArchive protocol = new ProtocolDeploymentAppender().createAuxiliaryArchive(); Archive<?> applicationArchive = testDeployment.getApplicationArchive(); Collection<Archive<?>> auxiliaryArchives = testDeployment.getAuxiliaryArchives(); Processor processor = new Processor(testDeployment, processors); if (Validate.isArchiveOfType(EnterpriseArchive.class, applicationArchive)) { return handleArchive(applicationArchive.as(EnterpriseArchive.class), auxiliaryArchives, protocol, processor, testDeployment); } if (Validate.isArchiveOfType(WebArchive.class, applicationArchive)) { return handleArchive(applicationArchive.as(WebArchive.class), auxiliaryArchives, protocol, processor); } if (Validate.isArchiveOfType(JavaArchive.class, applicationArchive)) { return handleArchive(applicationArchive.as(JavaArchive.class), auxiliaryArchives, protocol, processor); } throw new IllegalArgumentException(ServletProtocolDeploymentPackager.class.getName() + " can not handle archive of type " + applicationArchive.getClass().getName()); }
@Override public Archive<?> generateDeployment(final TestDeployment testDeployment, final Collection<ProtocolArchiveProcessor> processors) { // Merge auxiliary archives with the declared for ARQ and testrunner support final Archive<?> archive = testDeployment.getApplicationArchive(); if (log.isLoggable(Level.FINEST)) { log.finest("Archive before additional packaging: " + archive.toString(true)); } if (Validate.isArchiveOfType(WebArchive.class, archive)) { ((LibraryContainer<?>) archive).addAsLibraries(testDeployment.getAuxiliaryArchives()); } else { mergeAuxAsClasses(archive, testDeployment); } if (log.isLoggable(Level.FINEST)) { log.finest("Archive after additional packaging: " + archive.toString(true)); } return archive; }
@Override public Archive<?> generateDeployment(final TestDeployment testDeployment, final Collection<ProtocolArchiveProcessor> processors) { // Merge auxiliary archives with the declared for ARQ and testrunner support final Archive archive = testDeployment.getApplicationArchive(); if (log.isLoggable(Level.FINEST)) { log.finest("Archive before additional packaging: " + archive.toString(true)); } if (Validate.isArchiveOfType(WebArchive.class, archive)) { ((LibraryContainer<?>) archive).addAsLibraries(testDeployment.getAuxiliaryArchives()); } else { mergeAuxAsClasses(archive, testDeployment); } if (log.isLoggable(Level.FINEST)) { log.finest("Archive after additional packaging: " + archive.toString(true)); } return archive; }
@Override public void process(TestDeployment testDeployment, Archive<?> protocolArchive) { if (testDeployment.getApplicationArchive().equals(protocolArchive)) { return; // if the protocol is merged in the user Archive, the user is in control. } if (containsBeansXML(testDeployment.getApplicationArchive())) { if (Validate.isArchiveOfType(WebArchive.class, protocolArchive)) { if (!protocolArchive.contains("WEB-INF/beans.xml")) { protocolArchive.as(WebArchive.class).addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); } } else if (Validate.isArchiveOfType(JavaArchive.class, protocolArchive)) { if (!protocolArchive.contains("META-INF/beans.xml")) { protocolArchive.as(JavaArchive.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } } } }
/** * Adds Warp archive to the protocol archive to make it available for WARs and EARs. */ @Override public void process(TestDeployment testDeployment, Archive<?> protocolArchive) { final TestClass testClass = this.testClass.get(); final Archive<?> applicationArchive = testDeployment.getApplicationArchive(); if (WarpCommons.isWarpTest(testClass.getJavaClass())) { if (!Validate.isArchiveOfType(WebArchive.class, protocolArchive)) { throw new IllegalArgumentException("Protocol archives of type " + protocolArchive.getClass() + " not supported by Warp. Please use the Servlet 3.0 protocol."); } addWarpPackageToDeployment(protocolArchive.as(WebArchive.class)); addWarpExtensionsDeployment(protocolArchive.as(WebArchive.class)); removeTestClassFromDeployment(applicationArchive, testClass); } }
@Test public void shouldReadExpectedAndOverrideDeployment() { List<DeploymentDescription> scenario = generate(ExpectedDeploymentExceptionSet.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 1, scenario.size()); DeploymentDescription deploymentOne = scenario.get(0); Assert.assertEquals(false, deploymentOne.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentOne.getArchive())); Assert.assertEquals(Exception.class, deploymentOne.getExpectedException()); }
@Test public void shouldReadExpectedAndOverrideDeploymentWhenTestable() { List<DeploymentDescription> scenario = generate(ExpectedDeploymentExceptionSetTestable.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 1, scenario.size()); DeploymentDescription deploymentOne = scenario.get(0); Assert.assertEquals(true, deploymentOne.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentOne.getArchive())); Assert.assertEquals(Exception.class, deploymentOne.getExpectedException()); }
@Test public void shouldReadExpectedAndOverrideDeployment() { List<DeploymentDescription> scenario = generate(ExpectedDeploymentExceptionSet.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 1, scenario.size()); DeploymentDescription deploymentOne = scenario.get(0); Assert.assertEquals(false, deploymentOne.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentOne.getArchive())); Assert.assertEquals(Exception.class, deploymentOne.getExpectedException()); }
@Test public void shouldReadExpectedAndOverrideDeploymentWhenTestable() { List<DeploymentDescription> scenario = generate(ExpectedDeploymentExceptionSetTestable.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 1, scenario.size()); DeploymentDescription deploymentOne = scenario.get(0); Assert.assertEquals(true, deploymentOne.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentOne.getArchive())); Assert.assertEquals(Exception.class, deploymentOne.getExpectedException()); }
@Test public void shouldHandleMultipleDeploymentsAllDefault() throws Exception { List<DeploymentDescription> scenario = generate(MultiDeploymentsDefault.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 2, scenario.size()); for (DeploymentDescription deployment : scenario) { Assert.assertEquals( "Verify deployment has default target", TargetDescription.DEFAULT, deployment.getTarget()); Assert.assertEquals( "Verify deployment has default protocol", ProtocolDescription.DEFAULT, deployment.getProtocol()); Assert.assertEquals(-1, deployment.getOrder()); Assert.assertEquals(true, deployment.managed()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deployment.getArchive())); } }
@Test public void shouldHandleMultipleDeploymentsAllDefault() throws Exception { List<DeploymentDescription> scenario = generate(MultiDeploymentsDefault.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 2, scenario.size()); for (DeploymentDescription deployment : scenario) { Assert.assertEquals( "Verify deployment has default target", TargetDescription.DEFAULT, deployment.getTarget()); Assert.assertEquals( "Verify deployment has default protocol", ProtocolDescription.DEFAULT, deployment.getProtocol()); Assert.assertEquals(-1, deployment.getOrder()); Assert.assertEquals(true, deployment.managed()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deployment.getArchive())); } }
@Test public void shouldHandleJavaArchive() throws Exception { Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(JavaArchive.class, "applicationArchive.jar"), createAuxiliaryArchives()), processors()); Assert.assertTrue( "Verify that a defined JavaArchive using EE5 WebArchive protocol is build as EnterpriseArchive", Validate.isArchiveOfType(EnterpriseArchive.class, archive)); Assert.assertTrue( "Verify that the auxiliaryArchives EE Modules are placed in /", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); Assert.assertTrue( "Verify that the applicationArchive is placed in /", archive.contains(ArchivePaths.create("/applicationArchive.jar"))); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleJavaArchive() throws Exception { Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(JavaArchive.class, "applicationArchive.jar"), createAuxiliaryArchives()), processors()); Assert.assertTrue( "Verify that a defined JavaArchive using EE6 JavaArchive protocol is build as WebArchive", Validate.isArchiveOfType(WebArchive.class, archive)); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /WEB-INF/lib", archive.contains(ArchivePaths.create("/WEB-INF/lib/arquillian-protocol.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /WEB-INF/lib", archive.contains(ArchivePaths.create("/WEB-INF/lib/auxiliaryArchive2.jar"))); Assert.assertTrue( "Verify that the applicationArchive is placed in /WEB-INF/lib", archive.contains(ArchivePaths.create("/WEB-INF/lib/applicationArchive.jar"))); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleWebArchive() throws Exception { Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(WebArchive.class, "applicationArchive.war"), createAuxiliaryArchives()), processors()); Assert.assertTrue( "Verify that a defined WebArchive using EE6 JavaArchive protocol is build as WebArchive", Validate.isArchiveOfType(WebArchive.class, archive)); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /WEB-INF/lib", archive.contains(ArchivePaths.create("/WEB-INF/lib/arquillian-protocol.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /WEB-INF/lib", archive.contains(ArchivePaths.create("/WEB-INF/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /WEB-INF/lib", archive.contains(ArchivePaths.create("/WEB-INF/lib/auxiliaryArchive2.jar"))); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
Assert.assertEquals(false, deploymentDesc.managed()); Assert.assertEquals(false, deploymentDesc.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentDesc.getArchive())); Assert.assertNull(deploymentDesc.getExpectedException()); } else { Assert.assertEquals(false, deploymentDesc.managed()); Assert.assertEquals(true, deploymentDesc.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentDesc.getArchive())); Assert.assertNull(deploymentDesc.getExpectedException());
Assert.assertEquals(false, deploymentDesc.managed()); Assert.assertEquals(false, deploymentDesc.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentDesc.getArchive())); Assert.assertNull(deploymentDesc.getExpectedException()); } else { Assert.assertEquals(false, deploymentDesc.managed()); Assert.assertEquals(true, deploymentDesc.testable()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deploymentDesc.getArchive())); Assert.assertNull(deploymentDesc.getExpectedException());