diff options
author | Thomas Watson | 2016-02-19 15:28:02 +0000 |
---|---|---|
committer | Thomas Watson | 2016-02-19 18:54:58 +0000 |
commit | 91d2439c80d81fccdcd8fe1150dbed119182eadf (patch) | |
tree | 8bb2f817319963f1dd8acf144dbbe0b7023d2b33 /bundles/org.eclipse.osgi.tests | |
parent | 05d4b77e904d06e6d2c1bff98231447db2ab7195 (diff) | |
download | rt.equinox.framework-91d2439c80d81fccdcd8fe1150dbed119182eadf.tar.gz rt.equinox.framework-91d2439c80d81fccdcd8fe1150dbed119182eadf.tar.xz rt.equinox.framework-91d2439c80d81fccdcd8fe1150dbed119182eadf.zip |
Bug 487842 - Unable to acquire state change lock for the module when
starting a bundle
Must increment inStart BEFORE acquiring the STARTED state the first
time. There is still an unavoidable timing issue. The window is now
as small as possible. A new flag is added to disable auto-starting
newly resolved bundles that are marked for persistent start.
Also fixed bug in how modules are restarted after a refresh.
They must use their activation policy if it is set.
Change-Id: I8175af9ed29e611659a8b8bc0b64b0a3874e68bf
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
2 files changed, 30 insertions, 10 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java index 57d1bd811..1f623a1fe 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -98,7 +98,7 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { Bundle chainTestD = installer.installBundle("chain.test.d"); //$NON-NLS-1$ chainTest.loadClass("chain.test.TestMultiChain").newInstance(); //$NON-NLS-1$ - Object[] expectedEvents = new Object[12]; + Object[] expectedEvents = new Object[8]; expectedEvents[0] = new BundleEvent(BundleEvent.STARTED, chainTestD); expectedEvents[1] = new BundleEvent(BundleEvent.STARTED, chainTestB); expectedEvents[2] = new BundleEvent(BundleEvent.STARTED, chainTestC); @@ -107,14 +107,20 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { expectedEvents[5] = new BundleEvent(BundleEvent.STOPPED, chainTestB); expectedEvents[6] = new BundleEvent(BundleEvent.STOPPED, chainTestC); expectedEvents[7] = new BundleEvent(BundleEvent.STOPPED, chainTestD); - expectedEvents[8] = new BundleEvent(BundleEvent.STARTED, chainTestD); - expectedEvents[9] = new BundleEvent(BundleEvent.STARTED, chainTestC); - expectedEvents[10] = new BundleEvent(BundleEvent.STARTED, chainTestB); - expectedEvents[11] = new BundleEvent(BundleEvent.STARTED, chainTestA); installer.refreshPackages(new Bundle[] {chainTestC, chainTestD}); - Object[] actualEvents = simpleResults.getResults(12); + Object[] actualEvents = simpleResults.getResults(8); + compareResults(expectedEvents, actualEvents); + + chainTest.loadClass("chain.test.TestMultiChain").newInstance(); //$NON-NLS-1$ + expectedEvents = new Object[4]; + expectedEvents[0] = new BundleEvent(BundleEvent.STARTED, chainTestD); + expectedEvents[1] = new BundleEvent(BundleEvent.STARTED, chainTestB); + expectedEvents[2] = new BundleEvent(BundleEvent.STARTED, chainTestC); + expectedEvents[3] = new BundleEvent(BundleEvent.STARTED, chainTestA); + + actualEvents = simpleResults.getResults(4); compareResults(expectedEvents, actualEvents); } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java index efb7eda25..90b6cad05 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java @@ -988,7 +988,7 @@ public class TestModuleContainer extends AbstractTest { container.refresh(Arrays.asList(lazy1)); actual = database.getModuleEvents(); - expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.STOPPING, State.STOPPING), new DummyModuleEvent(lazy1, ModuleEvent.STOPPED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(lazy1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.STARTING, State.STARTING), new DummyModuleEvent(lazy1, ModuleEvent.STARTED, State.ACTIVE))); + expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.STOPPING, State.STOPPING), new DummyModuleEvent(lazy1, ModuleEvent.STOPPED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(lazy1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.LAZY_ACTIVATION, State.LAZY_STARTING))); assertEvents(expected, actual, true); container.update(lazy1, OSGiManifestBuilderFactory.createBuilder(getManifest("lazy1_v1.MF")), null); @@ -2369,7 +2369,20 @@ public class TestModuleContainer extends AbstractTest { @Test public void testStartOnResolve() throws BundleException, IOException { - DummyContainerAdaptor adaptor = createDummyAdaptor(); + doTestStartOnResolve(true); + } + + @Test + public void testDisableStartOnResolve() throws BundleException, IOException { + doTestStartOnResolve(false); + } + + private void doTestStartOnResolve(boolean enabled) throws BundleException, IOException { + Map<String, String> configuration = new HashMap<String, String>(); + if (!enabled) { + configuration.put(EquinoxConfiguration.PROP_MODULE_AUTO_START_ON_RESOLVE, Boolean.toString(false)); + } + DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), configuration); ModuleContainer container = adaptor.getContainer(); // install the system.bundle @@ -2405,8 +2418,9 @@ public class TestModuleContainer extends AbstractTest { report = container.resolve(Collections.<Module> emptySet(), false); Assert.assertNull("Found a error.", report.getResolutionException()); + State expectedState = enabled ? State.ACTIVE : State.RESOLVED; for (Module module : modules) { - Assert.assertEquals("Wrong state.", State.ACTIVE, module.getState()); + Assert.assertEquals("Wrong state.", expectedState, module.getState()); } } |