[jboss-svn-commits] JBoss Common SVN: r4546 - in arquillian/trunk: containers/openejb and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 24 04:46:53 EDT 2010


Author: thomas.diesler at jboss.com
Date: 2010-06-24 04:46:51 -0400 (Thu, 24 Jun 2010)
New Revision: 4546

Added:
   arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkContainer.java
   arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkTestCase.java
   arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleActivator.java
   arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleService.java
Removed:
   arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedContainer.java
   arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedIntegrationTestCase.java
   arquillian/trunk/examples/junit/src/test/java/com/acme/osgi/SimpleBundleTestCase.java
Modified:
   arquillian/trunk/build/pom.xml
   arquillian/trunk/containers/openejb/pom.xml
   arquillian/trunk/containers/osgi-embedded/pom.xml
   arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedConfiguration.java
   arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiTestEnricher.java
   arquillian/trunk/containers/osgi-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
Log:
osgi: Add test stub for service access

Modified: arquillian/trunk/build/pom.xml
===================================================================
--- arquillian/trunk/build/pom.xml	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/build/pom.xml	2010-06-24 08:46:51 UTC (rev 4546)
@@ -25,6 +25,7 @@
   <properties>
 
     <!-- Versioning -->
+    <version.javax.inject_javax.inject>1</version.javax.inject_javax.inject>
     <version.javaee_api>6.0</version.javaee_api>
     <version.jboss_embedded>1.0.0-alpha-1</version.jboss_embedded>
     <version.jboss_osgi_spi>1.0.7-SNAPSHOT</version.jboss_osgi_spi>
@@ -186,6 +187,11 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>javax.inject</groupId>
+        <artifactId>javax.inject</artifactId>
+        <version>${version.javax.inject_javax.inject}</version>
+      </dependency>
+      <dependency>
         <groupId>org.jboss.osgi</groupId>
         <artifactId>jboss-osgi-spi</artifactId>
         <version>${version.jboss_osgi_spi}</version>

Modified: arquillian/trunk/containers/openejb/pom.xml
===================================================================
--- arquillian/trunk/containers/openejb/pom.xml	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/openejb/pom.xml	2010-06-24 08:46:51 UTC (rev 4546)
@@ -25,7 +25,6 @@
 
     <!-- Versioning -->
     <version.org.apache.openejb_openejb.core>3.1.2</version.org.apache.openejb_openejb.core>
-    <version.javax.inject_javax.inject>1</version.javax.inject_javax.inject>
 
   </properties>
 
@@ -81,7 +80,6 @@
    <dependency>
     <groupId>javax.inject</groupId>
     <artifactId>javax.inject</artifactId>
-    <version>${version.javax.inject_javax.inject}</version>
     <scope>provided</scope>
    </dependency>
 

Modified: arquillian/trunk/containers/osgi-embedded/pom.xml
===================================================================
--- arquillian/trunk/containers/osgi-embedded/pom.xml	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/osgi-embedded/pom.xml	2010-06-24 08:46:51 UTC (rev 4546)
@@ -53,8 +53,13 @@
       <groupId>org.jboss.osgi</groupId>
       <artifactId>jboss-osgi-spi</artifactId>
     </dependency>
-
+    
     <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+    </dependency>
+    
+    <dependency>
       <groupId>org.jboss.shrinkwrap</groupId>
       <artifactId>shrinkwrap-impl-base</artifactId>
       <scope>provided</scope>

Modified: arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedConfiguration.java
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedConfiguration.java	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedConfiguration.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -20,7 +20,7 @@
 import org.jboss.arquillian.spi.ContainerProfile;
 
 /**
- * [TODO] OSGiEmbeddedConfiguration
+ * OSGiEmbeddedConfiguration
  *
  * @author thomas.diesler at jboss.com
  * @version $Revision: $

Deleted: arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedContainer.java
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedContainer.java	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedContainer.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.osgi;
-
-import org.jboss.arquillian.packager.osgi.BundleArchive;
-import org.jboss.arquillian.protocol.local.LocalMethodExecutor;
-import org.jboss.arquillian.spi.Configuration;
-import org.jboss.arquillian.spi.ContainerMethodExecutor;
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.DeployableContainer;
-import org.jboss.arquillian.spi.DeploymentException;
-import org.jboss.arquillian.spi.LifecycleException;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.shrinkwrap.api.Archive;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-
-/**
- * [TODO] OSGiEmbeddedContainer
- *
- * @author thomas.diesler at jboss.com
- * @version $Revision: $
- */
-public class OSGiEmbeddedContainer implements DeployableContainer
-{
-   // Provide logging
-   private static final Logger log = Logger.getLogger(OSGiEmbeddedContainer.class);
-
-   private Framework framework;
-
-   @Override
-   public void setup(Context context, Configuration configuration)
-   {
-      OSGiBootstrapProvider provider = OSGiBootstrap.getBootstrapProvider();
-      framework = provider.getFramework();
-      context.add(Framework.class, framework);
-   }
-
-   @Override
-   public void start(Context context) throws LifecycleException
-   {
-      try
-      {
-         framework.start();
-      }
-      catch (BundleException ex)
-      {
-         throw new LifecycleException("Cannot start embedded OSGi Framework", ex);
-      }
-   }
-
-   @Override
-   public void stop(Context context) throws LifecycleException
-   {
-      try
-      {
-         framework.stop();
-         framework.waitForStop(3000);
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         throw new LifecycleException("Cannot stop embedded OSGi Framework", ex);
-      }
-   }
-
-   @Override
-   public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
-   {
-      try
-      {
-         if ((archive instanceof BundleArchive) == false)
-            throw new IllegalStateException("Archive is not a bundle archive: " + archive);
-         
-         BundleContext sysContext = framework.getBundleContext();
-         VirtualFile virtualFile = ((BundleArchive)archive).getBundleInfo().getRoot();
-         Bundle bundle = sysContext.installBundle(archive.getName(), virtualFile.openStream());
-         context.add(Bundle.class, bundle);
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         throw new DeploymentException("Cannot deploy: " + archive, ex);
-      }
-      return new LocalMethodExecutor();
-   }
-
-   @Override
-   public void undeploy(Context context, Archive<?> archive) throws DeploymentException
-   {
-      try
-      {
-         Bundle bundle = context.get(Bundle.class);
-         if (bundle != null)
-            bundle.uninstall();
-      }
-      catch (BundleException ex)
-      {
-         log.error("Cannot undeploy: " + archive, ex);
-      }
-   }
-}
\ No newline at end of file

Copied: arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkContainer.java (from rev 4545, arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedContainer.java)
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkContainer.java	                        (rev 0)
+++ arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkContainer.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.osgi;
+
+import org.jboss.arquillian.packager.osgi.BundleArchive;
+import org.jboss.arquillian.protocol.local.LocalMethodExecutor;
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.shrinkwrap.api.Archive;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * OSGiEmbeddedFrameworkContainer
+ *
+ * @author thomas.diesler at jboss.com
+ * @version $Revision: $
+ */
+public class OSGiEmbeddedFrameworkContainer implements DeployableContainer
+{
+   // Provide logging
+   private static final Logger log = Logger.getLogger(OSGiEmbeddedFrameworkContainer.class);
+
+   private Framework framework;
+
+   @Override
+   public void setup(Context context, Configuration configuration)
+   {
+      OSGiBootstrapProvider provider = OSGiBootstrap.getBootstrapProvider();
+      framework = provider.getFramework();
+      context.add(Framework.class, framework);
+   }
+
+   @Override
+   public void start(Context context) throws LifecycleException
+   {
+      try
+      {
+         framework.start();
+      }
+      catch (BundleException ex)
+      {
+         throw new LifecycleException("Cannot start embedded OSGi Framework", ex);
+      }
+   }
+
+   @Override
+   public void stop(Context context) throws LifecycleException
+   {
+      try
+      {
+         framework.stop();
+         framework.waitForStop(3000);
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         throw new LifecycleException("Cannot stop embedded OSGi Framework", ex);
+      }
+   }
+
+   @Override
+   public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
+   {
+      try
+      {
+         if ((archive instanceof BundleArchive) == false)
+            throw new IllegalStateException("Archive is not a bundle archive: " + archive);
+         
+         BundleContext sysContext = framework.getBundleContext();
+         VirtualFile virtualFile = ((BundleArchive)archive).getBundleInfo().getRoot();
+         Bundle bundle = sysContext.installBundle(archive.getName(), virtualFile.openStream());
+         context.add(Bundle.class, bundle);
+      }
+      catch (RuntimeException rte)
+      {
+         throw rte;
+      }
+      catch (Exception ex)
+      {
+         throw new DeploymentException("Cannot deploy: " + archive, ex);
+      }
+      return new LocalMethodExecutor();
+   }
+
+   @Override
+   public void undeploy(Context context, Archive<?> archive) throws DeploymentException
+   {
+      try
+      {
+         Bundle bundle = context.get(Bundle.class);
+         if (bundle != null)
+            bundle.uninstall();
+      }
+      catch (BundleException ex)
+      {
+         log.error("Cannot undeploy: " + archive, ex);
+      }
+   }
+}
\ No newline at end of file

