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, TestBundleActivator.class.getName());
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
String path = TestBundleActivator.class.getName().replace('.', '/') + ".class";
os.putNextEntry(new ZipEntry(path));
InputStream is = TestBundleActivator.class.getClassLoader().getResourceAsStream(path);
byte[] b = new byte[is.available()];
is.read(b);
is.close();
os.write(b);
os.close();
return f;
}