[jboss-osgi-commits] JBoss-OSGI SVN: r97227 - in projects/jboss-osgi/trunk/testsuite: example/src/test/java/org/jboss/test/osgi/example/webapp and 12 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Dec 1 08:37:59 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-12-01 08:37:57 -0500 (Tue, 01 Dec 2009)
New Revision: 97227

Modified:
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java
Log:
Pull up test assertions

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -32,7 +32,7 @@
 import org.jboss.osgi.husky.RuntimeContext;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.OSGiTest;
 import org.jboss.test.osgi.example.simple.bundle.SimpleService;
 import org.junit.After;
 import org.junit.Before;
@@ -49,7 +49,7 @@
  * @author thomas.diesler at jboss.com
  * @since 12-Feb-2009
  */
-public class SimpleHuskyTestCase
+public class SimpleHuskyTestCase extends OSGiTest
 {
    @RuntimeContext
    public BundleContext context;
@@ -64,7 +64,7 @@
       if (context == null)
       {
          // Get the default runtime
-         runtime = new OSGiTestHelper().getDefaultRuntime();
+         runtime = getDefaultRuntime();
          runtime.addCapability(new HuskyCapability());
          
          // Install the bundle
@@ -72,7 +72,7 @@
          
          // Start the bundle
          bundle.start();
-         assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+         assertBundleState(Bundle.ACTIVE, bundle.getState());
       }
    }
    

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,11 +23,9 @@
 
 //$Id$
 
-import static org.junit.Assert.assertEquals;
-
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.OSGiTest;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 
@@ -37,13 +35,13 @@
  * @author thomas.diesler at jboss.com
  * @since 12-Feb-2009
  */
