use of org.eclipse.osgi.storage.url.reference.Handler in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testInitialBundleUpdate.
public void testInitialBundleUpdate() throws IOException {
// test installing bundle with empty manifest
File config = OSGiTestsActivator.getContext().getDataFile(getName());
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected exception in init()", e);
}
// should be in the STARTING state
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState());
BundleContext systemContext = equinox.getBundleContext();
// $NON-NLS-1$
assertNotNull("System context is null", systemContext);
try {
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState());
File bundleFile = null;
try {
File baseDir = new File(config, "bundles");
baseDir.mkdirs();
bundleFile = createBundle(baseDir, getName(), true, true);
} catch (IOException e) {
fail("Unexpected error creating bundles.", e);
}
Bundle testBundle = null;
try {
String location = "reference:file:///" + bundleFile.getAbsolutePath();
URL url = new URL(null, location, new Handler(systemContext.getProperty(EquinoxLocations.PROP_INSTALL_AREA)));
// $NON-NLS-1$
testBundle = systemContext.installBundle("initial@" + location, url.openStream());
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected install error", e);
}
try {
testBundle.update();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected update error", e);
}
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
try {
equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState());
}
Aggregations