[jboss-cvs] JBossAS SVN: r90187 - in projects/jboss-osgi/trunk: blueprint/testsuite and 21 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 15 07:28:40 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-06-15 07:28:40 -0400 (Mon, 15 Jun 2009)
New Revision: 90187

Added:
   projects/jboss-osgi/trunk/husky/testsuite/${basedir}/
   projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/
   projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/
   projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/
   projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id
   projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
Modified:
   projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml
   projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
   projects/jboss-osgi/trunk/husky/harness/.project
   projects/jboss-osgi/trunk/husky/harness/pom.xml
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java
   projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java
   projects/jboss-osgi/trunk/husky/pom.xml
   projects/jboss-osgi/trunk/husky/testsuite/pom.xml
   projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml
   projects/jboss-osgi/trunk/pom.xml
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
   projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
   projects/jboss-osgi/trunk/testsuite/pom.xml
   projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
Log:
[JBOSGI-102] Add support for static Husky context injection

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -69,7 +69,7 @@
     </dependency>
     <dependency>
       <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-husky</artifactId>
+      <artifactId>jboss-osgi-husky-harness</artifactId>
       <scope>provided</scope>
     </dependency>
     <dependency>

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -19,7 +19,7 @@
         <include>*:jboss-osgi-blueprint:jar</include>
         <include>*:jboss-osgi-common:jar</include>
         <include>*:jboss-osgi-common-core:jar</include>
-        <include>*:jboss-osgi-husky:jar</include>
+        <include>*:jboss-osgi-husky-harness:jar</include>
         <include>*:jboss-osgi-jaxb:jar</include>
         <include>*:jboss-osgi-jmx:jar</include>
         <include>*:jboss-osgi-microcontainer:jar</include>

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -25,6 +25,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeNotNull;
 
 import org.jboss.osgi.husky.BridgeFactory;
 import org.jboss.osgi.husky.annotation.ProvideContext;
@@ -33,9 +34,9 @@
 import org.jboss.osgi.spi.capability.MicrocontainerCapability;
 import org.jboss.osgi.spi.testing.OSGiBundle;
 import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTest;
-import org.junit.After;
-import org.junit.Before;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -48,22 +49,20 @@
  * @author thomas.diesler at jboss.com
  * @since 13-May-2009
  */
