use of java.util.jar.JarOutputStream in project felix by apache.
the class CycleDetectionWithWovenClassTest method createBundle.
private static File createBundle(String manifest, Class... classes) throws IOException {
File f = File.createTempFile("felix-bundle", ".jar");
f.deleteOnExit();
Manifest mf = new Manifest(new ByteArrayInputStream(manifest.getBytes("utf-8")));
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
for (Class clazz : classes) {
String path = clazz.getName().replace('.', '/') + ".class";
os.putNextEntry(new ZipEntry(path));
InputStream is = clazz.getClassLoader().getResourceAsStream(path);
byte[] buffer = new byte[8 * 1024];
for (int i = is.read(buffer); i != -1; i = is.read(buffer)) {
os.write(buffer, 0, i);
}
is.close();
os.closeEntry();
}
os.close();
return f;
}
use of java.util.jar.JarOutputStream in project felix by apache.
the class DTOFactoryTest method createBundle.
private File createBundle(String manifest) throws IOException {
File f = File.createTempFile("felix-bundle" + counter++, ".jar", testDir);
Manifest mf = new Manifest(new ByteArrayInputStream(manifest.getBytes("utf-8")));
mf.getMainAttributes().putValue("Manifest-Version", "1.0");
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
os.close();
return f;
}
use of java.util.jar.JarOutputStream in project felix by apache.
the class ExtensionManagerTest method createExtensionBundle.
private File createExtensionBundle() throws IOException {
File f = File.createTempFile("felix-bundle" + counter++, ".jar", testDir);
Manifest mf = new Manifest();
mf.getMainAttributes().putValue("Manifest-Version", "1.0");
mf.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, "extension-bundle");
mf.getMainAttributes().putValue(Constants.BUNDLE_VERSION, "3.2.1");
mf.getMainAttributes().putValue(Constants.FRAGMENT_HOST, "system.bundle;extension:=framework");
mf.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
mf.getMainAttributes().putValue(Constants.EXTENSION_BUNDLE_ACTIVATOR, TestActivator.class.getName());
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
String path = TestActivator.class.getName().replace('.', '/') + ".class";
os.putNextEntry(new ZipEntry(path));
InputStream is = TestActivator.class.getClassLoader().getResourceAsStream(path);
pumpStreams(is, os);
is.close();
os.close();
return f;
}
use of java.util.jar.JarOutputStream in project felix by apache.
the class ImplicitBootDelegationTest method createBundle.
private static File createBundle(String manifest, Class... classes) throws IOException {
File f = File.createTempFile("felix-bundle", ".jar");
f.deleteOnExit();
Manifest mf = new Manifest(new ByteArrayInputStream(manifest.getBytes("utf-8")));
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
for (Class clazz : classes) {
String path = clazz.getName().replace('.', '/') + ".class";
os.putNextEntry(new ZipEntry(path));
InputStream is = clazz.getClassLoader().getResourceAsStream(path);
byte[] buffer = new byte[8 * 1024];
for (int i = is.read(buffer); i != -1; i = is.read(buffer)) {
os.write(buffer, 0, i);
}
is.close();
os.closeEntry();
}
os.close();
return f;
}
use of java.util.jar.JarOutputStream in project felix by apache.
the class MultiReleaseVersionTest method createBundle.
private static File createBundle(String manifest, File tempDir) throws IOException {
File f = File.createTempFile("felix-bundle", ".jar", tempDir);
Manifest mf = new Manifest(new ByteArrayInputStream(manifest.getBytes("utf-8")));
mf.getMainAttributes().putValue("Manifest-Version", "1.0");
// mf.getMainAttributes().putValue(Constants.BUNDLE_ACTIVATOR, StartStopBundleTest.TestBundleActivator.class.getName());
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
String path = Test.class.getName().replace('.', '/') + ".class";
os.putNextEntry(new ZipEntry("META-INF/versions/9/" + path));
InputStream is = Test.class.getClassLoader().getResourceAsStream(path);
byte[] b = new byte[is.available()];
is.read(b);
is.close();
os.write(b);
os.putNextEntry(new ZipEntry("META-INF/versions/9/OSGI-INF/MANIFEST.MF"));
Manifest subMF = new Manifest();
subMF.getMainAttributes().putValue("Import-Package", "org.osgi.framework");
subMF.getMainAttributes().putValue("Manifest-Version", "1.0");
subMF.write(os);
os.close();
return f;
}
Aggregations