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 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 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 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)); }
@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 testAddWebResourceResource() throws Exception { getWebContainer().addAsWebResource(NAME_TEST_PROPERTIES); ArchivePath testPath = new BasicPath(getWebPath(), "Test.properties"); 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 testAddWebResourceStringTargetURL() throws Exception { getWebContainer().addAsWebResource(getURLForClassResource(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 testAddWebResourceStringTargetAsset() throws Exception { getWebContainer().addAsWebResource(getAssetForClassResource(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 testAddWebResourcePathTargetResource() throws Exception { getWebContainer().addAsWebResource(NAME_TEST_PROPERTIES, new BasicPath("Test.txt")); ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourceFile() throws Exception { getWebContainer().addAsWebResource(getFileForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getWebPath(), "Test.properties"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourceStringTargetFile() throws Exception { getWebContainer().addAsWebResource(getFileForClassResource(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 testAddWebResourceURL() throws Exception { ArchivePath targetPath = new BasicPath("Test.properties"); getWebContainer().addAsWebResource(getURLForClassResource(NAME_TEST_PROPERTIES), targetPath); ArchivePath testPath = new BasicPath(getWebPath(), targetPath); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePathTargetAsset() throws Exception { getWebContainer().addAsWebResource(getAssetForClassResource(NAME_TEST_PROPERTIES), new BasicPath("Test.txt")); ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePathTargetFile() throws Exception { getWebContainer().addAsWebResource(getFileForClassResource(NAME_TEST_PROPERTIES), new BasicPath("Test.txt")); ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(WebContainer.class) public void testAddWebResourcePathTargetURL() throws Exception { getWebContainer().addAsWebResource(getURLForClassResource(NAME_TEST_PROPERTIES), new BasicPath("Test.txt")); ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }