[jboss-osgi-commits] JBoss-OSGI SVN: r97469 - in projects/jboss-osgi/trunk/testsuite/functional: src/test/java/org/jboss/test/osgi/jbosgi214 and 2 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Fri Dec 4 11:39:12 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-12-04 11:39:11 -0500 (Fri, 04 Dec 2009)
New Revision: 97469

Added:
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/SomeService.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeServiceImpl.java
Removed:
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeService.java
Modified:
   projects/jboss-osgi/trunk/testsuite/functional/pom.xml
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/OSGI214TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/OSGI214Activator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi214/jbosgi214-bundle.bnd
Log:
[JBOSGI-214] Cannot repeatedly register service bound to an interface from the system classpath
Simplify test case

Modified: projects/jboss-osgi/trunk/testsuite/functional/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/pom.xml	2009-12-04 16:22:13 UTC (rev 97468)
+++ projects/jboss-osgi/trunk/testsuite/functional/pom.xml	2009-12-04 16:39:11 UTC (rev 97469)
@@ -255,6 +255,8 @@
                 <exclude>org/jboss/test/osgi/jbosgi108/**</exclude>
                 <!-- [JBOSGI-207] Implement persistent file storage -->
                 <exclude>org/jboss/test/osgi/jbosgi41/**</exclude>
+                <!-- [JBOSGI-214] Cannot repeatedly register service bound to an interface from the system classpath -->
+                <exclude>org/jboss/test/osgi/jbosgi214/**</exclude>
               </excludes>
             </configuration>
           </plugin>
@@ -306,6 +308,8 @@
                 <exclude>org/jboss/test/osgi/jbosgi108/**</exclude>
                 <!-- [JBOSGI-207] Implement persistent file storage -->
                 <exclude>org/jboss/test/osgi/jbosgi41/**</exclude>
+                <!-- [JBOSGI-214] Cannot repeatedly register service bound to an interface from the system classpath -->
+                <exclude>org/jboss/test/osgi/jbosgi214/**</exclude>
               </excludes>
             </configuration>
           </plugin>

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/OSGI214TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/OSGI214TestCase.java	2009-12-04 16:22:13 UTC (rev 97468)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/OSGI214TestCase.java	2009-12-04 16:39:11 UTC (rev 97469)
@@ -21,20 +21,23 @@
  */
 package org.jboss.test.osgi.jbosgi214;
 
-//$Id:$
+//$Id$
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
 
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ServiceLoader;
 import org.jboss.osgi.testing.OSGiTest;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
@@ -50,49 +53,30 @@
    @Test
    public void testFirstRun() throws Exception
    {
-      // Bootstrap and start the framework
-      OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
-      Framework framework = bootProvider.getFramework();
-      framework.start();
-      
-      // Start the ServiceTracker
-      BundleContext context = framework.getBundleContext();
-      new SystemServiceTracker(context).open();
-      
-      try
-      {
-         // Install and start the test bundle
-         URL bundleURL = getTestArchiveURL("jbosgi214-bundle.jar");
-         Bundle bundle = context.installBundle(bundleURL.toExternalForm());
-         bundle.start();
-         
-         // Verify that the service is there and can be cast to an interface from the system classpath
-         ServiceReference sref = context.getServiceReference(OSGiBootstrapProvider.class.getName());
-         OSGiBootstrapProvider service = (OSGiBootstrapProvider)context.getService(sref);
-         assertNotNull("Service not null", service);
-
-         // Uninstall the test bundle
-         bundle.uninstall();
-      }
-      finally
-      {
-         // Stop the framework
-         framework.stop();
-         framework.waitForStop(5000);
-      }
+      runSystemServiceTest();
    }
-   
+
    @Test
    public void testSecondRun() throws Exception
    {
+      runSystemServiceTest();
+   }
+   
+   private void runSystemServiceTest() throws BundleException, InterruptedException
+   {
+      // Setup some package on the system classpath
+      Map<String, String> props = new HashMap<String, String>();
+      props.put("org.osgi.framework.system.packages.extra", SomeService.class.getPackage().getName());
+      props.put("felix.bootdelegation.implicit", "false");
+      
       // Bootstrap and start the framework
-      OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
-      Framework framework = bootProvider.getFramework();
+      FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+      Framework framework = factory.newFramework(props);
       framework.start();
       
       // Start the ServiceTracker
       BundleContext context = framework.getBundleContext();
-      new SystemServiceTracker(context).open();
+      new SomeServiceTracker(context).open();
       
       try
       {
@@ -102,8 +86,8 @@
          bundle.start();
          
          // Verify that the service is there and can be cast to an interface from the system classpath
-         ServiceReference sref = context.getServiceReference(OSGiBootstrapProvider.class.getName());
-         OSGiBootstrapProvider service = (OSGiBootstrapProvider)context.getService(sref);
+         ServiceReference sref = context.getServiceReference(SomeService.class.getName());
+         SomeService service = (SomeService)context.getService(sref);
          assertNotNull("Service not null", service);
 
          // Uninstall the test bundle
@@ -117,11 +101,11 @@
       }
    }
    