-public class SimpleTestCase
+public class SimpleTestCase extends OSGiTest
 {
    @Test
    public void testSimpleBundle() throws Exception
    {
       // Get the default runtime
-      OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+      OSGiRuntime runtime = getDefaultRuntime();
       
       try
       {
@@ -52,7 +50,7 @@
 
          // Start the bundle
          bundle.start();
-         assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+         assertBundleState(Bundle.ACTIVE, bundle.getState());
 
          // Uninstall the bundle
          bundle.uninstall();

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
 
 // $Id$
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -68,7 +67,7 @@
    public void testServletAccess() throws Exception
    {
       OSGiBundle bundle = runtime.installBundle("example-webapp-negative.war");
-      assertEquals(Bundle.INSTALLED, bundle.getState());
+      assertBundleState(Bundle.INSTALLED, bundle.getState());
 
       try
       {

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,10 +23,9 @@
 
 //$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
 
-import static org.junit.Assert.assertEquals;
-
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTest;
 import org.jboss.osgi.testing.OSGiTestHelper;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -43,7 +42,7 @@
  * @author thomas.diesler at jboss.com
  * @since 19-Jun-2009
  */
-public class OSGI112TestCase
+public class OSGI112TestCase extends OSGiTest
 {
    private static OSGiRuntime runtime;
 
@@ -81,6 +80,6 @@
       // If the BP extender detects some issue with the BP configuration, it can/should log this information 
       // but it cannot prevent the bundle from starting.
       
-      assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,8 +23,6 @@
 
 //$Id: OSGI142TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 import org.jboss.osgi.spi.framework.OSGiBootstrap;
 import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
@@ -66,26 +64,26 @@
          Bundle bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi142-bundleX.jar").toExternalForm());
          bundleX.start();
          
-         assertBundleLoadClass(bundleX, BeanX.class, true);
+         assertBundleLoadClass(bundleX, BeanX.class.getName(), true);
          
          Bundle bundleA = sysContext.installBundle(getTestArchiveURL("jbosgi142-bundleA.jar").toExternalForm());
          bundleA.start();
          
-         assertBundleLoadClass(bundleA, BeanA.class, true);
+         assertBundleLoadClass(bundleA, BeanA.class.getName(), true);
          
          Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi142-bundleB.jar").toExternalForm());
          bundleB.start();
          
-         assertBundleLoadClass(bundleB, BeanB.class, true);
+         assertBundleLoadClass(bundleB, BeanB.class.getName(), true);
          
-         assertBundleLoadClass(bundleA, BeanX.class, true);
-         assertBundleLoadClass(bundleB, BeanX.class, true);
+         assertBundleLoadClass(bundleA, BeanX.class.getName(), true);
+         assertBundleLoadClass(bundleB, BeanX.class.getName(), true);
     
-         assertBundleLoadClass(bundleX, BeanA.class, false);
-         assertBundleLoadClass(bundleX, BeanB.class, false);
+         assertBundleLoadClass(bundleX, BeanA.class.getName(), false);
+         assertBundleLoadClass(bundleX, BeanB.class.getName(), false);
          
-         assertBundleLoadClass(bundleA, BeanB.class, false);
-         assertBundleLoadClass(bundleB, BeanA.class, false);
+         assertBundleLoadClass(bundleA, BeanB.class.getName(), false);
+         assertBundleLoadClass(bundleB, BeanA.class.getName(), false);
       }
       finally
       {
@@ -93,28 +91,4 @@
          framework.waitForStop(1000);
       }
    }
-
-   private void assertBundleLoadClass(Bundle bundle, Class<?> expClazz, boolean success) 
-   {
-      String message = bundle.getSymbolicName() + " loads " + expClazz.getName();
-      
-      Class<?> wasClass;
-      try
-      {
-         wasClass = bundle.loadClass(expClazz.getName());
-         if (success)
-         {
-            assertEquals(message, expClazz.getName(), wasClass.getName());
-         }
-         else
-         {
-            fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + wasClass.getClassLoader());
-         }
-      }
-      catch (ClassNotFoundException ex)
-      {
-         if (success)
-            fail("Unexpected ClassNotFoundException for: " + message);
-      }
-   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -90,14 +90,14 @@
       BundleContext sysContext = framework.getBundleContext();
       
       Bundle bundleA = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleA.jar").toExternalForm());
-      assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleA.getState());
+      assertBundleState(Bundle.INSTALLED, bundleA.getState());
 
       Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleB.jar").toExternalForm());
-      assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleB.getState());
+      assertBundleState(Bundle.INSTALLED, bundleB.getState());
       
       bundleB.start();
-      assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleB.getState());
-      assertEquals("RESOLVED expected", Bundle.RESOLVED, bundleA.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.RESOLVED, bundleA.getState());
       
       Class<?> classAA = bundleA.loadClass(BeanA.class.getName());
       Class<?> classAB = bundleB.loadClass(BeanA.class.getName());
@@ -117,14 +117,14 @@
       BundleContext sysContext = framework.getBundleContext();
       
       Bundle bundleC = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleC.jar").toExternalForm());
-      assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleC.getState());
+      assertBundleState(Bundle.INSTALLED, bundleC.getState());
 
       Bundle bundleD = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleD.jar").toExternalForm());
-      assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleD.getState());
+      assertBundleState(Bundle.INSTALLED, bundleD.getState());
       
       bundleD.start();
-      assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleD.getState());
-      assertEquals("RESOLVED expected", Bundle.RESOLVED, bundleC.getState());
+      assertBundleState(Bundle.ACTIVE, bundleD.getState());
+      assertBundleState(Bundle.RESOLVED, bundleC.getState());
       
       Class<?> classBC = bundleC.loadClass(BeanB.class.getName());
       Class<?> classBD = bundleD.loadClass(BeanB.class.getName());
@@ -144,14 +144,14 @@
       BundleContext sysContext = framework.getBundleContext();
       
       Bundle bundleD = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleD.jar").toExternalForm());
-      assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleD.getState());
+      assertBundleState(Bundle.INSTALLED, bundleD.getState());
       
       Bundle bundleC = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleC.jar").toExternalForm());
-      assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleC.getState());
+      assertBundleState(Bundle.INSTALLED, bundleC.getState());
 
       bundleD.start();