-public class BlueprintContextTestCase extends OSGiTest
+public class BlueprintContextTestCase
 {
    @ProvideContext
-   public BundleContext context;
+   public static BundleContext context;
 
-   private OSGiRuntime runtime;
-   private OSGiBundle bundle;
+   private static OSGiRuntime runtime;
+   private static OSGiBundle bundle;
 
-   @Before
-   public void setUp() throws Exception
+   @BeforeClass
+   public static void beforeClass() throws Exception
    {
-      super.setUp();
-      
       if (context == null)
       {
-         runtime = getDefaultRuntime();
+         runtime = new OSGiTestHelper().getDefaultRuntime();
          runtime.addCapability(new HuskyCapability());
          runtime.addCapability(new MicrocontainerCapability());
          runtime.addCapability(new BlueprintCapability());
@@ -73,8 +72,8 @@
       }
    }
 
-   @After
-   public void tearDown() throws Exception
+   @AfterClass
+   public static void afterClass() throws Exception
    {
       if (context == null)
       {
@@ -83,19 +82,16 @@
          
          runtime.shutdown();
       }
-      
-      super.tearDown();
    }
 
    @Test
    public void testBlueprintContext() throws Exception
    {
       if (context == null)
-      {
          BridgeFactory.getBridge().run();
-         return;
-      }
       
+      assumeNotNull(context);
+      
       Bundle bundle = context.getBundle();
       assertEquals("context-basic", bundle.getSymbolicName());
       

Modified: projects/jboss-osgi/trunk/husky/harness/.project
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/.project	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/.project	2009-06-15 11:28:40 UTC (rev 90187)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>jboss-osgi-husky</name>
+	<name>jboss-osgi-husky-harness</name>
 	<comment></comment>
 	<projects>
 	</projects>

Modified: projects/jboss-osgi/trunk/husky/harness/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/pom.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/pom.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,13 +18,13 @@
   <name>JBossOSGi Husky - Harness</name>
 
   <groupId>org.jboss.osgi</groupId>
-  <artifactId>jboss-osgi-husky</artifactId>
+  <artifactId>jboss-osgi-husky-harness</artifactId>
   <packaging>bundle</packaging>
 
   <!-- Parent -->
   <parent>
     <groupId>org.jboss.osgi</groupId>
-    <artifactId>jboss-osgi-husky-parent</artifactId>
+    <artifactId>jboss-osgi-husky</artifactId>
     <version>1.0.0.Beta3</version>
   </parent>
 

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -70,18 +70,21 @@
       for (Failure failure : failures)
       {
          String failedClass = failure.getClassName();
-         String failedMethod = failure.getMethodName();
-         if (failedClass.equals(testClass.getName()) && failedMethod.equals(testMethod))
+         if (failedClass.equals(testClass.getName()))
          {
-            Throwable failureCause = failure.getException();
-            if (failureCause instanceof RuntimeException)
-               throw (RuntimeException)failureCause;
-            if (failureCause instanceof Error)
-               throw (Error)failureCause;
+            String failedMethod = failure.getMethodName();
+            if (failedMethod == null || failedMethod.equals(testMethod))
+            {
+               Throwable failureCause = failure.getException();
+               if (failureCause instanceof RuntimeException)
+                  throw (RuntimeException)failureCause;
+               if (failureCause instanceof Error)
+                  throw (Error)failureCause;
 
-            AssertionFailedError error = new AssertionFailedError(failure.getMessage());
-            error.initCause(failureCause);
-            throw error;
+               AssertionFailedError error = new AssertionFailedError(failure.getMessage());
+               error.initCause(failureCause);
+               throw error;
+            }
          }
       }
    }

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -59,7 +59,7 @@
 
          InputStream reqBytes = new ByteArrayInputStream(baos.toByteArray());
 
-         ObjectName objectName = JMXConnector.getObjectName();
+         ObjectName objectName = JMXConnector.OBJECT_NAME;
          InputStream resBytes = (InputStream)server.invoke(objectName, "process", new Object[] { reqBytes }, new String[] { InputStream.class.getName() });
 
          // Unmarshall the Response

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -57,7 +57,7 @@
          {
             return new SocketInvocation().invoke(req);
          }
-         else if (server.isRegistered(JMXConnector.getObjectName()))
+         else if (server.isRegistered(JMXConnector.OBJECT_NAME))
          {
             return new JMXInvocation().invoke(server, req);
          }

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -55,7 +55,7 @@
    Response runTests(Context context, Class<?> testClass);
    
    /**
-    * Inject the {@link Context} inte the test case instance
+    * Inject the {@link Context} in the test case instance
     */
-   void injectContext(Object test, Context context) throws Exception;
+   void injectContext(Class<?> testClass, Object test, Context context) throws Exception;
 }

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -24,7 +24,9 @@
 // $Id$
 
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import org.jboss.osgi.husky.Context;
 import org.jboss.osgi.husky.Response;
@@ -50,6 +52,20 @@
     */
    public Response runTests(final Context context, final Class<?> testClass)
    {
+      // Inject the context in potentially static fields
+      try
+      {
+         injectContext(testClass, null, context);
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         throw new IllegalStateException("Cannot initialize test case: " + testClass.getName(), ex);
+      }
+      
       BlockJUnit4ClassRunner runner;
       try
       {
@@ -58,15 +74,15 @@
             @Override
             protected Object createTest() throws Exception
             {
-               Object test = super.createTest();
-               injectContext(test, context);
-               return test;
+               Object target = super.createTest();
+               injectContext(testClass, target, context);
+               return target;
             }
          };
       }
       catch (InitializationError ex)
       {
-         throw new IllegalStateException("Cannot initialize test case: " + testClass.getName());
+         throw new IllegalStateException("Cannot initialize test case: " + testClass.getName(), ex);
       }
 
       Result result = new Result();
@@ -88,15 +104,15 @@
       return response;
    }
 
-   public void injectContext(Object test, Context context) throws Exception
+   public void injectContext(Class<?> testClass, Object target, Context context) throws Exception
    {
-      Class<? extends Object> testClass = test.getClass();
-      for (Field field : testClass.getFields())
+      for (Field field : testClass.getDeclaredFields())
       {
          ProvideContext anProvide = field.getAnnotation(ProvideContext.class);
          if (anProvide != null)
          {
-            field.set(test, context);
+            if ((field.getModifiers() & Modifier.STATIC) != 0 || target != null)
+               injectField(field, target, context);
          }
       }
       for (Method method : testClass.getDeclaredMethods())
@@ -104,8 +120,19 @@
          ProvideContext anProvide = method.getAnnotation(ProvideContext.class);
          if (anProvide != null)
          {
-            method.invoke(test, context);
+            if ((method.getModifiers() & Modifier.STATIC) != 0 || target != null)
+               injectMethod(method, target, context);
          }
       }
    }
