@Override public void process(Archive<?> applicationArchive, TestClass testClass) { String prefix = getPrefix(); if (prefix != null) { if (applicationArchive instanceof ResourceContainer) { ResourceContainer<?> container = (ResourceContainer<?>) applicationArchive; container.addAsResource(new StringAsset( toString(filterSystemProperties(prefix))), SystemProperties.FILE_NAME); } } }
private void addResourcesToApplicationArchive(ResourceContainer<?> applicationArchive, List<String> resourcePaths) { for (String path : resourcePaths) { applicationArchive.addAsResource(path); } }
public ArchiveBuilder addAsResource(Asset asset, String resname) { if (archive instanceof WebContainer) { WebContainer<?> container = (WebContainer<?>) archive; ((ResourceContainer<?>)container).addAsResource(asset, resname); } else { ResourceContainer<?> container = (ResourceContainer<?>) archive; container.addAsResource(asset, resname); } return this; }
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof ResourceContainer) { ResourceContainer archive = (ResourceContainer)applicationArchive; archive.addAsResource("io/smallrye/metrics/base-metrics.properties", "/io/smallrye/metrics/base-metrics.properties"); } else { throw new IllegalStateException(this.getClass().getCanonicalName() + " works only with ResourceContainers"); } } }
/** * @param archive deployment archive in which the property file is added */ public void addAsSystemProperties(ResourceContainer<?> archive) { archive.addAsResource(new StringAsset(stringBuilder.toString()), SystemPropertiesLoader.PROPERTIES_FILE_NAME); }
public static void storeProperties(ResourceContainer container, Properties properties, String fileName) throws IOException { StringWriter writer = new StringWriter(); properties.store(writer, "CE-Arquillian"); container.addAsResource(new StringAsset(writer.toString()), fileName); }
protected void addFiles(ResourceContainer<?> archive, File dir, ArchivePath dest) { for (String name : dir.list()) { File file = new File(dir, name); if (file.isDirectory()) { addFiles(archive, file, ArchivePaths.create(dest, name)); } else { archive.addAsResource(file, ArchivePaths.create(dest, name)); } } }
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { String prefix = getPrefix(); if (prefix != null) { if (applicationArchive instanceof ResourceContainer) { ResourceContainer<?> container = (ResourceContainer<?>) applicationArchive; container.addAsResource(new StringAsset( toString(filterSystemProperties(prefix))), SystemProperties.FILE_NAME); } } }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourcePackage() throws Exception { getResourceContainer().addAsResource(AssetUtil.class.getPackage(), "Test.properties"); ArchivePath testPath = new BasicPath(getResourcePath(), NAME_TEST_PROPERTIES); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourcePackageStringTarget() throws Exception { getResourceContainer().addAsResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt"); ArchivePath testPath = new BasicPath(getResourcePath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourcePackagePathTarget() throws Exception { ArchivePath targetPath = ArchivePaths.create("Test.txt"); getResourceContainer().addAsResource(AssetUtil.class.getPackage(), "Test.properties", targetPath); ArchivePath testPath = new BasicPath(getResourcePath(), targetPath); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourceResource() throws Exception { getResourceContainer().addAsResource(NAME_TEST_PROPERTIES); ArchivePath testPath = new BasicPath(getResourcePath(), NAME_TEST_PROPERTIES); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourceFile() throws Exception { getResourceContainer().addAsResource(getFileForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getResourcePath(), "Test.properties"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourceStringTargetURL() throws Exception { getResourceContainer().addAsResource(getURLForClassResource(NAME_TEST_PROPERTIES), "Test.txt"); ArchivePath testPath = new BasicPath(getResourcePath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourceFileRecusivelyWithTarget() throws Exception { File baseFolder = getFileForClassResource("org/jboss/shrinkwrap/impl/base/recursion"); getResourceContainer().addAsResource(baseFolder, "/new-name"); assertArchiveContainsFolderRecursively(baseFolder, getResourcePath(), "/new-name"); }
@Test @ArchiveType(ResourceContainer.class) public void testArchiveContainsEmptyResourceDirectory() throws Exception { String baseFolder = "org/jboss/shrinkwrap/impl/base/recursion"; getResourceContainer().addAsResource(baseFolder); String emptyFolderPath = baseFolder + "/empty"; assertArchiveContainsFolderRecursively(getFileForClassResource(emptyFolderPath), getResourcePath(), emptyFolderPath); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourcePathTargetURL() throws Exception { getResourceContainer().addAsResource(getURLForClassResource(NAME_TEST_PROPERTIES), new BasicPath("Test.txt")); ArchivePath testPath = new BasicPath(getResourcePath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourcePathTargetAsset() throws Exception { getResourceContainer().addAsResource(getAssetForClassResource(NAME_TEST_PROPERTIES), new BasicPath("Test.txt")); ArchivePath testPath = new BasicPath(getResourcePath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourceURL() throws Exception { ArchivePath targetPath = new BasicPath("Test.properties"); getResourceContainer().addAsResource(getURLForClassResource(NAME_TEST_PROPERTIES), targetPath); ArchivePath testPath = new BasicPath(getResourcePath(), targetPath); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ResourceContainer.class) public void testAddResourceUrlWithTargetStringRecursively() throws Exception { String baseFolderPath = "org/jboss/shrinkwrap/impl/base/recursion"; URL baseFolderUrl = getURLForClassResource(baseFolderPath); getResourceContainer().addAsResource(baseFolderUrl, "/new-name"); assertArchiveContainsFolderRecursively(getFileForClassResource(baseFolderPath), getResourcePath(), "/new-name"); }