use of org.eclipse.osgi.launch.Equinox in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testSystemNLFragment.
public void testSystemNLFragment() throws BundleException {
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile(getName());
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
configuration.put("osgi.nl", "zh");
Equinox equinox = new Equinox(configuration);
equinox.start();
equinox.getHeaders();
BundleContext systemContext = equinox.getBundleContext();
Bundle systemNLS = systemContext.installBundle(installer.getBundleLocation("test.system.nls"));
equinox.adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(systemNLS));
assertEquals("Wrong fragment state", Bundle.RESOLVED, systemNLS.getState());
assertEquals("Wrong header value.", "TEST NAME", equinox.getHeaders().get(Constants.BUNDLE_NAME));
equinox.stop();
}
use of org.eclipse.osgi.launch.Equinox in project rt.equinox.framework by eclipse.
the class SystemBundleTests method checkParentClassLoader.
private void checkParentClassLoader(Map<String, Object> configuration) {
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
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());
Bundle test = null;
try {
// $NON-NLS-1$
test = equinox.getBundleContext().installBundle(installer.getBundleLocation("substitutes.a"));
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to install bundle", e);
}
try {
// $NON-NLS-1$
Class activatorClazz = test.loadClass("substitutes.x.Ax");
ClassLoader parentCL = activatorClazz.getClassLoader().getParent();
String configParent = (String) configuration.get(Constants.FRAMEWORK_BUNDLE_PARENT);
if (Constants.FRAMEWORK_BUNDLE_PARENT_APP.equals(configParent))
// $NON-NLS-1$
assertTrue("Wrong parent", parentCL == ClassLoader.getSystemClassLoader());
else if (Constants.FRAMEWORK_BUNDLE_PARENT_EXT.equals(configParent))
// $NON-NLS-1$
assertTrue("Wrong parent", parentCL == ClassLoader.getSystemClassLoader().getParent());
else if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equals(configParent))
// $NON-NLS-1$
assertTrue("Wrong parent", parentCL == equinox.getClass().getClassLoader());
} catch (ClassNotFoundException e) {
// $NON-NLS-1$
fail("failed to load class", e);
}
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
FrameworkEvent stopEvent = null;
try {
stopEvent = equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertNotNull("Stop event is null", stopEvent);
// $NON-NLS-1$
assertEquals("Wrong stopEvent", FrameworkEvent.STOPPED, stopEvent.getType());
}
use of org.eclipse.osgi.launch.Equinox in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testBug352275.
public void testBug352275() {
// simple test to create an embedded framework
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile(getName());
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
configuration.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "");
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", 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());
}
use of org.eclipse.osgi.launch.Equinox in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testNullConfigurationValue.
public void testNullConfigurationValue() throws BundleException {
System.setProperty(nullTest, "system");
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile(getName());
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
configuration.put(nullTest, null);
Equinox equinox = new Equinox(configuration);
equinox.start();
String nullValue = equinox.getBundleContext().getProperty(nullTest);
assertNull(nullTest + " is not null: " + nullValue, nullValue);
String systemNullValue = System.getProperty(nullTest);
assertEquals("Wrong system null value.", "system", systemNullValue);
equinox.stop();
}
use of org.eclipse.osgi.launch.Equinox in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testSystemBundle14.
public void testSystemBundle14() {
// Test startlevel property
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle14");
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
// $NON-NLS-1$
configuration.put(Constants.FRAMEWORK_BEGINNING_STARTLEVEL, "10");
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", e);
}
StartLevel st = (StartLevel) equinox.getBundleContext().getService(equinox.getBundleContext().getServiceReference(StartLevel.class.getName()));
// $NON-NLS-1$
assertNotNull("StartLevel service is null", st);
// $NON-NLS-1$
assertEquals("Unexpected start level", 10, st.getStartLevel());
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState());
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
FrameworkEvent stopEvent = null;
try {
stopEvent = equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertNotNull("Stop event is null", stopEvent);
// $NON-NLS-1$
assertEquals("Wrong stopEvent", FrameworkEvent.STOPPED, stopEvent.getType());
}
Aggregations