private static Node getKeycloakJsonNodeFromWebInf(Archive<?> tmpArchive, String resourceName, boolean useForwardSlash) { String webInfPath = useForwardSlash ? "/WEB-INF" : "WEB-INF"; if (!resourceName.startsWith("/")) { resourceName = "/" + resourceName; } Node jsonNode = tmpArchive.get(webInfPath + resourceName); if (jsonNode == null) { jsonNode = tmpArchive.get(webInfPath + "/classes" + resourceName); } return jsonNode; }
public String format(Archive<?> archive) throws IllegalArgumentException { StringBuilder xml = new StringBuilder(); xml.append("<?xml version=\"1.0\"?>\n<deployment") .append(" name=\"").append(archive.getName()).append("\"") .append(" testclass=\"").append(testClass.getName()).append("\"") .append(">\n"); formatNode(archive.get(ArchivePaths.root()), xml); xml.append("</deployment>").append("\n"); return xml.toString(); }
public String format(Archive<?> archive) throws IllegalArgumentException { StringBuilder xml = new StringBuilder(); xml.append("<?xml version=\"1.0\"?>\n<deployment") .append(" name=\"").append(archive.getName()).append("\"") .append(" testclass=\"").append(testClass.getName()).append("\"") .append(">\n"); formatNode(archive.get(ArchivePaths.root()), xml); xml.append("</deployment>").append("\n"); return xml.toString(); }
private static Node getKeycloakJsonNodeFromWebInf(Archive<?> tmpArchive, String resourceName, boolean useForwardSlash) { String webInfPath = useForwardSlash ? "/WEB-INF" : "WEB-INF"; if (!resourceName.startsWith("/")) { resourceName = "/" + resourceName; } Node jsonNode = tmpArchive.get(webInfPath + resourceName); if (jsonNode == null) { jsonNode = tmpArchive.get(webInfPath + "/classes" + resourceName); } return jsonNode; }
public void process() { if (archive.get("META-INF/arquillian-testable") == null) { return; } archive.add(new StringAsset(archive.getName()), "META-INF/arquillian-testable"); archive.as(JARArchive.class) .addModule("org.wildfly.swarm.arquillian.adapter"); archive.as(JARArchive.class) .addModule("org.wildfly.swarm.arquillian", "deployment"); archive.as(ServiceActivatorArchive.class) .addServiceActivator("org.wildfly.swarm.arquillian.deployment.TestableArchiveServiceActivator"); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#get(org.jboss.shrinkwrap.api.ArchivePath) */ @Override public Node get(ArchivePath path) { return this.getArchive().get(path); }
public void process() { if (archive.get("META-INF/arquillian-testable") == null) { return; } archive.add(new StringAsset(archive.getName()), "META-INF/arquillian-testable"); archive.as(JARArchive.class) .addModule("org.wildfly.swarm.arquillian.adapter"); archive.as(JARArchive.class) .addModule("org.wildfly.swarm.arquillian", "deployment"); archive.as(ServiceActivatorArchive.class) .addServiceActivator("org.wildfly.swarm.arquillian.deployment.TestableArchiveServiceActivator"); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#get(java.lang.String) */ @Override public Node get(String path) throws IllegalArgumentException { return this.getArchive().get(path); }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.Archive#get(java.lang.String) */ @Override public Node get(String path) throws IllegalArgumentException { return this.getArchive().get(path); }
private Manifest getBundleManifest(Archive<?> archive) { try { Node node = archive.get(JarFile.MANIFEST_NAME); if (node == null) return null; Manifest manifest = new Manifest(node.getAsset().openStream()); return manifest; } catch (Exception ex) { return null; } }
public static Manifest getManifest(Archive<?> archive) { try { Node node = archive.get(JarFile.MANIFEST_NAME); if (node != null && node.getAsset() != null) { return new Manifest(node.getAsset().openStream()); } } catch (Exception ex) { throw new IllegalStateException("Cannot obtain manifest", ex); } return null; }
private static boolean hasApplicationServletMapping(Archive<?> archive) { Node webXmlNode = archive.get(PATH_WEB_XML); if (webXmlNode != null) { return hasApplicationServletMapping(webXmlNode.getAsset()); } return false; }
private void validateBundleArchive(Archive<?> archive) throws Exception { Manifest manifest = null; Node node = archive.get(JarFile.MANIFEST_NAME); if (node != null) { manifest = new Manifest(node.getAsset().openStream()); } OSGiManifestBuilder.validateBundleManifest(manifest); } }
/** * {@inheritDoc} * * @see java.nio.file.attribute.BasicFileAttributes#isDirectory() */ @Override public boolean isDirectory() { final ArchivePath archivePath = ArchivePaths.create(path.toString()); Node node = archive.get(archivePath); return node.getAsset() == null; }
/** * {@inheritDoc} * @see org.glassfish.api.deployment.archive.ReadableArchive#getEntry(java.lang.String) */ @Override public InputStream getEntry(String path) throws IOException { return this.getArchive().get(ArchivePaths.create(path)).getAsset().openStream(); }
private String readStringAsset(final ArchivePath path) throws IOException { Asset addedAsset = getArchive().get(path).getAsset(); return new BufferedReader(new InputStreamReader(addedAsset.openStream())).readLine(); } }
@Test public void moveDirectory() throws IOException { final String source = "dir"; this.getArchive().addAsDirectory(source); final String dest = "newPath"; final Path src = fs.getPath(source); final Path dst = fs.getPath(dest); final Path moved = Files.move(src, dst); Assert.assertEquals(dest, moved.toString()); Assert.assertNull("Directory expected after move", this.getArchive().get(dest).getAsset()); }
@Test public void shouldMoveAsset() { final Archive<JavaArchive> archive = ShrinkWrap.create(JavaArchive.class, "archive.jar"); final String sourcePath = "path1"; final String targetPath = "path2"; archive.add(EmptyAsset.INSTANCE, sourcePath); archive.move(sourcePath, targetPath); Assert.assertEquals("The archive should have only one asset", 1, numAssets(archive)); Assert.assertNotNull("The asset should be at the target path", archive.get(targetPath)); }
@Test public void ensureShallowCopyOperatesOnNestedAssets() { Archive<T> archive = getArchive(); Asset asset = new ClassLoaderAsset(NAME_TEST_PROPERTIES); archive.add(asset, "location/sublocation"); Archive<T> copyArchive = archive.shallowCopy(); Assert.assertTrue(copyArchive.contains("location")); Assert.assertTrue(copyArchive.contains("location/sublocation")); Assert.assertSame(copyArchive.get("location/sublocation").getAsset(), archive.get("location/sublocation") .getAsset()); }
@Test @ArchiveType(ManifestContainer.class) public void testAddServiceProviderString() throws Exception { String[] impls = { "do.not.exist.impl.Dummy1", "do.not.exist.impl.Dummy2", "do.not.exist.impl.Dummy3" }; String serviceInterface = "do.not.exist.api.Dummy"; getManifestContainer().addAsServiceProvider(serviceInterface, impls); ArchivePath testPath = new BasicPath(getManifestPath(), "services/" + serviceInterface); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); assertServiceProviderContent(getArchive().get(testPath), impls); }