+
+   protected void injectMethod(Method method, Object target, Context value) throws IllegalAccessException, InvocationTargetException
+   {
+      method.invoke(target, value);
+   }
+
+   protected void injectField(Field field, Object target, Context value) throws IllegalAccessException
+   {
+      field.set(target, value);
+   }
 }

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -34,7 +34,6 @@
 import org.jboss.osgi.husky.runtime.Connector;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;
 
 /**
@@ -46,10 +45,26 @@
  */
 public class JMXConnector extends AbstractConnector implements JMXConnectorMBean
 {
+   /*
+    * The ObjectName for this service: jboss.osgi.husky:service=jmx-connector
+    */
+   public static ObjectName OBJECT_NAME;
+
    private LogService log;
    private BundleContext context;
-   private ServiceRegistration sreg;
-   
+
+   static
+   {
+      try
+      {
+         OBJECT_NAME = ObjectName.getInstance("jboss.osgi.husky:service=jmx-connector");
+      }
+      catch (MalformedObjectNameException ex)
+      {
+         // ignore
+      }
+   }
+
    public JMXConnector(BundleContext context)
    {
       this.log = new LogServiceTracker(context);
@@ -61,40 +76,24 @@
       ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
       if (sref == null)
          throw new IllegalStateException("Cannot obtain MBeanServer service");
-      
+
       Properties props = new Properties();
       props.setProperty("transport", "jmx");
-      sreg = context.registerService(Connector.class.getName(), this, props);
-      
+      context.registerService(Connector.class.getName(), this, props);
+
       MBeanServer server = (MBeanServer)context.getService(sref);
-      server.registerMBean(this, getObjectName());
-      log.log(LogService.LOG_INFO, "JMXConnector registered: " + getObjectName());
+      server.registerMBean(this, OBJECT_NAME);
+      log.log(LogService.LOG_INFO, "JMXConnector registered: " + OBJECT_NAME);
    }
 
    public void stop() throws Exception
    {
-      if (sreg != null)
-         sreg.unregister();
-      
       ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
       if (sref != null)
       {
          MBeanServer server = (MBeanServer)context.getService(sref);
-         if (server.isRegistered(getObjectName()));
-            server.unregisterMBean(getObjectName());
+         if (server.isRegistered(OBJECT_NAME))
+            server.unregisterMBean(OBJECT_NAME);
       }
    }
-
-   public static ObjectName getObjectName()
-   {
-      try
-      {
-         return ObjectName.getInstance("jboss.osgi.husky:service=jmx-connector");
-      }
-      catch (MalformedObjectNameException ex)
-      {
-         // should never get here
-         return null;
-      }
-   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -25,8 +25,6 @@
 
 import java.io.InputStream;
 
-import org.jboss.osgi.husky.Request;
-import org.jboss.osgi.husky.Response;
 import org.jboss.osgi.husky.runtime.PackageListener;
 
 /**
@@ -37,16 +35,14 @@
  */
 public interface JMXConnectorMBean
 {
-   /**
-    * Consumes the serialized version of an {@link Request} and
-    * return the the {@link Response} from the test run
-    *
+   /*
+    * Consumes the serialized version of an {@link Request} and return the the {@link Response} from the test run
     * @param reqStream the input stream to read the {@link Request} from
     * @return the input stream to read the {@link Response} from
     */
    InputStream process(InputStream reqStream);
-   
-   /**
+
+   /*
     * Add a {@link PackageListener} to this connector
     */
    void addPackageListener(PackageListener listener);

Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -24,56 +24,46 @@
 // $Id$
 
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
 import org.jboss.osgi.husky.Context;
-import org.jboss.osgi.husky.annotation.ProvideContext;
-import org.jboss.osgi.husky.runtime.Runner;
 import org.jboss.osgi.husky.runtime.junit.JUnitRunner;
 import org.osgi.framework.BundleContext;
 
 /**
- * An implementation of a {@link Runner} that uses the JUnit4 Test Runner.
+ * An extension to the {@link JUnitRunner} that injects the OSGi BundleContext.
  * 
  * @author Thomas.Diesler at jboss.com
  * @since 16-May-2009
  */
 public class OSGiJUnitRunner extends JUnitRunner
 {
-   public void injectContext(Object test, Context context) throws Exception
+   @Override
+   protected void injectField(Field field, Object target, Context context) throws IllegalAccessException
    {
       BundleContext bundleContext = context.getAttachment(BundleContext.class);
-      Class<? extends Object> testClass = test.getClass();
-      
-      for (Field field : testClass.getFields())
+      if (field.getType().isAssignableFrom(BundleContext.class))
       {
-         ProvideContext anProvide = field.getAnnotation(ProvideContext.class);
-         if (anProvide != null)
-         {
-            if (field.getType().isAssignableFrom(BundleContext.class))
-            {
-               field.set(test, bundleContext);
-            }
-            else
-            {
-               field.set(test, context);
-            }
-         }
+         field.set(target, bundleContext);
       }
-      for (Method method : testClass.getDeclaredMethods())
+      else
       {
-         ProvideContext anProvide = method.getAnnotation(ProvideContext.class);
-         if (anProvide != null)
-         {
-            if (method.getParameterTypes()[0].isAssignableFrom(BundleContext.class))
-            {
-               method.invoke(test, bundleContext);
-            }
-            else
-            {
-               method.invoke(test, context);
-            }
-         }
+         field.set(target, context);
       }
    }
+
+   @Override
+   protected void injectMethod(Method method, Object target, Context context) throws IllegalAccessException, InvocationTargetException
+   {
+      BundleContext bundleContext = context.getAttachment(BundleContext.class);
+      if (method.getParameterTypes()[0].isAssignableFrom(BundleContext.class))
+      {
+         method.invoke(target, bundleContext);
+      }
+      else
+      {
+         method.invoke(target, context);
+      }
+   }
 }

Modified: projects/jboss-osgi/trunk/husky/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/pom.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/pom.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -19,7 +19,7 @@
   <description>JBoss OSGi Test Support</description>
 
   <groupId>org.jboss.osgi</groupId>
-  <artifactId>jboss-osgi-husky-parent</artifactId>
+  <artifactId>jboss-osgi-husky</artifactId>
   <packaging>pom</packaging>
 
   <parent>

Added: projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id	                        (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id	2009-06-15 11:28:40 UTC (rev 90187)
@@ -0,0 +1 @@
+2
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/husky/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/pom.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/testsuite/pom.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -24,7 +24,7 @@
   <!-- Parent -->
   <parent>
     <groupId>org.jboss.osgi</groupId>
-    <artifactId>jboss-osgi-husky-parent</artifactId>
+    <artifactId>jboss-osgi-husky</artifactId>
     <version>1.0.0.Beta3</version>
   </parent>
 
@@ -32,8 +32,11 @@
   <dependencies>
     <dependency>
       <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-husky</artifactId>
-      <version>${version}</version>
+      <artifactId>jboss-osgi-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-husky-harness</artifactId>
       <scope>provided</scope>
     </dependency>
     

Modified: projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -17,7 +17,7 @@
       <includes>
         <include>*:jboss-osgi-common:jar</include>
         <include>*:jboss-osgi-jmx:jar</include>
-        <include>*:jboss-osgi-husky:jar</include>
+        <include>*:jboss-osgi-husky-harness:jar</include>
         <include>*:org.apache.felix.log:jar</include>
         <include>*:org.osgi.compendium:jar</include>
       </includes>

Added: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.husky.context;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeNotNull;
+
+import org.jboss.osgi.husky.BridgeFactory;
+import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.spi.capability.HuskyCapability;
+import org.jboss.osgi.spi.capability.JMXCapability;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * Test BundleContext injection
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 13-May-2009
+ */
+public class StaticContextTestCase
+{
+   @ProvideContext
+   public static BundleContext context;
+
+   private static OSGiRuntime runtime;
+   private static OSGiBundle bundle;
+
+   @BeforeClass
+   public static void beforeClass() throws BundleException
+   {
+      if (context == null)
+      {
+         runtime = new OSGiTestHelper().getDefaultRuntime();
+         runtime.addCapability(new JMXCapability());
+         runtime.addCapability(new HuskyCapability());
+         
+         bundle = runtime.installBundle("context-basic.jar");
+         bundle.start();
+      }
+   }
+
+   @AfterClass
+   public static void afterDown() throws BundleException
+   {
+      if (context == null)
+      {
+         if (bundle != null)
+            bundle.uninstall();
+         
+         runtime.shutdown();
+      }
+   }
+
+   @Test
+   public void testBundleContext() throws Exception
+   {
+      if (context == null)
+         BridgeFactory.getBridge().run();
+      
+      assumeNotNull(context);
+      
+      Bundle bundle = context.getBundle();
+      assertEquals("context-basic", bundle.getSymbolicName());
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/pom.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -46,7 +46,6 @@
     <version.jboss.osgi.common.core>2.2.11</version.jboss.osgi.common.core>
     <version.jboss.osgi.deployers>1.0.0.Beta2</version.jboss.osgi.deployers>
     <version.jboss.osgi.hotdeploy>1.0.0.Beta2</version.jboss.osgi.hotdeploy>
-    <version.jboss.osgi.husky>1.0.0.Beta2</version.jboss.osgi.husky>
     <version.jboss.osgi.integration.jbossas>1.0.0.Beta2</version.jboss.osgi.integration.jbossas>
     <version.jboss.osgi.jaxb>2.1.10</version.jboss.osgi.jaxb>
     <version.jboss.osgi.jmx>1.0.0.Beta2</version.jboss.osgi.jmx>
@@ -163,8 +162,8 @@
       </dependency>
       <dependency>
         <groupId>org.jboss.osgi</groupId>
-        <artifactId>jboss-osgi-husky</artifactId>
-        <version>${version.jboss.osgi.husky}</version>
+        <artifactId>jboss-osgi-husky-harness</artifactId>
+        <version>${version}</version>
       </dependency>
       <dependency>
         <groupId>org.jboss.osgi</groupId>
@@ -182,6 +181,11 @@
         <version>${version.jboss.osgi.runtime.knopflerfish}</version>
       </dependency>
       <dependency>
+        <groupId>org.jboss.osgi</groupId>
+        <artifactId>jboss-osgi-spi</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.jboss.osgi.bundles</groupId>
         <artifactId>jboss-osgi-apache-xerces</artifactId>
         <version>${version.jboss.osgi.apache.xerces}</version>

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -47,6 +47,6 @@
       super("org.jboss.osgi.husky.runtime.Connector");
       
       addDependency(new JMXCapability());
-      addBundle("bundles/jboss-osgi-husky.jar");
+      addBundle("bundles/jboss-osgi-husky-harness.jar");
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-06-15 11:28:40 UTC (rev 90187)
@@ -175,9 +175,12 @@
 
       stopLogEntryTracking();
 
-      while (capabilities.size() > 0)
+      List<Capability> reverse = new ArrayList<Capability>(capabilities);
+      Collections.reverse(reverse);
+      
+      while (reverse.size() > 0)
       {
-         Capability capability = capabilities.get(0);
+         Capability capability = reverse.remove(0);
          removeCapability(capability);
       }
 

Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,7 +18,7 @@
         <include>*:jboss-osgi-apache-xerces:jar</include>
         <include>*:jboss-osgi-common:jar</include>
         <include>*:jboss-osgi-common-core:jar</include>
-        <include>*:jboss-osgi-husky:jar</include>
+        <include>*:jboss-osgi-husky-harness:jar</include>
         <include>*:jboss-osgi-jaxb:jar</include>
         <include>*:jboss-osgi-jmx:jar</include>
         <include>*:jboss-osgi-jndi:jar</include>

Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,7 +18,7 @@
         <include>*:jboss-osgi-apache-xerces:jar</include>
         <include>*:jboss-osgi-common:jar</include>
         <include>*:jboss-osgi-common-core:jar</include>
-        <include>*:jboss-osgi-husky:jar</include>
+        <include>*:jboss-osgi-husky-harness:jar</include>
         <include>*:jboss-osgi-jaxb:jar</include>
         <include>*:jboss-osgi-jmx:jar</include>
         <include>*:jboss-osgi-jndi:jar</include>

Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -29,7 +29,6 @@
     <dependency>
       <groupId>org.jboss.osgi</groupId>
       <artifactId>jboss-osgi-spi</artifactId>
-      <version>${version}</version>
     </dependency>
 
     <dependency>
@@ -79,7 +78,7 @@
     </dependency>
     <dependency>
       <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-husky</artifactId>
+      <artifactId>jboss-osgi-husky-harness</artifactId>
       <scope>provided</scope>
     </dependency>
     <dependency>

Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml	2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml	2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,7 +18,7 @@
         <include>*:jboss-osgi-apache-xerces:jar</include>
         <include>*:jboss-osgi-common:jar</include>
         <include>*:jboss-osgi-common-core:jar</include>
-        <include>*:jboss-osgi-husky:jar</include>
+        <include>*:jboss-osgi-husky-harness:jar</include>
         <include>*:jboss-osgi-jaxb:jar</include>
         <include>*:jboss-osgi-jmx:jar</include>
         <include>*:jboss-osgi-jndi:jar</include>




More information about the jboss-cvs-commits mailing list