[jboss-osgi-commits] JBoss-OSGI SVN: r87339 - in projects/jboss-osgi/trunk: bundle/remotelog and 3 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed Apr 15 08:23:20 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-04-15 08:23:20 -0400 (Wed, 15 Apr 2009)
New Revision: 87339

Modified:
   projects/jboss-osgi/trunk/bundle/remotelog/pom.xml
   projects/jboss-osgi/trunk/pom.xml
   projects/jboss-osgi/trunk/runtime/spi/pom.xml
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTest.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java
   projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java
Log:
Push setup of remote logging to integration layer

Modified: projects/jboss-osgi/trunk/bundle/remotelog/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/remotelog/pom.xml	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/bundle/remotelog/pom.xml	2009-04-15 12:23:20 UTC (rev 87339)
@@ -25,11 +25,6 @@
   <!-- Dependencies -->
   <dependencies>
     <dependency>
-      <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-runtime-spi</artifactId>
-      <version>${version}</version>
-    </dependency>
-    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
       <scope>provided</scope>

Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/pom.xml	2009-04-15 12:23:20 UTC (rev 87339)
@@ -28,8 +28,8 @@
   <modules>
     <module>microcontainer</module>
     <module>repository</module>
+    <module>bundle</module>
     <module>runtime</module>
-    <module>bundle</module>
     <module>testsuite</module>
   </modules>
 

Modified: projects/jboss-osgi/trunk/runtime/spi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/pom.xml	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/runtime/spi/pom.xml	2009-04-15 12:23:20 UTC (rev 87339)
@@ -19,6 +19,18 @@
   <!-- Dependencies -->
   <dependencies>
     <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-common</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-remotelog</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
       <scope>provided</scope>

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTest.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTest.java	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTest.java	2009-04-15 12:23:20 UTC (rev 87339)
@@ -27,6 +27,7 @@
 
 import javax.management.MBeanServerConnection;
 
+import org.jboss.osgi.common.log.LogEntryCache;
 import org.jboss.osgi.spi.framework.RemoteBundle;
 import org.jboss.osgi.spi.framework.RemoteFramework;
 
@@ -49,6 +50,16 @@
       return delegate;
    }
 
+   protected void startRemoteLogging(LogEntryCache entryCache) throws Exception
+   {
+      getDelegate().startRemoteLogging(entryCache);
+   }
+   
+   protected void stopRemoteLogging() throws Exception
+   {
+      getDelegate().stopRemoteLogging();
+   }
+   
    protected boolean isRemoteIntegration()
    {
       return IntegrationTestHelper.isRemoteIntegration();

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/IntegrationTestHelper.java	2009-04-15 12:23:20 UTC (rev 87339)
@@ -36,7 +36,10 @@
 import javax.naming.NamingException;
 
 import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.osgi.common.log.LogEntryCache;
+import org.jboss.osgi.service.remotelog.RemoteLogReaderService;
 import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.framework.RemoteBundle;
 import org.jboss.osgi.spi.framework.RemoteFramework;
 import org.jboss.osgi.spi.framework.RemoteFrameworkException;
@@ -44,7 +47,11 @@
 import org.jboss.osgi.spi.management.MBeanProxyException;
 import org.jboss.osgi.spi.management.ManagedBundleMBean;
 import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogReaderService;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * An integration test helper that deals with test deployment/undeployment, etc.
@@ -55,15 +62,47 @@
 public class IntegrationTestHelper extends OSGiTestHelper
 {
    private static MBeanServerConnection server;
-   private OSGiBootstrapProvider bootProvider;
    private ManagedFrameworkMBean managedFramework;
    private String integrationTarget;
 
    public IntegrationTestHelper(OSGiBootstrapProvider bootProvider)
    {
-      this.bootProvider = bootProvider;
+      setBootstrapProvider(bootProvider);
    }
 
+   protected void startRemoteLogging(final LogEntryCache logEntryCache) throws Exception
+   {
+      // Bootstrap the Framework and get the system bundle
+      OSGiFramework framework = getBootstrapProvider().getFramework();
+      BundleContext sysContext = framework.getSystemBundleContext();
+      
+      // Track the RemoteLogReaderService to add the LogEntryCache as LogListener
+      ServiceTracker tracker = new ServiceTracker(sysContext, RemoteLogReaderService.class.getName(), null)
+      {
+         @Override
+         public Object addingService(ServiceReference sref)
+         {
+            LogReaderService service = (LogReaderService)super.addingService(sref);
+            service.addLogListener(logEntryCache);
+            return service;
+         }
+      };
+      tracker.open();
+
+      // Install the RemoteLogReaderService in the local OSGiFramework.
+      // The 'org.jboss.osgi.service.remote.log.reader' property must be set to 'true'
+      installBundle(sysContext, "bundles/jboss-osgi-remotelog.jar", true);
+
+      // Deploy the RemoteLogListener to the remote OSGiFramework.
+      // The 'org.jboss.osgi.service.remote.log.sender' property must be set to 'true'
+      deployBundle("bundles/jboss-osgi-remotelog.jar");
+   }
+   
+   protected void stopRemoteLogging() throws Exception
+   {
+      undeployBundle("bundles/jboss-osgi-remotelog.jar");
+   }
+   
    public void deploy(String archive) throws Exception
    {
       URL url = getTestArchiveFile(archive).toURI().toURL();
@@ -143,7 +182,7 @@
       }
       else
       {
-         DeployerClient deployer = (DeployerClient)bootProvider.getInstance("MainDeployer");
+         DeployerClient deployer = (DeployerClient)getBootstrapProvider().getInstance("MainDeployer");
          return new EmbeddedArchiveDeployer(deployer);
       }
    }

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java	2009-04-15 12:23:20 UTC (rev 87339)
@@ -25,16 +25,15 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
+import junit.framework.TestCase;
+
 import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
 import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.virtual.VFS;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 
-import junit.framework.TestCase;
-
 /**
  * An OSGi Test Case
  * 
@@ -47,7 +46,6 @@
    final Logger log = Logger.getLogger(OSGiTest.class);
 
    private OSGiTestHelper delegate = new OSGiTestHelper();
-   private OSGiBootstrapProvider bootProvider;
 
    public OSGiTest()
    {
@@ -57,21 +55,17 @@
 
    protected OSGiBootstrapProvider createBootstrapProvider()
    {
-      return OSGiBootstrap.getBootstrapProvider();
+      return delegate.createBootstrapProvider();
    }
 
    protected OSGiBootstrapProvider getBootstrapProvider()
    {
-      if (bootProvider == null)
-      {
-         bootProvider = createBootstrapProvider();
-      }
-      return bootProvider;
+      return delegate.getBootstrapProvider();
    }
 
    protected void setBootstrapProvider(OSGiBootstrapProvider bootProvider)
    {
-      this.bootProvider = bootProvider;
+      delegate.setBootstrapProvider(bootProvider);
    }
 
    @Override

Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java	2009-04-15 12:23:20 UTC (rev 87339)
@@ -25,6 +25,8 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -40,9 +42,30 @@
    private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
    private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
 
+   private OSGiBootstrapProvider bootProvider;
+   
    private static String testResourcesDir;
    private static String testArchiveDir;
 
+   public OSGiBootstrapProvider createBootstrapProvider()
+   {
+      return OSGiBootstrap.getBootstrapProvider();
+   }
+
+   public OSGiBootstrapProvider getBootstrapProvider()
+   {
+      if (bootProvider == null)
+      {
+         bootProvider = createBootstrapProvider();
+      }
+      return bootProvider;
+   }
+
+   public void setBootstrapProvider(OSGiBootstrapProvider bootProvider)
+   {
+      this.bootProvider = bootProvider;
+   }
+
    /** Try to discover the URL for the test resource */
    public URL getResourceURL(String resource)
    {

Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java	2009-04-15 12:16:16 UTC (rev 87338)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java	2009-04-15 12:23:20 UTC (rev 87339)
@@ -28,17 +28,11 @@
 import org.jboss.osgi.common.log.LogEntryCache;
 import org.jboss.osgi.common.log.LogEntryFilter;
 import org.jboss.osgi.service.remotelog.RemoteLogReaderService;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.framework.RemoteBundle;
 import org.jboss.osgi.spi.junit.IntegrationTest;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogReaderService;
 import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * This example demonstrates the usage of the {@link RemoteLogReaderService}
@@ -48,37 +42,26 @@
  */
 public class LogServiceRemoteTestCase extends IntegrationTest
 {
-   public void testServiceA() throws Exception
+   private LogEntryCache logEntryCache;
+   
+   @Override
+   protected void setUp() throws Exception
    {
-      // Bootstrap the Framework and get the system bundle
-      OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
-      BundleContext sysContext = framework.getSystemBundleContext();
+      super.setUp();
       
-      // Setup the LogEntryCache
-      final LogEntryCache logEntryCache = new LogEntryCache();
-      logEntryCache.addFilter(new LogEntryFilter("example-log(.*)", LogService.LOG_INFO, "\\[ServiceA\\](.*)"));
-      
-      // Track the RemoteLogReaderService to add the LogEntryCache as LogListener
-      ServiceTracker tracker = new ServiceTracker(sysContext, RemoteLogReaderService.class.getName(), null)
-      {
-         @Override
-         public Object addingService(ServiceReference sref)
-         {
-            LogReaderService service = (LogReaderService)super.addingService(sref);
-            service.addLogListener(logEntryCache);
-            return service;
-         }
-      };
-      tracker.open();
+      logEntryCache = new LogEntryCache(new LogEntryFilter("example-log(.*)", LogService.LOG_INFO, "\\[ServiceA\\](.*)"));
+      startRemoteLogging(logEntryCache);
+   }
 
-      // Install the RemoteLogReaderService in the local OSGiFramework.
-      // The 'org.jboss.osgi.service.remote.log.reader' property must be set to 'true'
-      installBundle(sysContext, "bundles/jboss-osgi-remotelog.jar", true);
-      
-      // Deploy the RemoteLogListener to the remote OSGiFramework.
-      // The 'org.jboss.osgi.service.remote.log.sender' property must be set to 'true'
-      deployBundle("bundles/jboss-osgi-remotelog.jar");
-      
+   @Override
+   protected void tearDown() throws Exception
+   {
+      stopRemoteLogging();
+      super.tearDown();
+   }
+
+   public void testServiceA() throws Exception
+   {
       // Deploy the test bundle
       RemoteBundle bundleA = deployBundle("example/example-log.jar");
       
@@ -88,9 +71,6 @@
       // Undeploy the test bundle
       undeployBundle("example/example-log.jar");
       
-      // Uneploy the RemoteLogListener from the remote OSGiFramework.
-      undeployBundle("bundles/jboss-osgi-remotelog.jar");
-      
       // Verify the received log entries
       List<LogEntry> entries = logEntryCache.getLog();
       assertEquals("Number of entries", 1, entries.size());




More information about the jboss-osgi-commits mailing list