-   class SystemServiceTracker extends ServiceTracker
+   class SomeServiceTracker extends ServiceTracker
    {
-      public SystemServiceTracker(BundleContext context)
+      public SomeServiceTracker(BundleContext context)
       {
-         super(context, OSGiBootstrapProvider.class.getName(), null);
+         super(context, SomeService.class.getName(), null);
       }
 
       @Override
@@ -129,7 +113,7 @@
       {
          Object serviceObj = super.addingService(sref);
          //System.out.println("addingService: " + serviceObj);
-         return (OSGiBootstrapProvider)serviceObj;
+         return (SomeService)serviceObj;
       }
 
       @Override

Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/SomeService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/SomeService.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/SomeService.java	2009-12-04 16:39:11 UTC (rev 97469)
@@ -0,0 +1,35 @@
+/*
+ * 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.jbosgi214;
+
+//$Id: SomeService.java 97340 2009-12-03 12:57:01Z thomas.diesler at jboss.com $
+
+
+/**
+ * A service interface on the system classpath
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public interface SomeService
+{
+}

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/OSGI214Activator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/OSGI214Activator.java	2009-12-04 16:22:13 UTC (rev 97468)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/OSGI214Activator.java	2009-12-04 16:39:11 UTC (rev 97469)
@@ -23,7 +23,7 @@
 
 //$Id$
 
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.test.osgi.jbosgi214.SomeService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -38,7 +38,7 @@
    public void start(BundleContext context)
    {
       // Register a service that is bound to an interface from the system classpath
-      context.registerService(OSGiBootstrapProvider.class.getName(), new SomeService(), null);
+      context.registerService(SomeService.class.getName(), new SomeServiceImpl(), null);
    }
 
    public void stop(BundleContext context)

Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeService.java	2009-12-04 16:22:13 UTC (rev 97468)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeService.java	2009-12-04 16:39:11 UTC (rev 97469)
@@ -1,60 +0,0 @@
-/*
- * 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.jbosgi214.bundle;
-
-//$Id$
-
-import java.io.InputStream;
-import java.net.URL;
-
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.osgi.framework.launch.Framework;
-
-/**
- * A service that implements an interface from the system classpath
- * 
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class SomeService implements OSGiBootstrapProvider
-{
-   public void configure()
-   {
-   }
-
-   public void configure(URL urlConfig)
-   {
-   }
-
-   public void configure(String resourceConfig)
-   {
-   }
-
-   public void configure(InputStream streamConfig)
-   {
-   }
-
-   public Framework getFramework()
-   {
-      return null;
-   }
-}

Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeServiceImpl.java (from rev 97467, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeService.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeServiceImpl.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi214/bundle/SomeServiceImpl.java	2009-12-04 16:39:11 UTC (rev 97469)
@@ -0,0 +1,36 @@
+/*
+ * 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.jbosgi214.bundle;
+
+//$Id$
+
+import org.jboss.test.osgi.jbosgi214.SomeService;
+
+/**
+ * A service that implements an interface from the system classpath
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class SomeServiceImpl implements SomeService
+{
+}

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi214/jbosgi214-bundle.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi214/jbosgi214-bundle.bnd	2009-12-04 16:22:13 UTC (rev 97468)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi214/jbosgi214-bundle.bnd	2009-12-04 16:39:11 UTC (rev 97469)
@@ -3,4 +3,4 @@
 Bundle-SymbolicName: jbosgi214-bundle
 Bundle-Activator: org.jboss.test.osgi.jbosgi214.bundle.OSGI214Activator
 Export-Package: org.jboss.test.osgi.jbosgi214.bundle
-Import-Package: org.jboss.osgi.spi.framework, org.osgi.framework, org.osgi.framework.launch
+Import-Package: org.jboss.test.osgi.jbosgi214, org.osgi.framework



More information about the jboss-osgi-commits mailing list