Utils.safeClose(is); war.delete(node.getPath());
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; }
@Deployment(testable = false) public static WebArchive createDeployment() throws Exception { File f = new File(ServletMetaModelPlugin.class.getProtectionDomain().getCodeSource().getLocation().toURI()); WebArchive war = createServletDeployment(true, "plugin.servlet.base"); war.addAsResource(new StringAsset("abc=def"), "bundle.properties"); war.delete("WEB-INF/web.xml"); war.addAsLibrary(f); return war; }
@Deployment(testable = false) public static WebArchive createDeployment() throws Exception { File f = new File(ServletMetaModelPlugin.class.getProtectionDomain().getCodeSource().getLocation().toURI()); WebArchive war = createServletDeployment(true, "plugin.servlet.base"); war.addAsResource(new StringAsset("abc=def"), "bundle.properties"); war.delete("WEB-INF/web.xml"); war.addAsLibrary(f); return war; }
@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())); } }
/** * SHRINKWRAP-476 */ @Test @ArchiveType(WebContainer.class) public void canDeleteEmbeddedArchiveAddedAsLibrary(){ String name = "test.jar"; WebArchive war = ShrinkWrap.create(WebArchive.class) .addAsLibraries( ShrinkWrap.create(JavaArchive.class, name) .add(EmptyAsset.INSTANCE, "some")); ArchivePath path = ArchivePaths.create("WEB-INF/lib", name); Assert.assertTrue(war.contains(path)); war.delete(path); Assert.assertFalse("Path should have been deleted", war.contains(path)); }
protocol.delete(WEB_XML_PATH); applicationArchive .addAsModule(
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<?> 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 = 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; }