aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2013-11-12 11:25:18 (EST)
committerJohn Ross2013-11-13 14:23:20 (EST)
commit1354da95ef22b6ecd9170a3c953776575807e78e (patch)
treec59125b04c0b5847514ba0f4599e758abbdf3b42
parent65fa7e5a41b711b77d10eb290e1b93b9ced6dacc (diff)
downloadrt.equinox.bundles-1354da95ef22b6ecd9170a3c953776575807e78e.zip
rt.equinox.bundles-1354da95ef22b6ecd9170a3c953776575807e78e.tar.gz
rt.equinox.bundles-1354da95ef22b6ecd9170a3c953776575807e78e.tar.bz2
Bug 421487 - Initial test.
Add test. Update copyrights. Update bundle version.
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/AllTests.java3
-rwxr-xr-xbundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/BugTests.java50
4 files changed, 54 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.compendium.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.compendium.tests/META-INF/MANIFEST.MF
index 0c50b1c..47649d3 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.compendium.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.equinox.compendium.tests
-Bundle-Version: 1.1.100
+Bundle-Version: 1.2.0
Bundle-Activator: org.eclipse.equinox.compendium.tests.Activator
Require-Bundle: org.eclipse.core.runtime
Eclipse-LazyStart: true
diff --git a/bundles/org.eclipse.equinox.compendium.tests/pom.xml b/bundles/org.eclipse.equinox.compendium.tests/pom.xml
index 1f8a5a1..e15efb7 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/pom.xml
+++ b/bundles/org.eclipse.equinox.compendium.tests/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.compendium.tests</artifactId>
- <version>1.1.100</version>
+ <version>1.2.0</version>
<packaging>eclipse-test-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/AllTests.java
index 2b6c413..e2a8557 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/AllTests.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others
+ * Copyright (c) 2011, 2013 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
@@ -18,6 +18,7 @@ public class AllTests {
TestSuite suite = new TestSuite("Tests for Equinox Coordinator"); //$NON-NLS-1$
suite.addTestSuite(CoordinationMaxTimeoutTest.class);
suite.addTestSuite(ReverseParticipantOrderNotifyTest.class);
+ suite.addTestSuite(BugTests.class);
return suite;
}
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/BugTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/BugTests.java
new file mode 100755
index 0000000..e8afdda
--- /dev/null
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/coordinator/tests/BugTests.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.coordinator.tests;
+
+import java.lang.ref.WeakReference;
+import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.CoordinationException;
+
+public class BugTests extends CoordinatorTest {
+ public void testBug421487() throws Exception {
+ // Begin a thread coordination on this thread.
+ Coordination c1 = coordinator.begin("c1", 0); //$NON-NLS-1$
+ // Begin a second thread coordination on this thread.
+ Coordination c2 = coordinator.begin("c2", 0); //$NON-NLS-1$
+ // c2's enclosing coordination will be c1.
+ assertEquals("Wrong enclosing coordination", c1, c2.getEnclosingCoordination()); //$NON-NLS-1$
+ WeakReference reference = new WeakReference(c1);
+ // Set c1 to null so it will become weakly reachable and enqueued.
+ c1 = null;
+ // Ensure c1 becomes weakly reachable.
+ for (int i = 0; i < 100 && reference.get() != null; i++)
+ // Force garbage collection.
+ System.gc();
+ assertNull("The enclosing coordination never became weakly reachable", reference.get()); //$NON-NLS-1$
+ // For some reason, this delay is necessary to force the failure
+ // condition to occur when running "normally". The failure will occur
+ // without this delay when running in debug mode with or without
+ // breakpoints.
+ Thread.sleep(1000);
+ try {
+ // End the enclosed coordination.
+ c2.end();
+ } catch (CoordinationException e) {
+ // A CoordinationException of type ALREADY_ENDED is expected since
+ // the coordination was failed.
+ assertEquals("Wrong type", CoordinationException.ALREADY_ENDED, e.getType()); //$NON-NLS-1$
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ fail("Received NPE while ending the coordination"); //$NON-NLS-1$
+ }
+ }
+}