Bug 563372 - Capture thread dump for timeout during update

Change-Id: I96f1ef0e85ab873f56c612ff6e0d509bfd50a640
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
index 2d278ee..ab849d1 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
@@ -311,8 +311,7 @@
 	static public FrameworkEvent stop(Framework equinox, boolean quietly, long timeout) {
 		if (equinox == null)
 			return null;
-		BundleContext bc = equinox.getBundleContext();
-		final String uuid = bc == null ? null : bc.getProperty(Constants.FRAMEWORK_UUID);
+		final String uuid = getUUID(equinox);
 		try {
 			equinox.stop();
 		} catch (BundleException e) {
@@ -320,6 +319,10 @@
 				fail("Unexpected erorr stopping framework", e); //$NON-NLS-1$
 			}
 		}
+		return waitForStop(equinox, uuid, quietly, timeout);
+	}
+
+	static public FrameworkEvent waitForStop(Framework equinox, String uuid, boolean quietly, long timeout) {
 		try {
 			FrameworkEvent stopEvent = equinox.waitForStop(timeout);
 			if (stopEvent.getType() == FrameworkEvent.WAIT_TIMEDOUT) {
@@ -342,6 +345,11 @@
 		return null;
 	}
 
+	public static String getUUID(Framework equinox) {
+		BundleContext bc = equinox.getBundleContext();
+		return bc == null ? null : bc.getProperty(Constants.FRAMEWORK_UUID);
+	}
+
 	static private String getState(Framework framework) {
 		int state = framework.getState();
 		switch (state) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 61aa581..83b9f34 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -1623,13 +1623,17 @@
 		equinox.start();
 		assertEquals("Unexpected state", Bundle.ACTIVE, testTCCL.getState()); //$NON-NLS-1$
 
+		String uuid = getUUID(equinox);
 		// test that the correct tccl is used for framework update
 		try {
 			equinox.update();
-			checkActive(testTCCL);
 		} catch (Exception e) {
 			fail("Unexpected exception", e); //$NON-NLS-1$
 		}
+		waitForStop(equinox, uuid, false, 10000);
+
+		checkActive(testTCCL);
+
 		systemContext = equinox.getBundleContext();
 		assertEquals("Unexpected state", Bundle.ACTIVE, testTCCL.getState()); //$NON-NLS-1$