+ "Bundle-Version: 1.1.0\n"
+ "Bundle-ManifestVersion: 2\n"
+ "Import-Package: org.osgi.framework\n";
File bundleFile = createBundle(mf, cacheDir);
Framework f = new Felix(params);
f.init();
f.start();
try {
final Bundle bundle = f.getBundleContext().installBundle(bundleFile.toURI().toString());
new Thread()
{
public void run()
{
try
{
bundle.start();
}
catch (BundleException e)
{
e.printStackTrace();
}
}
}.start();
Thread.sleep(DELAY / 4);
long t0 = System.currentTimeMillis();
bundle.stop();
long t1 = System.currentTimeMillis();
assertEquals(Bundle.RESOLVED, bundle.getState());
assertTrue((t1 - t0) > DELAY / 2);
bundle.start();
new Thread()
{
public void run()
{
try
{
bundle.stop();
}
catch (BundleException e)
{
e.printStackTrace();
}
}
}.start();
Thread.sleep(DELAY / 4);
t0 = System.currentTimeMillis();
bundle.start();
t1 = System.currentTimeMillis();
assertEquals(Bundle.ACTIVE, bundle.getState());
assertTrue((t1 - t0) > DELAY / 2);
} finally {
f.stop();
deleteDir(cacheDir);
}
}