Files.copy(n.getAsset().openStream(), f, StandardCopyOption.REPLACE_EXISTING);
assertTrue(tmp.delete()); war.as(ZipExporter.class).exportTo(tmp); final byte[] bytes = Utils.readAsBytes(jar.get("foo/A.class").getAsset().openStream()); return new ClassLoader(Thread.currentThread().getContextClassLoader()) { Class<?> aClass = null;
@Override public InputStream get() throws IOException { return asset.openStream(); } }
@Override public InputStream getInputStream() throws IOException { final InputStream input = asset.openStream(); final Collection<Closeable> c = closeables.get(arName); c.add(input); return input; } };
@Override public InputStream getInputStream() throws IOException { final InputStream input = asset.openStream(); final Collection<Closeable> c = closeables.get(arName); c.add(input); return input; } };
@Override public InputStream getInputStream() throws Exception { return jarEntry.getAsset().openStream(); } }
public InputStream openStream() { try { ByteArrayOutputStream out = new ByteArrayOutputStream(1024); JACOCO_SIG_REMOVER.filterEntry("META-INF/MANIFEST.MF", asset.openStream(), out); return new ByteArrayInputStream(out.toByteArray()); } catch (Exception e) { throw new RuntimeException("Could not instrument MANIFEST.MF Asset " + asset, e); } } }
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; }
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; }
public InputStream openStream() { try { final IRuntime runtime = ArquillianRuntime.getInstance(); final Instrumenter instrumenter = new Instrumenter(runtime); final byte[] instrumented = instrumenter.instrument(asset.openStream(), EX_STRING); return new ByteArrayInputStream(instrumented); } catch (Exception e) { throw new RuntimeException("Could not instrument Asset " + asset, e); } } }
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); } }
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); } }
@Override public Manifest getManifest() throws IOException { ArchivePath manifestPath = ArchivePaths.create("META-INF/MANIFEST.MF"); final Archive<?> archive = this.getArchive(); if (archive.contains(manifestPath)) { return new Manifest(archive.get(manifestPath).getAsset().openStream()); } return 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(); }
@Test public void shouldBeAbleToReadFile() throws Exception { Asset asset = new FileAsset(new File(EXISTING_FILE)); InputStream io = asset.openStream(); Assert.assertNotNull(io); Assert.assertEquals("Should be able to read the content of the resource", "shrinkwrap=true", ApiTestUtils.convertToString(io)); }
@Test public void shouldBeAbleToReadResource() throws Exception { Asset asset = new ClassLoaderAsset(EXISTING_RESOURCE); InputStream io = asset.openStream(); Assert.assertNotNull(io); Assert.assertEquals("Should be able to read the content of the resource", "shrinkwrap=true", ApiTestUtils.convertToString(io)); }
@Override public void undeploy(Archive<?> archive) throws DeploymentException { try { Manifest manifest = new Manifest(archive.get("/META-INF/MANIFEST.MF").getAsset().openStream()); OSGiMetaData metadata = OSGiMetaDataBuilder.load(manifest); undeploy(metadata.getBundleSymbolicName()); } catch (IOException e) { throw new DeploymentException("Cannot undeploy: " + archive.getName(), e); } }
@Test public void shouldBeAbleToReadURL() throws Exception { Asset asset = new UrlAsset(getThreadContextClassLoader().getResource(EXISTING_RESOURCE)); InputStream io = asset.openStream(); Assert.assertNotNull(io); Assert.assertEquals("Should be able to read the content of the resource", "shrinkwrap=true", ApiTestUtils.convertToString(io)); }
public static WebArchive createDeployment(String packageName) throws IOException { WebArchive war = createPortletDeployment(packageName); Node node = war.get("WEB-INF/portlet.xml"); ArchivePath path = node.getPath(); String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8); s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>"); war.delete(path); war.add(new StringAsset(s), path); war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties"); return war; }