Fix test failures which happened if tests were not executed in textual
order
See https://bugs.eclipse.org/314850 (PDE)
Fixed by better shutdown/restart.
diff --git a/testplugins/org.eclipse.objectteams.otdt.test.builder/META-INF/MANIFEST.MF b/testplugins/org.eclipse.objectteams.otdt.test.builder/META-INF/MANIFEST.MF
index 656a1fe..5c4ae8a 100644
--- a/testplugins/org.eclipse.objectteams.otdt.test.builder/META-INF/MANIFEST.MF
+++ b/testplugins/org.eclipse.objectteams.otdt.test.builder/META-INF/MANIFEST.MF
@@ -17,6 +17,7 @@
  org.eclipse.jdt.core,
  org.eclipse.test.performance,
  org.eclipse.objectteams.otdt.tests,
- org.eclipse.objectteams.otequinox
+ org.eclipse.objectteams.otequinox,
+ org.eclipse.pde.core
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/testplugins/org.eclipse.objectteams.otdt.test.builder/plugin.xml b/testplugins/org.eclipse.objectteams.otdt.test.builder/plugin.xml
index 2e2fd3d..35ef774 100644
--- a/testplugins/org.eclipse.objectteams.otdt.test.builder/plugin.xml
+++ b/testplugins/org.eclipse.objectteams.otdt.test.builder/plugin.xml
@@ -15,6 +15,18 @@
                icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
          </team>
       </aspectBinding>
+      <aspectBinding
+            icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+         <basePlugin
+               icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+               id="org.eclipse.pde.core">
+         </basePlugin>
+         <team
+               activation="NONE"
+               class="org.eclipse.objectteams.otdt.test.builder.OTTestingEnvironment"
+               icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+         </team>
+      </aspectBinding>
    </extension>
 
 </plugin>
diff --git a/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTEquinoxBuilderTests.java b/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTEquinoxBuilderTests.java
index 9ea7ed7..fdd653b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTEquinoxBuilderTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTEquinoxBuilderTests.java
@@ -319,8 +319,6 @@
 		expectingNoProblemsFor(project.getPath());
 	}
 	
-	// NOTE: run this as the last test here, because I haven't figured out how to
-	//       clean up after the simulated workbench restart.
 	public void testBaseImportTrac132_2 () throws CoreException, IOException {
 		IJavaProject trac132b= fileManager.setUpJavaProject("Trac132b"); 
 		env.addProject(trac132b.getProject());
@@ -348,6 +346,8 @@
 		env.getWorkspace().save(true, null);
 		JavaModelManager.getJavaModelManager().shutdown();
 		JavaModelManager.doNotUse(); // reset the MANAGER singleton
+		// this one is extra: also restart PDE's PluginModelManager:
+		OTTestingEnvironment.restart();
 		JavaModelManager.getJavaModelManager().startup();
 		new JavaCorePreferenceInitializer().initializeDefaultPreferences();
 		
diff --git a/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTTestingEnvironment.java b/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTTestingEnvironment.java
index 297edfd..6f31dc3 100644
--- a/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTTestingEnvironment.java
+++ b/testplugins/org.eclipse.objectteams.otdt.test.builder/src/org/eclipse/objectteams/otdt/test/builder/OTTestingEnvironment.java
@@ -24,11 +24,39 @@
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.core.JavaCore;
+import base org.eclipse.pde.internal.core.PluginModelManager;
 import base org.eclipse.jdt.core.tests.builder.TestingEnvironment;
 
-/** Purpose: add OTJ_NATURE to test projects (method not normally overridable). */
+@SuppressWarnings("restriction")
 public team class OTTestingEnvironment {
-	
+	static OTTestingEnvironment instance;
+	public OTTestingEnvironment() {
+		instance = this;
+	}
+
+	/** Better shutdown to allow reinitialization */
+	protected class ModelManager playedBy PluginModelManager {
+		
+		ModelManager getInstance() -> PluginModelManager getInstance();
+		
+		@SuppressWarnings("decapsulation")
+		void setFModelManager(ModelManager fModelManager) -> set PluginModelManager fModelManager;
+				
+		@SuppressWarnings("decapsulation")
+		void shutdown() -> void shutdown();
+
+		protected void internalRestart() {
+			shutdown();
+			setFModelManager(null);
+			getInstance();
+		}
+		
+		protected static void restart() {
+			getInstance().internalRestart();
+		}
+	}
+
+	/** Purpose: add OTJ_NATURE to test projects (method not normally overridable). */
 	protected class TestingEnvironment playedBy TestingEnvironment {
 
 		@SuppressWarnings("decapsulation")
@@ -52,4 +80,14 @@
 		addBuilderSpecs <- replace addBuilderSpecs;
 		
 	}
+	
+	/** Restart PDE's PluginModelManager. */
+	public static void restart() {
+		instance.internalRestart();
+	}
+	
+	// need a team instance to invoke a role method:
+	private void internalRestart() {
+		ModelManager.restart();		
+	}
 }