if (contextParams != null && contextParams.size() > 0 && !war.contains("WEB-INF/web.xml")) { StringBuilder webXml = new StringBuilder(); webXml.append("<web-app version=\"3.0\" xmlns=\"http://java.sun.com/xml/ns/javaee\" \n");
@Override public boolean contains(final String path) throws IllegalArgumentException { return war.contains(path); }
@Override public boolean contains(final Class<?> aClass) throws IllegalArgumentException { return war.contains(new BasicPath(PATH_CLASSES, AssetUtil.getFullPathForClassResource(aClass))); }
/** * 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)); }
@Test public void shouldNotAddBeansXMLIfArchivesAreEqual() { WebArchive protocol = ShrinkWrap.create(WebArchive.class); new BeansXMLProtocolProcessor().process( new TestDeployment(protocol, new ArrayList<Archive<?>>()), protocol); Assert.assertFalse(protocol.contains("WEB-INF/beans.xml")); }
private void shouldImportDirectory(final String subdirectory) throws Exception { String fileName = SecurityActions.getThreadContextClassLoader().getResource(EXISTING_DIRECTORY_RESOURCE).toURI().getPath(); final File importDirectory = new File(fileName, subdirectory); if (!importDirectory.exists()) { Assert.assertTrue("Unable to create test folder: " + importDirectory.getAbsolutePath(), importDirectory.mkdir()); } Assert.assertTrue("Import test folder does not exist: " + importDirectory.getAbsolutePath(), importDirectory.exists()); importDirectory.deleteOnExit(); ShrinkWrap.create(WebArchive.class, "test.war") .addClass(ExplodedImporter.class) .setWebXML(new StringAsset("<web-app></web-app>")) .as(ExplodedExporter.class).exportExploded(importDirectory); // test import of exploded directory WebArchive war = ShrinkWrap.create(WebArchive.class, "SHRINKWRAP-453.war") .as(ExplodedImporter.class).importDirectory(importDirectory) .as(WebArchive.class); Assert.assertTrue("Expected imported web archive to be present at web archive root", war.contains("/test.war")); Assert.assertTrue("Expected imported web archive to include web.xml", war.contains("/test.war/WEB-INF/web.xml")); }
Assert.assertEquals( "Verify beans.xml was " + (!shouldBeFound ? "not ":"") + "found", shouldBeFound, protocol.contains("WEB-INF/beans.xml"));
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; }
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; }