use of org.osgi.framework.BundleEvent in project rt.equinox.framework by eclipse.
the class ClassLoadingBundleTests method testChainDepedencies.
public void testChainDepedencies() throws Exception {
// $NON-NLS-1$
Bundle chainTest = installer.installBundle("chain.test");
// $NON-NLS-1$
Bundle chainTestA = installer.installBundle("chain.test.a");
// $NON-NLS-1$
Bundle chainTestB = installer.installBundle("chain.test.b");
// $NON-NLS-1$
installer.installBundle("chain.test.c");
// $NON-NLS-1$
installer.installBundle("chain.test.d");
// $NON-NLS-1$
((ITestRunner) chainTest.loadClass("chain.test.TestSingleChain").newInstance()).testIt();
Object[] expectedEvents = new Object[6];
expectedEvents[0] = new BundleEvent(BundleEvent.STARTED, chainTestB);
expectedEvents[1] = new BundleEvent(BundleEvent.STARTED, chainTestA);
expectedEvents[2] = new BundleEvent(BundleEvent.STOPPED, chainTestA);
expectedEvents[3] = new BundleEvent(BundleEvent.STOPPED, chainTestB);
expectedEvents[4] = new BundleEvent(BundleEvent.STARTED, chainTestB);
expectedEvents[5] = new BundleEvent(BundleEvent.STARTED, chainTestA);
installer.refreshPackages(new Bundle[] { chainTestB });
// $NON-NLS-1$
((ITestRunner) chainTest.loadClass("chain.test.TestSingleChain").newInstance()).testIt();
Object[] actualEvents = simpleResults.getResults(6);
compareResults(expectedEvents, actualEvents);
}
use of org.osgi.framework.BundleEvent in project rt.equinox.framework by eclipse.
the class ClassLoadingBundleTests method testMultiChainDepedencies02.
public void testMultiChainDepedencies02() throws Exception {
// $NON-NLS-1$
Bundle chainTestA = installer.installBundle("chain.test.a");
// $NON-NLS-1$
Bundle chainTestB = installer.installBundle("chain.test.b");
// $NON-NLS-1$
Bundle chainTestC = installer.installBundle("chain.test.c");
// $NON-NLS-1$
Bundle chainTestD = installer.installBundle("chain.test.d");
syncListenerResults.getResults(0);
installer.resolveBundles(new Bundle[] { chainTestA, chainTestB, chainTestC, chainTestD });
Object[] expectedEvents = new Object[8];
expectedEvents[0] = new BundleEvent(BundleEvent.RESOLVED, chainTestD);
expectedEvents[1] = new BundleEvent(BundleEvent.RESOLVED, chainTestC);
expectedEvents[2] = new BundleEvent(BundleEvent.RESOLVED, chainTestB);
expectedEvents[3] = new BundleEvent(BundleEvent.RESOLVED, chainTestA);
expectedEvents[4] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestD);
expectedEvents[5] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestC);
expectedEvents[6] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestB);
expectedEvents[7] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestA);
Object[] actualEvents = syncListenerResults.getResults(8);
compareResults(expectedEvents, actualEvents);
installer.refreshPackages(new Bundle[] { chainTestC, chainTestD });
expectedEvents = new Object[20];
expectedEvents[0] = new BundleEvent(BundleEvent.STOPPING, chainTestA);
expectedEvents[1] = new BundleEvent(BundleEvent.STOPPED, chainTestA);
expectedEvents[2] = new BundleEvent(BundleEvent.STOPPING, chainTestB);
expectedEvents[3] = new BundleEvent(BundleEvent.STOPPED, chainTestB);
expectedEvents[4] = new BundleEvent(BundleEvent.STOPPING, chainTestC);
expectedEvents[5] = new BundleEvent(BundleEvent.STOPPED, chainTestC);
expectedEvents[6] = new BundleEvent(BundleEvent.STOPPING, chainTestD);
expectedEvents[7] = new BundleEvent(BundleEvent.STOPPED, chainTestD);
expectedEvents[8] = new BundleEvent(BundleEvent.UNRESOLVED, chainTestA);
expectedEvents[9] = new BundleEvent(BundleEvent.UNRESOLVED, chainTestB);
expectedEvents[10] = new BundleEvent(BundleEvent.UNRESOLVED, chainTestC);
expectedEvents[11] = new BundleEvent(BundleEvent.UNRESOLVED, chainTestD);
expectedEvents[12] = new BundleEvent(BundleEvent.RESOLVED, chainTestD);
expectedEvents[13] = new BundleEvent(BundleEvent.RESOLVED, chainTestC);
expectedEvents[14] = new BundleEvent(BundleEvent.RESOLVED, chainTestB);
expectedEvents[15] = new BundleEvent(BundleEvent.RESOLVED, chainTestA);
expectedEvents[16] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestD);
expectedEvents[17] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestC);
expectedEvents[18] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestB);
expectedEvents[19] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestA);
actualEvents = syncListenerResults.getResults(12);
compareResults(expectedEvents, actualEvents);
}
use of org.osgi.framework.BundleEvent in project rt.equinox.framework by eclipse.
the class ClassLoadingBundleTests method testBug408629.
public void testBug408629() throws BundleException {
// $NON-NLS-1$
Bundle chainTest = installer.installBundle("chain.test");
// $NON-NLS-1$
Bundle chainTestA = installer.installBundle("chain.test.a");
// $NON-NLS-1$
Bundle chainTestB = installer.installBundle("chain.test.b");
// $NON-NLS-1$
Bundle chainTestC = installer.installBundle("chain.test.c");
// $NON-NLS-1$
Bundle chainTestD = installer.installBundle("chain.test.d");
syncListenerResults.getResults(0);
StartLevel sl = installer.getStartLevel();
int currentSL = sl.getStartLevel();
int testSL = currentSL + 1;
sl.setBundleStartLevel(chainTest, testSL);
sl.setBundleStartLevel(chainTestA, testSL);
sl.setBundleStartLevel(chainTestB, testSL);
sl.setBundleStartLevel(chainTestC, testSL);
sl.setBundleStartLevel(chainTestD, testSL);
installer.resolveBundles(new Bundle[] { chainTest, chainTestA, chainTestB, chainTestC, chainTestD });
// eager start chainTestD
chainTestD.start();
Object[] expectedEvents1 = new Object[5];
expectedEvents1[0] = new BundleEvent(BundleEvent.RESOLVED, chainTestD);
expectedEvents1[1] = new BundleEvent(BundleEvent.RESOLVED, chainTestC);
expectedEvents1[2] = new BundleEvent(BundleEvent.RESOLVED, chainTestB);
expectedEvents1[3] = new BundleEvent(BundleEvent.RESOLVED, chainTestA);
expectedEvents1[4] = new BundleEvent(BundleEvent.RESOLVED, chainTest);
Object[] actualEvents = syncListenerResults.getResults(5);
compareResults(expectedEvents1, actualEvents);
try {
System.setProperty("test.bug300692", "true");
System.setProperty("test.bug300692.listener", "true");
chainTest.start();
sl.setStartLevel(testSL);
Object[] expectedFrameworkEvents = new Object[1];
expectedFrameworkEvents[0] = new FrameworkEvent(FrameworkEvent.STARTLEVEL_CHANGED, OSGiTestsActivator.getContext().getBundle(0), null);
Object[] actualFrameworkEvents = frameworkListenerResults.getResults(1);
compareResults(expectedFrameworkEvents, actualFrameworkEvents);
expectedEvents1 = new Object[14];
Object[] expectedEvents2 = new Object[14];
int i1 = 0;
int i2 = 0;
expectedEvents1[i1++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestA);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestA);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestB);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestB);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestC);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestC);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTING, chainTest);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTING, chainTest);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestD);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTING, chainTestB);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTING, chainTestB);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTED, chainTestB);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTED, chainTestB);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.LAZY_ACTIVATION, chainTestD);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTING, chainTestD);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTING, chainTestD);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTED, chainTestD);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTED, chainTestD);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTING, chainTestC);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTING, chainTestC);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTED, chainTestC);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTED, chainTestC);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTING, chainTestA);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTING, chainTestA);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTED, chainTestA);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTED, chainTestA);
expectedEvents1[i1++] = new BundleEvent(BundleEvent.STARTED, chainTest);
expectedEvents2[i2++] = new BundleEvent(BundleEvent.STARTED, chainTest);
actualFrameworkEvents = syncListenerResults.getResults(14);
try {
compareResults(expectedEvents1, actualFrameworkEvents);
} catch (AssertionFailedError e) {
// try the second alternative
compareResults(expectedEvents2, actualFrameworkEvents);
}
} finally {
System.getProperties().remove("test.bug300692");
System.getProperties().remove("test.bug300692.listener");
sl.setStartLevel(currentSL);
Object[] expectedFrameworkEvents = new Object[1];
expectedFrameworkEvents[0] = new FrameworkEvent(FrameworkEvent.STARTLEVEL_CHANGED, OSGiTestsActivator.getContext().getBundle(0), null);
Object[] actualFrameworkEvents = frameworkListenerResults.getResults(1);
compareResults(expectedFrameworkEvents, actualFrameworkEvents);
}
}
use of org.osgi.framework.BundleEvent in project rt.equinox.framework by eclipse.
the class ClassLoadingBundleTests method testBug258659_04.
public void testBug258659_04() throws Exception {
// install a bundle
// $NON-NLS-1$
Bundle test = installer.installBundle("test");
test.start();
SynchronousBundleListener testLoadClassListener = new SynchronousBundleListener() {
public void bundleChanged(BundleEvent event) {
if (event.getType() == BundleEvent.STARTED)
try {
event.getBundle().stop();
} catch (BundleException e) {
simpleResults.addEvent(e);
}
}
};
// clear the results from the initial start
simpleResults.getResults(0);
// listen for the events from refreshing
OSGiTestsActivator.getContext().addBundleListener(testLoadClassListener);
try {
installer.refreshPackages(new Bundle[] { test });
Object[] expectedEvents = new Object[3];
expectedEvents[0] = new BundleEvent(BundleEvent.STOPPED, test);
expectedEvents[1] = new BundleEvent(BundleEvent.STARTED, test);
expectedEvents[2] = new BundleEvent(BundleEvent.STOPPED, test);
Object[] actualEvents = simpleResults.getResults(3);
compareResults(expectedEvents, actualEvents);
} finally {
OSGiTestsActivator.getContext().removeBundleListener(testLoadClassListener);
}
}
use of org.osgi.framework.BundleEvent in project rt.equinox.framework by eclipse.
the class ClassLoadingBundleTests method testSimple.
public void testSimple() throws Exception {
// $NON-NLS-1$
Bundle test = installer.installBundle("test");
test.start();
installer.shutdown();
Object[] expectedEvents = new Object[6];
expectedEvents[0] = new BundleEvent(BundleEvent.INSTALLED, test);
expectedEvents[1] = new BundleEvent(BundleEvent.RESOLVED, test);
expectedEvents[2] = new BundleEvent(BundleEvent.STARTED, test);
expectedEvents[3] = new BundleEvent(BundleEvent.STOPPED, test);
expectedEvents[4] = new BundleEvent(BundleEvent.UNRESOLVED, test);
expectedEvents[5] = new BundleEvent(BundleEvent.UNINSTALLED, test);
Object[] actualEvents = listenerResults.getResults(expectedEvents.length);
compareResults(expectedEvents, actualEvents);
}
Aggregations