-      assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleD.getState());
-      assertEquals("RESOLVED expected", Bundle.RESOLVED, bundleC.getState());
+      assertBundleState(Bundle.ACTIVE, bundleD.getState());
+      assertBundleState(Bundle.RESOLVED, bundleC.getState());
       
       Class<?> classBC = bundleC.loadClass(BeanB.class.getName());
       Class<?> classBD = bundleD.loadClass(BeanB.class.getName());

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,8 +23,6 @@
 
 //$Id:$
 
-import static org.junit.Assert.assertEquals;
-
 import org.jboss.osgi.spi.capability.LogServiceCapability;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
@@ -53,7 +51,7 @@
          OSGiBundle bundleA = runtime.installBundle("jbosgi161-bundle.jar");
          bundleA.start();
          
-         assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+         assertBundleState(Bundle.ACTIVE, bundleA.getState());
          bundleA.uninstall();
       }
       finally

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
 
 //$Id:$
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import org.jboss.osgi.microcontainer.MicrocontainerCapability;
@@ -58,7 +57,7 @@
          if (bundle != null)
          {
             assertNotNull("MicrocontainerService available", bundle);
-            assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+            assertBundleState(Bundle.ACTIVE, bundle.getState());
             
             // Update the MC bundle
             bundle.stop();

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -56,7 +56,7 @@
          OSGiBundle bundleA = runtime.installBundle("jbosgi37-bundleA.jar");
          bundleA.start();
          
-         assertEquals("Bundle started", Bundle.ACTIVE, bundleA.getState());
+         assertBundleState(Bundle.ACTIVE, bundleA.getState());
          
          List<String> relevant = new ArrayList<String>();
          for (OSGiBundle bundle : runtime.getBundles())

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -24,10 +24,8 @@
 //$Id: OSGI38TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
 
 import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
 
 import org.jboss.osgi.spi.capability.CompendiumCapability;
-import org.jboss.osgi.spi.util.ConstantsHelper;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
 import org.jboss.osgi.testing.OSGiTest;
@@ -271,11 +269,4 @@
       }
    }
 
-   private void assertBundleState(int expState, int wasState)
-   {
-      String expstr = ConstantsHelper.bundleState(expState);
-      String wasstr = ConstantsHelper.bundleState(wasState);
-      assertEquals("Bundle " + expstr, expstr, wasstr);
-   }
-
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
 
 //$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import org.jboss.osgi.testing.OSGiBundle;
