public ArchiveBuilder addAsResource(String resname) { if (archive instanceof WebContainer) { WebContainer<?> container = (WebContainer<?>) archive; container.addAsWebResource(resname, resname); } else { ResourceContainer<?> container = (ResourceContainer<?>) archive; container.addAsResource(resname); } return this; }
@Test @ArchiveType(WebContainer.class) public void testAddWebInfResourcePackageStringTarget() throws Exception { getWebContainer().addAsWebInfResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt"); ArchivePath testPath = new BasicPath(getWebInfPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testSetWebXMLResourceInPackage() throws Exception { getWebContainer().setWebXML(AssetUtil.class.getPackage(), "Test.properties"); ArchivePath testPath = new BasicPath(getWebInfPath(), "web.xml"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePackages() throws Exception { getWebContainer().addAsWebResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties"); ArchivePath testPath = new BasicPath(getWebPath(), NAME_TEST_PROPERTIES); ArchivePath testPath2 = new BasicPath(getWebPath(), NAME_TEST_PROPERTIES_2); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); Assert.assertTrue("Archive should contain " + testPath2, getArchive().contains(testPath2)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebInfResourcePackages() throws Exception { getWebContainer().addAsWebInfResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties"); ArchivePath testPath = new BasicPath(getWebInfPath(), NAME_TEST_PROPERTIES); ArchivePath testPath2 = new BasicPath(getWebInfPath(), NAME_TEST_PROPERTIES_2); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); Assert.assertTrue("Archive should contain " + testPath2, getArchive().contains(testPath2)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePackage() throws Exception { getWebContainer().addAsWebResource(AssetUtil.class.getPackage(), "Test.properties"); ArchivePath testPath = new BasicPath(getWebPath(), NAME_TEST_PROPERTIES); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebInfResourcePackage() throws Exception { getWebContainer().addAsWebInfResource(AssetUtil.class.getPackage(), "Test.properties"); ArchivePath testPath = new BasicPath(getWebInfPath(), NAME_TEST_PROPERTIES); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testSetWebXMLResource() throws Exception { getWebContainer().setWebXML(NAME_TEST_PROPERTIES); ArchivePath testPath = new BasicPath(getWebInfPath(), "web.xml"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePackageStringTarget() throws Exception { getWebContainer().addAsWebResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt"); ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebInfResourcePackagePathTarget() throws Exception { ArchivePath targetPath = ArchivePaths.create("Test.txt"); getWebContainer().addAsWebInfResource(AssetUtil.class.getPackage(), "Test.properties", targetPath); ArchivePath testPath = new BasicPath(getWebInfPath(), targetPath); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testSetWebXMLURL() throws Exception { getWebContainer().setWebXML(getURLForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getWebInfPath(), "web.xml"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePackagePathTarget() throws Exception { ArchivePath targetPath = ArchivePaths.create("Test.txt"); getWebContainer().addAsWebResource(AssetUtil.class.getPackage(), "Test.properties", targetPath); ArchivePath testPath = new BasicPath(getWebPath(), targetPath); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
/** * SHRINKWRAP-275 */ @Test @ArchiveType(WebContainer.class) public void testAddWebInfStringTargetResourceFromJar() throws Exception { // Causing NPE getWebContainer().addAsWebInfResource("java/lang/String.class", "String.class"); ArchivePath testPath = new BasicPath(getWebInfPath(), "String.class"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testSetWebXMLAsset() throws Exception { getWebContainer().setWebXML(getAssetForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getWebInfPath(), "web.xml"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourceStringTargetResource() throws Exception { getWebContainer().addAsWebResource(NAME_TEST_PROPERTIES, "Test.txt"); ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebInfResourceResource() throws Exception { getWebContainer().addAsWebInfResource(NAME_TEST_PROPERTIES); ArchivePath testPath = new BasicPath(getWebInfPath(), "Test.properties"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testSetWebXMLFile() throws Exception { getWebContainer().setWebXML(getFileForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getWebInfPath(), "web.xml"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
/** * SHRINKWRAP-275 */ @Test @ArchiveType(WebContainer.class) public void testAddWebStringTargetResourceFromJar() throws Exception { // Causing NPE getWebContainer().addAsWebResource("java/lang/String.class", "String.class"); ArchivePath testPath = new BasicPath(getWebPath(), "String.class"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebInfResourceStringTargetResource() throws Exception { getWebContainer().addAsWebInfResource(NAME_TEST_PROPERTIES, "Test.txt"); ArchivePath testPath = new BasicPath(getWebInfPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourceResource() throws Exception { getWebContainer().addAsWebResource(NAME_TEST_PROPERTIES); ArchivePath testPath = new BasicPath(getWebPath(), "Test.properties"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }