protected void doBefore(MergeLifecycleEvent event) { Class<?> clazz = event.getCallerClass(); if (clazz != null && clazz.getName().contains("tck.datastore") == false) { WebArchive war = event.getDeployment(); if (war.get("WEB-INF/classes/capedwarf-compatibility.properties") == null) { Properties properties = new Properties(); properties.put("disable.metadata", Boolean.TRUE.toString()); CapeDwarfArchiveProcessor.addCompatibility(war, properties); } } }
public static EnterpriseArchive createSsoEar() { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); String resourcesLocation = "org/jboss/as/test/integration/web/sso/resources/"; WebArchive war1 = createSsoWar("sso-form-auth1.war"); WebArchive war2 = createSsoWar("sso-form-auth2.war"); WebArchive war3 = createSsoWar("sso-with-no-auth.war"); // Remove jboss-web.xml so the war will not have an authenticator war3.delete(war3.get("WEB-INF/jboss-web.xml").getPath()); JavaArchive webEjbs = ShrinkWrap.create(JavaArchive.class, "jbosstest-web-ejbs.jar"); webEjbs.addAsManifestResource(tccl.getResource(resourcesLocation + "ejb-jar.xml"), "ejb-jar.xml"); webEjbs.addAsManifestResource(tccl.getResource(resourcesLocation + "jboss.xml"), "jboss.xml"); webEjbs.addPackage(StatelessSession.class.getPackage()); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "web-sso.ear"); ear.setApplicationXML(tccl.getResource(resourcesLocation + "application.xml")); ear.addAsModule(war1); ear.addAsModule(war2); ear.addAsModule(war3); ear.addAsModule(webEjbs); return ear; }
public static EnterpriseArchive createSsoEar() { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); String resourcesLocation = "org/jboss/as/test/integration/web/sso/resources/"; WebArchive war1 = createSsoWar("sso-form-auth1.war"); WebArchive war2 = createSsoWar("sso-form-auth2.war"); WebArchive war3 = createSsoWar("sso-with-no-auth.war"); // Remove jboss-web.xml so the war will not have an authenticator war3.delete(war3.get("WEB-INF/jboss-web.xml").getPath()); JavaArchive webEjbs = ShrinkWrap.create(JavaArchive.class, "jbosstest-web-ejbs.jar"); webEjbs.addAsManifestResource(tccl.getResource(resourcesLocation + "ejb-jar.xml"), "ejb-jar.xml"); webEjbs.addAsManifestResource(tccl.getResource(resourcesLocation + "jboss.xml"), "jboss.xml"); webEjbs.addPackage(StatelessSession.class.getPackage()); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "web-sso.ear"); ear.setApplicationXML(tccl.getResource(resourcesLocation + "application.xml")); ear.addAsModule(war1); ear.addAsModule(war2); ear.addAsModule(war3); ear.addAsModule(webEjbs); return ear; }
@Test public void testAddPackage() { // This archive's classloaders should be the app classloader (without `donotchange`) // and an .war-based classloader including the `donotchange` within WEB-INF/classes/... WebArchive war = this.domain.getArchiveFactory().create(WebArchive.class); war.addPackage(DummyClassA.class.getPackage()); Assert.assertNotNull( war.get( "/WEB-INF/classes/" + DummyClassA.class.getName().replace( '.', '/' ) + ".class" ) ); } }
protected void handleWebArchive(WebArchive war) { final Node lib = war.get("WEB-INF/lib"); if (lib != null) { final Set<Node> libs = lib.getChildren(); for (Node jar : libs) { if (jar.getPath().get().contains("appengine-api")) return; } } // do not add GAE jar; e.g. CapeDwarf can work off GAE module boolean ignoreGaeJar = Boolean.getBoolean("ignore.gae.jar"); if (ignoreGaeJar == false) { war.addAsLibraries(Maven.resolver() .loadPomFromFile("pom.xml") .resolve("com.google.appengine:appengine-api-1.0-sdk") .withTransitivity() .as(File.class) ); } } }
@Override protected void handleWebArchive(WebArchive war) { Node node = war.get(WEB_XML_PATH); if (node == null) { throw new IllegalStateException("No web.xml in .war: " + war.toString(true)); } war.addClass(GetLoginUrlServlet.class); WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(node.getAsset().openStream()); war.delete(WEB_XML_PATH); // delete first, so we can re-add webXml.servlet(UserLogin.USER_LOGIN_SERVLET_PATH + "-servlet", GetLoginUrlServlet.class.getName(), new String[]{"/" + UserLogin.USER_LOGIN_SERVLET_PATH}); war.setWebXML(new StringAsset(webXml.exportAsString())); } }
private Archive<?> handleArchive(WebArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, WebArchive protocol, Processor processor) { if (applicationArchive.contains(WEB_XML_PATH)) { WebAppDescriptor applicationWebXml = Descriptors.importAs(WebAppDescriptor.class).from( applicationArchive.get(WEB_XML_PATH).getAsset().openStream()); // SHRINKWRAP-187, to eager on not allowing overrides, delete it first applicationArchive.delete(WEB_XML_PATH); applicationArchive.setWebXML( new StringAsset( WebUtils.mergeWithDescriptor(applicationWebXml).exportAsString())); applicationArchive.merge(protocol, Filters.exclude(".*web\\.xml.*")); } else { applicationArchive.merge(protocol); } applicationArchive.addAsLibraries(auxiliaryArchives.toArray(new Archive<?>[0])); processor.process(applicationArchive); return applicationArchive; }
private Archive<?> handleArchive(WebArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, WebArchive protocol, Processor processor) { ArchivePath webXmlPath = ArchivePaths.create("WEB-INF/web.xml"); if(applicationArchive.contains(webXmlPath)) { WebAppDescriptor applicationWebXml = Descriptors.importAs(WebAppDescriptor.class).from( applicationArchive.get(webXmlPath).getAsset().openStream()); applicationArchive.setWebXML( new StringAsset( mergeWithDescriptor(applicationWebXml).exportAsString())); applicationArchive.merge(protocol, Filters.exclude(".*web\\.xml.*")); } else { applicationArchive.merge(protocol); } applicationArchive.addAsLibraries(auxiliaryArchives.toArray(new Archive<?>[0])); processor.process(applicationArchive); return applicationArchive; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createPortletDeployment(packageName); Node node = war.get("WEB-INF/portlet.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
private Archive<?> handleWar(WebArchive war, WebArchive protocol, Processor processor) { if (war.contains(WEB_XML_PATH)) { WebAppDescriptor applicationWebXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(war.get(WEB_XML_PATH).getAsset().openStream()); // SHRINKWRAP-187, to eager on not allowing overrides, delete it first war.delete(WEB_XML_PATH); war.setWebXML(new StringAsset(mergeWithDescriptor(applicationWebXml).exportAsString())); war.merge(protocol, Filters.exclude(".*web\\.xml.*")); } else { war.merge(protocol); } processor.process(war); return war; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createPortletDeployment(packageName); Node node = war.get("WEB-INF/portlet.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createServletDeployment(true, packageName); Node node = war.get("/WEB-INF/web.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<async-supported>true</async-supported>", "<init-param><param-name>juzu.resource_bundle</param-name><param-value>bundle</param-value></init-param>" + "<async-supported>true</async-supported>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createServletDeployment(true, packageName); Node node = war.get("/WEB-INF/web.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<async-supported>true</async-supported>", "<init-param><param-name>juzu.resource_bundle</param-name><param-value>bundle</param-value></init-param>" + "<async-supported>true</async-supported>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }
@Test public void shouldHandleEnterpriseArchiveWithWebArchive() throws Exception { WebArchive applicationWar = ShrinkWrap.create(WebArchive.class, "applicationArchive.war"); Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(EnterpriseArchive.class, "applicationArchive.ear") .addAsModule(applicationWar), createAuxiliaryArchives()), processors()); Assert.assertFalse( "Verify that the auxiliaryArchives was not added", archive.contains(ArchivePaths.create("arquillian-protocol.war"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); String webXmlContent = TestUtil.convertToString(applicationWar.get("WEB-INF/web.xml").getAsset().openStream()); Assert.assertTrue( "verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive", webXmlContent.contains(ServletTestRunner.class.getName())); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleEnterpriseArchiveWithMultipleWebArchiveAndOneMarkedWebArchive() throws Exception { WebArchive testableArchive = Testable.archiveToTest(ShrinkWrap.create(WebArchive.class)); Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(EnterpriseArchive.class, "applicationArchive.ear") .addAsModule(testableArchive) .addAsModule(ShrinkWrap.create(WebArchive.class)), createAuxiliaryArchives()), processors()); Assert.assertFalse( "Verify that the auxiliaryArchives was not added", archive.contains(ArchivePaths.create("arquillian-protocol.war"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); String webXmlContent = TestUtil.convertToString(testableArchive.get("WEB-INF/web.xml").getAsset().openStream()); Assert.assertTrue( "verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive", webXmlContent.contains(ServletTestRunner.class.getName())); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleEnterpriseArchiveWithMultipleWebArchiveAndOneMarkedWebArchive() throws Exception { WebArchive testableArchive = Testable.archiveToTest(ShrinkWrap.create(WebArchive.class)); Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(EnterpriseArchive.class, "applicationArchive.ear") .addAsModule(testableArchive) .addAsModule(ShrinkWrap.create(WebArchive.class)), createAuxiliaryArchives()), processors()); Assert.assertFalse( "Verify that the auxiliaryArchives was not added", archive.contains(ArchivePaths.create("arquillian-protocol.war"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); String webXmlContent = TestUtil.convertToString( testableArchive.get("WEB-INF/lib/arquillian-protocol.jar/META-INF/web-fragment.xml").getAsset().openStream()); Assert.assertTrue( "verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive", webXmlContent.contains(ServletTestRunner.class.getName())); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleEnterpriseArchiveWithWebArchive() throws Exception { WebArchive applicationWar = ShrinkWrap.create(WebArchive.class, "applicationArchive.war"); Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(EnterpriseArchive.class, "applicationArchive.ear") .addAsModule(applicationWar), createAuxiliaryArchives()), processors()); Assert.assertFalse( "Verify that the auxiliaryArchives was not added", archive.contains(ArchivePaths.create("arquillian-protocol.war"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); String webXmlContent = TestUtil.convertToString(applicationWar.get("WEB-INF/web.xml").getAsset().openStream()); Assert.assertTrue( "verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive", webXmlContent.contains(ServletTestRunner.class.getName())); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleEnterpriseArchiveWithWebArchive() throws Exception { WebArchive applicationWar = ShrinkWrap.create(WebArchive.class, "applicationArchive.war"); Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(EnterpriseArchive.class, "applicationArchive.ear") .addAsModule(applicationWar), createAuxiliaryArchives()), processors()); Assert.assertFalse( "Verify that the auxiliaryArchives was not added", archive.contains(ArchivePaths.create("arquillian-protocol.war"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); String webXmlContent = TestUtil.convertToString( applicationWar.get("WEB-INF/lib/arquillian-protocol.jar/META-INF/web-fragment.xml").getAsset().openStream()); Assert.assertTrue( "verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive", webXmlContent.contains(ServletTestRunner.class.getName())); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }
@Test public void shouldHandleEnterpriseArchiveWithWebArchive() throws Exception { WebArchive applicationWar = ShrinkWrap.create(WebArchive.class, "applicationArchive.war"); Archive<?> archive = new ServletProtocolDeploymentPackager().generateDeployment( new TestDeployment( ShrinkWrap.create(EnterpriseArchive.class, "applicationArchive.ear") .addAsModule(applicationWar), createAuxiliaryArchives()), processors()); Assert.assertFalse( "Verify that the auxiliaryArchives was not added", archive.contains(ArchivePaths.create("arquillian-protocol.war"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar"))); Assert.assertTrue( "Verify that the auxiliaryArchives are placed in /lib", archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar"))); String webXmlContent = TestUtil.convertToString(applicationWar.get("WEB-INF/lib/arquillian-protocol.jar/META-INF/web-fragment.xml").getAsset().openStream()); Assert.assertTrue( "verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive", webXmlContent.contains(ServletTestRunner.class.getName())); Assert.assertTrue( "Verify protocol Processor SPI was called", DummyProcessor.wasCalled); }