Modified: arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiTestEnricher.java
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiTestEnricher.java	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiTestEnricher.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -27,8 +27,18 @@
 import org.osgi.framework.launch.Framework;
 
 /**
- * [TODO] OSGiTestEnricher
- *
+ * The OSGi TestEnricher
+ * 
+ * The enricher supports the injection of the Framework and the Bundle under test.
+ * 
+ * <pre><code>
+ *    @Inject
+ *    Framework framework;
+ * 
+ *    @Inject
+ *    Bundle bundle;
+ * </code></pre>
+ * 
  * @author thomas.diesler at jboss.com
  * @version $Revision: $
  */

Modified: arquillian/trunk/containers/osgi-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/osgi-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer	2010-06-24 08:46:51 UTC (rev 4546)
@@ -1 +1 @@
-org.jboss.arquillian.osgi.OSGiEmbeddedContainer
\ No newline at end of file
+org.jboss.arquillian.osgi.OSGiEmbeddedFrameworkContainer
\ No newline at end of file

Copied: arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkTestCase.java (from rev 4545, arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedIntegrationTestCase.java)
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkTestCase.java	                        (rev 0)
+++ arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedFrameworkTestCase.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.osgi.testing.OSGiManifestBuilder;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * Test the embedded OSGi framework
+ *
+ * @author thomas.diesler at jboss.com
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class OSGiEmbeddedFrameworkTestCase
+{
+   @Deployment
+   public static JavaArchive createdeployment()
+   {
+      final JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class);
+      archive.setManifest(new Asset()
+      {
+         public InputStream openStream()
+         {
+            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
+            builder.addBundleSymbolicName(archive.getName());
+            builder.addBundleManifestVersion(2);
+            builder.addBundleActivator(SimpleActivator.class.getName());
+            return builder.openStream();
+         }
+      });
+      archive.addClasses(SimpleActivator.class, SimpleService.class);
+      archive.addClasses(OSGiEmbeddedFrameworkTestCase.class);
+      return archive;
+   }
+
+   @Inject
+   Framework framework;
+   
+   @Test
+   public void testFrameworkInjection() throws Exception
+   {
+      assertNotNull("Framework injected", framework);
+   }
+
+   @Inject
+   Bundle bundle;
+   
+   @Test
+   public void testBundleInjection() throws Exception
+   {
+      // Assert that the bundle is injected and in state INSTALLED
+      assertNotNull("Bundle injected", bundle);
+      assertEquals("Bundle INSTALLED", Bundle.INSTALLED, bundle.getState());
+      
+      // Start the bundle
+      bundle.start();
+      assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+      
+      // Assert the bundle context
+      BundleContext context = bundle.getBundleContext();
+      assertNotNull("BundleContext available", context);
+      
+      // Get the service reference
+      ServiceReference sref = context.getServiceReference(SimpleService.class.getName());
+      assertNotNull("ServiceReference not null", sref);
+      
+      // Get the service for the reference
+      //SimpleService service = (SimpleService)context.getService(sref);
+      //assertNotNull("Service not null", service);
+      
+      // Invoke the service 
+      //int sum = service.sum(1, 2, 3);
+      //assertEquals(6, sum);
+      
+      // Stop the bundle
+      bundle.stop();
+      assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundle.getState());
+   }
+}

Deleted: arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedIntegrationTestCase.java
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedIntegrationTestCase.java	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/OSGiEmbeddedIntegrationTestCase.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.osgi;
-
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.InputStream;
-
-import javax.inject.Inject;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.osgi.testing.OSGiManifestBuilder;
-import org.jboss.shrinkwrap.api.Asset;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.launch.Framework;
-
-/**
- * WeldEmbeddedIntegrationTestCase
- *
- * @author Thomas.Diesler at jboss.com
- * @version $Revision: $
- */
- at RunWith(Arquillian.class)
-public class OSGiEmbeddedIntegrationTestCase
-{
-   @Deployment
-   public static JavaArchive createdeployment()
-   {
-      final JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class);
-      archive.setManifest(new Asset()
-      {
-         public InputStream openStream()
-         {
-            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
-            builder.addBundleSymbolicName(archive.getName());
-            builder.addBundleManifestVersion(2);
-            return builder.openStream();
-         }
-      });
-      return archive.addClasses(OSGiEmbeddedIntegrationTestCase.class);
-   }
-
-   @Inject
-   Framework framework;
-   
-   @Test
-   public void testFrameworkInjection() throws Exception
-   {
-      assertNotNull("Framework injected", framework);
-   }
-
-   @Inject
-   Bundle bundle;
-   
-   @Test
-   public void testbundleInjection() throws Exception
-   {
-      assertNotNull("Bundle injected", bundle);
-      assertEquals("Bundle INSTALLED", Bundle.INSTALLED, bundle.getState());
-      
-      bundle.start();
-      assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
-      
-      bundle.stop();
-      assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundle.getState());
-   }
-}

Copied: arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleActivator.java (from rev 4545, arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedConfiguration.java)
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleActivator.java	                        (rev 0)
+++ arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleActivator.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A BundleActivator that registers a {@ SimpleService}
+ *
+ * @author thomas.diesler at jboss.com
+ * @version $Revision: $
+ */
+public class SimpleActivator implements BundleActivator
+{
+   @Override
+   public void start(BundleContext context) throws Exception
+   {
+      SimpleService service = new SimpleService()
+      {
+         @Override
+         public Integer sum(Integer... values)
+         {
+            Integer result = 0;
+            if (values != null)
+            {
+               for (Integer i : values)
+               {
+                  result += i;
+               }
+            }
+            return result;
+         }
+      };
+      context.registerService(SimpleService.class.getName(), service, null);
+   }
+
+   @Override
+   public void stop(BundleContext context) throws Exception
+   {
+   }
+}

Copied: arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleService.java (from rev 4545, arquillian/trunk/containers/osgi-embedded/src/main/java/org/jboss/arquillian/osgi/OSGiEmbeddedConfiguration.java)
===================================================================
--- arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleService.java	                        (rev 0)
+++ arquillian/trunk/containers/osgi-embedded/src/test/java/org/jboss/arquillian/osgi/SimpleService.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.osgi;
+
+
+/**
+ * A simple service.
+ *
+ * @author thomas.diesler at jboss.com
+ * @version $Revision: $
+ */
+public interface SimpleService 
+{
+   Integer sum(Integer... values);
+}

Deleted: arquillian/trunk/examples/junit/src/test/java/com/acme/osgi/SimpleBundleTestCase.java
===================================================================
--- arquillian/trunk/examples/junit/src/test/java/com/acme/osgi/SimpleBundleTestCase.java	2010-06-24 08:45:22 UTC (rev 4545)
+++ arquillian/trunk/examples/junit/src/test/java/com/acme/osgi/SimpleBundleTestCase.java	2010-06-24 08:46:51 UTC (rev 4546)
@@ -1,37 +0,0 @@
-package com.acme.osgi;
-
-import java.io.InputStream;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.osgi.testing.OSGiManifestBuilder;
-import org.jboss.shrinkwrap.api.Asset;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
- at RunWith(org.jboss.arquillian.junit.Arquillian.class)
-public class SimpleBundleTestCase
-{
-   @Deployment
-   public static JavaArchive createTestArchive()
-   {
-      final JavaArchive archive = ShrinkWrap.create("example-bundle.jar", JavaArchive.class);
-      archive.setManifest(new Asset()
-      {
-         public InputStream openStream()
-         {
-            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
-            builder.addBundleSymbolicName(archive.getName());
-            builder.addBundleManifestVersion(2);
-            return builder.openStream();
-         }
-      });
-      return archive;
-   }
-
-   @Test
-   public void testBundleAccess()
-   {
-   }
-}



More information about the jboss-svn-commits mailing list