@@ -71,7 +70,7 @@
    public void testVerifyUnresolved() throws Exception
    {
       OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
-      assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+      assertBundleState(Bundle.INSTALLED, bundleB.getState());
 
       try
       {
@@ -87,8 +86,8 @@
 
       bundleB.start();
 
-      assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
-      assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.RESOLVED, bundleX.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
 
       bundleB.uninstall();
       bundleX.uninstall();
@@ -113,8 +112,8 @@
 
       bundleB.start();
 
-      assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
-      assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.RESOLVED, bundleX.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
 
       // Uninstall X before B
       bundleX.uninstall();
@@ -125,7 +124,7 @@
 
       bundleB.start();
 
-      assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
 
       bundleB.uninstall();
    }
@@ -138,8 +137,8 @@
 
       bundleB.start();
 
-      assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
-      assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.RESOLVED, bundleX.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
 
       // Uninstall X before B
       bundleX.uninstall();
@@ -166,8 +165,8 @@
 
       bundleB.start();
 
-      assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
-      assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+      assertBundleState(Bundle.RESOLVED, bundleX.getState());
+      assertBundleState(Bundle.ACTIVE, bundleB.getState());
 
       bundleB.uninstall();
       bundleX.uninstall();

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -59,7 +59,7 @@
          OSGiBundle bundleA = runtime.installBundle("jbosgi41-bundleA.jar");
          bundleA.start();
          
-         assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+         assertBundleState(Bundle.ACTIVE, bundleA.getState());
          
          File dataFile = getBundleDataFile(bundleA, "config/jbosgi41.txt");
          assertTrue("File exists: " + dataFile, dataFile.exists());

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -31,6 +31,7 @@
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
 import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.testing.OSGiTest;
 import org.jboss.osgi.testing.OSGiTestHelper;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -47,7 +48,7 @@
  * @author thomas.diesler at jboss.com
  * @since 21-Jul-2009
  */
-public class OSGI92TestCase
+public class OSGI92TestCase extends OSGiTest
 {
    private static OSGiRuntime runtime;
 
@@ -74,7 +75,7 @@
       OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
       bundleA.start();
 
-      assertEquals(Bundle.ACTIVE, bundleA.getState());
+      assertBundleState(Bundle.ACTIVE, bundleA.getState());
       
       String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
       OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
 
 //$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import org.jboss.osgi.spi.util.ConstantsHelper;
@@ -74,22 +73,22 @@
    public void testAllGood() throws Exception
    {
       OSGiBundle bundle = runtime.installBundle("jbosgi99-allgood.jar");
-      assertBundleState(bundle, Bundle.INSTALLED);
+      assertBundleState(Bundle.INSTALLED, bundle.getState());
 
       bundle.start();
-      assertBundleState(bundle, Bundle.ACTIVE);
+      assertBundleState(Bundle.ACTIVE, bundle.getState());
 
       bundle.uninstall();
 
       if (runtime.isRemoteRuntime() == false)
-         assertBundleState(bundle, Bundle.UNINSTALLED);
+         assertBundleState(Bundle.UNINSTALLED, bundle.getState());
    }
 
    @Test
    public void testFailOnResolve() throws Exception
    {
       OSGiBundle bundle = runtime.installBundle("jbosgi99-failonresolve.jar");
-      assertBundleState(bundle, Bundle.INSTALLED);
+      assertBundleState(Bundle.INSTALLED, bundle.getState());
 
       try
       {
@@ -99,20 +98,20 @@
       catch (BundleException ex)
       {
          log.error("State on error: " + ConstantsHelper.bundleState(bundle.getState()), ex);
-         assertBundleState(bundle, Bundle.INSTALLED);
+         assertBundleState(Bundle.INSTALLED, bundle.getState());
       }
 
       bundle.uninstall();
 
       if (runtime.isRemoteRuntime() == false)
-         assertBundleState(bundle, Bundle.UNINSTALLED);
+         assertBundleState(Bundle.UNINSTALLED, bundle.getState());
    }
 
    @Test
    public void testFailOnStart() throws Exception
    {
       OSGiBundle bundle = runtime.installBundle("jbosgi99-failonstart.jar");
-      assertBundleState(bundle, Bundle.INSTALLED);
+      assertBundleState(Bundle.INSTALLED, bundle.getState());
 
       try
       {
@@ -122,19 +121,12 @@
       catch (BundleException ex)
       {
          log.error("State on error: " + ConstantsHelper.bundleState(bundle.getState()), ex);
-         assertBundleState(bundle, Bundle.RESOLVED);
+         assertBundleState(Bundle.RESOLVED, bundle.getState());
       }
 
       bundle.uninstall();
 
       if (runtime.isRemoteRuntime() == false)
-         assertBundleState(bundle, Bundle.UNINSTALLED);
+         assertBundleState(Bundle.UNINSTALLED, bundle.getState());
    }
-
-   private void assertBundleState(OSGiBundle bundle, int expState)
-   {
-      String exp = ConstantsHelper.bundleState(expState);
-      String was = ConstantsHelper.bundleState(bundle.getState());
-      assertEquals("Bundle " + exp, exp, was);
-   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java	2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java	2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,8 +23,6 @@
 
 //$Id: StartLevelRemoteTestCase.java 87336 2009-04-15 11:31:26Z thomas.diesler at jboss.com $
 
-import static org.junit.Assert.assertEquals;
-
 import org.jboss.osgi.spi.capability.CompendiumCapability;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
@@ -51,7 +49,7 @@
          OSGiBundle bundle = runtime.installBundle("service/startlevel.jar");
          bundle.start();
          
-         assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+         assertBundleState(Bundle.ACTIVE, bundle.getState());
          
          bundle.uninstall();
       }



More information about the jboss-osgi-commits mailing list