[jbosstools-commits] JBoss Tools SVN: r22607 - trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Jun 7 14:02:00 EDT 2010


Author: dgolovin
Date: 2010-06-07 14:02:00 -0400 (Mon, 07 Jun 2010)
New Revision: 22607

Added:
   trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java
Modified:
   trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
Log:
https://jira.jboss.org/browse/JBDS-1202 problems running tests
add assert function to check if plug-in is loaded and activated





Modified: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java	2010-06-07 17:46:33 UTC (rev 22606)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java	2010-06-07 18:02:00 UTC (rev 22607)
@@ -37,9 +37,9 @@
  * @author eskimo
  *
  */
-public class AbstractPluginsLoadTest extends TestCase {
+public class AbstractPluginsLoadTest extends AbstractRuntimeTest {
 
-	public static final String BUNDLE_GROUP_PROVIDER_NAME = "Update Manager Configurator";
+
 	private static final String PLUGIN_TAG_NAME = "plugin";
 	private static final String ID_ATTRIBUTE_NAME = "id"; 
 
@@ -80,43 +80,7 @@
 		}
 	}
 
-	/**
-	 * @param featureId
-	 */
-	private Bundle getFirstBundleFor(String featureId) {
-		IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
-		System.out.println(providers.length);
-		for (IBundleGroupProvider iBundleGroupProvider : providers) {
-			System.out.println(iBundleGroupProvider.getName());
-			IBundleGroup[] bundleGroups = iBundleGroupProvider.getBundleGroups();
-			if(BUNDLE_GROUP_PROVIDER_NAME.equals(iBundleGroupProvider.getName())) {
-				for (IBundleGroup iBundleGroup : bundleGroups) {
-					if(iBundleGroup.getIdentifier().equals(featureId)) {
-						Bundle[] bundles = iBundleGroup.getBundles();
-						for (Bundle bundle : bundles) {
-							return bundle;
-						}
-					}
-				}
-			}
-		}
-		return null;
-	}
-	
-	private boolean isPluginResolved(String pluginId) {
-		Bundle bundle = Platform.getBundle(pluginId);
-		assertNotNull(pluginId + " failed to load.", bundle); //$NON-NLS-1$
-		try {
-			// this line is needed to to force plug-in loading and to change it state to ACTIVE 
-			bundle.loadClass("fake class"); //$NON-NLS-1$
-		} catch (ClassNotFoundException e) {
-			// It happens always because loaded class doesn't not exist
-		}
-		return ((bundle.getState() & Bundle.RESOLVED) > 0)
-				|| ((bundle.getState() & Bundle.ACTIVE) > 0);
-	}
-
-	private void assertPluginsResolved(Bundle[] bundles) {
+	public void assertPluginsResolved(Bundle[] bundles) {
 		for (Bundle bundle : bundles) {
 			assertTrue("Plugin '" + bundle.getSymbolicName() + "' is not resolved", //$NON-NLS-1$ //$NON-NLS-2$
 					isPluginResolved(bundle.getSymbolicName()));
@@ -124,15 +88,7 @@
 		}
 	}
 	
-//	public void testAsComp() throws IOException {
-//		testBundlesAreLoadedFor("org.jboss.ide.eclipse.as.feature");
-//	}
-//	
-//	public void testJdtComp() throws IOException {
-//		testBundlesAreLoadedFor("org.eclipse.jdt");
-//	}
-//	
-//	public void testRichfacesComp() throws IOException {
-//		testBundlesAreLoadedFor("org.jboss.tools.richfaces.feature");
-//	}
+	public void assertPluginResolved(Bundle bundle) {
+		assertPluginsResolved(new Bundle[] {bundle});
+	}
 }

Added: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java	                        (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java	2010-06-07 18:02:00 UTC (rev 22607)
@@ -0,0 +1,60 @@
+package org.jboss.tools.tests;
+
+import org.eclipse.core.runtime.IBundleGroup;
+import org.eclipse.core.runtime.IBundleGroupProvider;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+import junit.framework.TestCase;
+
+public class AbstractRuntimeTest extends TestCase{
+	
+	public static final String BUNDLE_GROUP_PROVIDER_NAME = "Update Manager Configurator";
+	
+	/**
+	 * @param featureId
+	 */
+	public Bundle getFirstBundleFor(String featureId) {
+		IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
+		System.out.println(providers.length);
+		IBundleGroup iBundleGroup = getFirstBundleGroupFor(featureId);
+		Bundle[] bundles = iBundleGroup.getBundles();
+		for (Bundle bundle : bundles) {
+			return bundle;
+		}
+		return null;
+	}
+
+	
+	public IBundleGroup getFirstBundleGroupFor(String featureId) {
+		IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
+		System.out.println(providers.length);
+		for (IBundleGroupProvider iBundleGroupProvider : providers) {
+			System.out.println(iBundleGroupProvider.getName());
+			IBundleGroup[] bundleGroups = iBundleGroupProvider.getBundleGroups();
+			if(BUNDLE_GROUP_PROVIDER_NAME.equals(iBundleGroupProvider.getName())) {
+				for (IBundleGroup iBundleGroup : bundleGroups) {
+					if(iBundleGroup.getIdentifier().equals(featureId)) {
+						return  iBundleGroup;
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	
+	
+	public boolean isPluginResolved(String pluginId) {
+		Bundle bundle = Platform.getBundle(pluginId);
+		assertNotNull(pluginId + " failed to load.", bundle); //$NON-NLS-1$
+		try {
+			// this line is needed to to force plug-in loading and to change it state to ACTIVE 
+			bundle.loadClass("fake class"); //$NON-NLS-1$
+		} catch (ClassNotFoundException e) {
+			// It happens always because loaded class doesn't not exist
+		}
+		return ((bundle.getState() & Bundle.RESOLVED) > 0)
+				|| ((bundle.getState() & Bundle.ACTIVE) > 0);
+	}
+}


Property changes on: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list