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

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed Jun 3 09:10:12 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-06-03 09:10:12 -0400 (Wed, 03 Jun 2009)
New Revision: 89732

Modified:
   projects/jboss-osgi/trunk/docbook/en/modules/ch020-getting-started.xml
   projects/jboss-osgi/trunk/docbook/en/modules/ch070-provided-bundles.xml
   projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundleB/SomeBean.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
Log:
More userguide - WIP

Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch020-getting-started.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch020-getting-started.xml	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch020-getting-started.xml	2009-06-03 13:10:12 UTC (rev 89732)
@@ -161,48 +161,15 @@
     deployment is verified by an accompaning test case</para>
 
     <itemizedlist>
-      <listitem><emphasis role="bold">HTTP Service</emphasis> - Register servlets and resources with the HTTP Service</listitem>
-      <listitem><emphasis role="bold">Log Service</emphasis> - Interact with a local and remote Log Service</listitem>
-      <listitem><emphasis role="bold">JMX Service</emphasis> - Register an MBean through the JMX Service</listitem>
-      <listitem><emphasis role="bold">JNDI Service</emphasis> - Bind objects to the Naming Service</listitem>
-      <listitem><emphasis role="bold">Microcontainer Service</emphasis> - Call a service from an MC bean</listitem>
+      <listitem><emphasis role="bold">LogServiceTestCase</emphasis> - Interact with a local and remote Log Service</listitem>
+      <listitem><emphasis role="bold">HttpServiceTestCase</emphasis> - Register servlets and resources with the HTTP Service</listitem>
+      <listitem><emphasis role="bold">JMXTestCase</emphasis> - Register an MBean through the JMX Service</listitem>
+      <listitem><emphasis role="bold">JNDITestCase</emphasis> - Bind objects to the Naming Service</listitem>
+      <listitem><emphasis role="bold">MicrocontainerTestCase</emphasis> - Call a service from an MC bean and vica versa</listitem>
+      <listitem><emphasis role="bold">SimpleTestCase</emphasis> - A simple bundle lifecycle test</listitem>
+      <listitem><emphasis role="bold">SimpleHuskyTestCase</emphasis> - Accesses a service from within the test case</listitem>
     </itemizedlist>
     
-    <programlisting>
-    [tdiesler at tddell example]$ mvn test
-    [INFO] ------------------------------------------------------------------------
-    [INFO] Building JBoss OSGi - Testsuite Examples
-    [INFO]    task-segment: [test]
-    [INFO] ------------------------------------------------------------------------
-    ...
-    build-test-jars:
-    # example-http (example-http.jar) 4 
-    # example-jmx (example-jmx.jar) 4 
-    # example-jndi (example-jndi.jar) 1 
-    # example-log (example-log.jar) 2 
-    # example-mcservice-bundleA (example-mcservice-bundleA.jar) 2 
-    # example-mcservice-bundleB (example-mcservice-bundleB.jar) 3 
-    # example-simple (example-simple.jar) 2 
-    # example-simple-husky (example-simple-husky.jar) 4
-     
-    -------------------------------------------------------
-     T E S T S
-    -------------------------------------------------------
-    Running org.jboss.test.osgi.example.microcontainer.MicrocontainerTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.006 sec
-    Running org.jboss.test.osgi.example.http.HttpServiceTestCase
-    Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.735 sec
-    Running org.jboss.test.osgi.example.log.LogServiceTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.385 sec
-    Running org.jboss.test.osgi.example.jndi.JNDITestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.535 sec
-    Running org.jboss.test.osgi.example.jmx.JMXTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.643 sec
-    Running org.jboss.test.osgi.example.simple.SimpleTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.166 sec
-    Running org.jboss.test.osgi.example.simple.SimpleHuskyTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.384 sec
-    </programlisting>
   </sect1>
 
   <sect1 xml:id="SecBundleDeployment">

Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch070-provided-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch070-provided-bundles.xml	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch070-provided-bundles.xml	2009-06-03 13:10:12 UTC (rev 89732)
@@ -8,7 +8,7 @@
   <sect1 xml:id="SecLoggingService">  
     <title>Logging Bridge Service</title>
     
-    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-logging.jar</emphasis> bundle contains a simple Logging Bridge Service to
+    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-common.jar</emphasis> bundle contains a simple Logging Bridge Service to
     <ulink url="http://www.jboss.org/community/docs/DOC-11280">JBoss Logging</ulink>. It registers a trivial LogListener with the 
     LogReaderService in case that service is registered with the Framework.</para>
     
@@ -22,37 +22,20 @@
     from <ulink url="http://felix.apache.org">Apache Felix</ulink>, which gets deployed as Bundle <emphasis role="bold">org.apache.felix.log.jar</emphasis>
     </para>
     
-    <para>The LogListener itself logs messages under the Bundle's symbolic name.</para>
+    <para>The LogListener itself logs messages under the Bundle's symbolic name. You can change the logging for specific Bundles by 
+    <ulink url="http://www.jboss.org/community/docs/DOC-12490">setting the respective logging level</ulink>.</para>  
+  </sect1>
+  
+  <sect1 xml:id="SecJMXService">  
+    <title>JMX Service</title>
     
-    <programlisting role="JAVA">
-    public class JBossLoggingLogListener implements LogListener
-    {
-       public void logged(LogEntry entry)
-       {
-          Bundle bundle = entry.getBundle();
-          int level = entry.getLevel();
-          Throwable throwable = entry.getException();
+    <para>TODO</para>
+  </sect1>
+  
+  <sect1 xml:id="SecJNDIService">  
+    <title>JNDI Service</title>
     
-          String loggerName = bundle.getSymbolicName();
-          Logger log = Logger.getLogger(loggerName);
-          
-          if (level == LogService.LOG_DEBUG)
-             log.debug(entry.getMessage(), throwable);
-          
-          else if (level == LogService.LOG_INFO)
-             log.info(entry.getMessage(), throwable);
-          
-          else if (level == LogService.LOG_WARNING)
-             log.warn(entry.getMessage(), throwable);
-    
-          else if (level == LogService.LOG_ERROR)
-             log.error(entry.getMessage(), throwable);
-       }
-    }
-    </programlisting>
-    
-    <para>You can therefore change the logging for specific Bundles by 
-    <ulink url="http://www.jboss.org/community/docs/DOC-12490">setting the respective logging level</ulink>.</para>  
+    <para>TODO</para>
   </sect1>
   
   <sect1 xml:id="SecRemoteLogService">  
@@ -116,25 +99,30 @@
   <sect1 xml:id="SecMicrocontainerService">  
     <title>Microcontainer Service</title>
     
-    <para>JBoss OSGi SPI comes with a service that give access to the <ulink url="http://www.jboss.org/jbossmc">JBoss Microcontainer</ulink> Kernel
-    and the JMX <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/MBeanServer.html">MBeanServer</ulink>. The service is 
-    registered with the Framework under the name</para>
+    <para>JBoss OSGi SPI comes with a service that give access to the <ulink url="http://www.jboss.org/jbossmc">JBoss Microcontainer</ulink> Kernel. 
+    The service is registered with the Framework under the name</para>
     
     <itemizedlist>
-      <listitem><emphasis role="bold">org.jboss.osgi.service.MicrocontainerService</emphasis></listitem>
+      <listitem><emphasis role="bold">org.jboss.osgi.spi.service.MicrocontainerService</emphasis></listitem>
     </itemizedlist>
     
-    <para>Here is an example of how an OSGi component can register an arbitrary MBean with the 
-    <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/MBeanServer.html">MBeanServer</ulink>.</para>
+    <para>Here is an example of how an OSGi component can access an arbitrary MC bean.</para>
     
     <programlisting role="JAVA">
-    ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
-    if (sref == null)
-      throw new IllegalStateException("MicrocontainerService not registered");
-    
-    MicrocontainerService mcService = (MicrocontainerService)context.getService(sref);
-    MBeanServer mbeanServer = mcService.getMbeanServer();
-    mbeanServer.registerMBean(new Foo(), OBJECT_NAME);
+    public class SomeService
+    {
+       private BundleContext context;
+       
+       ...
+       
+       public String callSomeBean(String msg)
+       {
+          ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
+          MicrocontainerService mcService = (MicrocontainerService)context.getService(sref);
+          SomeBean bean = (SomeBean)mcService.getRegisteredBean("SomeBean");
+          return bean.echo(msg);
+       }
+    }
     </programlisting>
   </sect1>
   

Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml	2009-06-03 13:10:12 UTC (rev 89732)
@@ -13,78 +13,69 @@
     integrated in our <ulink url="http://www.jboss.org/community/docs/DOC-13275">Maven Build Process</ulink> 
     and <ulink url="http://www.jboss.org/community/docs/DOC-13420">Hudson QA Environment</ulink>.</para>
     
-    <para>The examples can be either run against a local embedded OSGi Framework or against
-    a remote OSGi Runtime instance. Here is how you build and run the against the embedded OSGi Framework.</para>
+    <para>The examples can be either run against an embedded OSGi runtime or against
+    a remote runtime. Here is how you build and run the against the embedded runtime.</para>
     
     <programlisting>
-    /home/yourname/jboss-osgi-1.0.0.Beta1/example
     [tdiesler at tddell example]$ mvn test
-    ...
     [INFO] ------------------------------------------------------------------------
     [INFO] Building JBoss OSGi - Testsuite Examples
     [INFO]    task-segment: [test]
     [INFO] ------------------------------------------------------------------------
     ...
-    build-example-jars:
-    # example-log (example-log.jar) 2 
+    build-test-jars:
     # example-http (example-http.jar) 4 
-    # example-microcontainer (example-microcontainer.jar) 4
-    ... 
+    # example-jmx (example-jmx.jar) 4 
+    # example-jndi (example-jndi.jar) 1 
+    # example-log (example-log.jar) 2 
+    # example-mcservice-bundleA (example-mcservice-bundleA.jar) 2 
+    # example-mcservice-bundleB (example-mcservice-bundleB.jar) 3 
+    # example-simple (example-simple.jar) 2 
+    # example-simple-husky (example-simple-husky.jar) 4
+     
     -------------------------------------------------------
      T E S T S
     -------------------------------------------------------
+    Running org.jboss.test.osgi.example.microcontainer.MicrocontainerTestCase
+    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.006 sec
+    Running org.jboss.test.osgi.example.http.HttpServiceTestCase
+    Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.735 sec
     Running org.jboss.test.osgi.example.log.LogServiceTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.876 sec
-    ...
-    [INFO] ------------------------------------------------------------------------
-    [INFO] BUILD SUCCESSFUL
-    [INFO] ------------------------------------------------------------------------
-    [INFO] Total time: 17 seconds
-    [INFO] Finished at: Tue Apr 21 14:32:31 CEST 2009
-    [INFO] Final Memory: 21M/51M
-    [INFO] ------------------------------------------------------------------------
+    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.385 sec
+    Running org.jboss.test.osgi.example.jndi.JNDITestCase
+    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.535 sec
+    Running org.jboss.test.osgi.example.jmx.JMXTestCase
+    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.643 sec
+    Running org.jboss.test.osgi.example.simple.SimpleTestCase
+    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.166 sec
+    Running org.jboss.test.osgi.example.simple.SimpleHuskyTestCase
+    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.384 sec
     </programlisting>
     
     <para>To run the examples against a remote OSGi Runtime, you need to provide the
-    host theat the runtime binds to. This can be done with the 
-    <emphasis role="bold">-Djboss.bind.address=localhost</emphasis> property.</para> 
+    target container that the runtime should connect to. This can be done with the 
+    <emphasis role="bold">target.container</emphasis> system property. 
+    Suported target container values are:</para> 
     
-    <programlisting>
-    /home/yourname/jboss-osgi-1.0.0.Beta1/example
-    [tdiesler at tddell example]$ mvn -Djboss.bind.address=localhost test
-    ...
-    [INFO] ------------------------------------------------------------------------
-    [INFO] Building JBoss OSGi - Testsuite Examples
-    [INFO]    task-segment: [test]
-    [INFO] ------------------------------------------------------------------------
-    ...
-    build-example-jars:
-    # example-log (example-log.jar) 2 
-    # example-http (example-http.jar) 4 
-    # example-microcontainer (example-microcontainer.jar) 4
-    ... 
-    -------------------------------------------------------
-     T E S T S
-    -------------------------------------------------------
-    Running org.jboss.test.osgi.example.http.HttpServiceRemoteTestCase
-    Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.435 sec
-    Running org.jboss.test.osgi.example.log.LogServiceTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.06 sec
-    Running org.jboss.test.osgi.example.microcontainer.MBeanServiceRemoteTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.177 sec
-    Running org.jboss.test.osgi.example.log.LogServiceRemoteTestCase
-    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.632 sec
-    ...
-    [INFO] ------------------------------------------------------------------------
-    [INFO] BUILD SUCCESSFUL
-    [INFO] ------------------------------------------------------------------------
-    [INFO] Total time: 29 seconds
-    [INFO] Finished at: Tue Apr 21 14:47:33 CEST 2009
-    [INFO] Final Memory: 44M/82M
-    [INFO] ------------------------------------------------------------------------
-    </programlisting>
+    <itemizedlist>
+      <listitem>runtime</listitem>
+      <listitem>jboss501</listitem>
+      <listitem>jboss510</listitem>
+      <listitem>jboss520</listitem>
+      <listitem>jboss600</listitem>
+    </itemizedlist>
   </sect1>
   
+  <sect1 xml:id="SecJMXServiceExample">  
+    <title>JMX Service Example</title>
+    <para>TODO</para>
+  </sect1>
+  
+  <sect1 xml:id="SecJMXServiceExample">  
+    <title>JNDI Service Example</title>
+    <para>TODO</para>
+  </sect1>
+  
   <sect1 xml:id="SecHTTPServiceExample">  
     <title>HTTP Service Example</title>
     
@@ -142,23 +133,22 @@
   </sect1>
   
   <sect1 xml:id="SecMicrocontainerServiceExample">  
-    <title>MC Service Example</title>
+    <title>Microcontainer Service Example</title>
     
     <para>The <emphasis role="bold">example-microcontainer.jar</emphasis> bundle contains a Service 
-    that registers an MBean with the <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/MBeanServer.html">MBeanServer</ulink>.
-    </para>
+    that calls a service from an MC bean and vica versa. The MC bean registeres itself as an MBean
+    after it got the MBeanServer injected.</para>
     
-    <programlisting role="JAVA">
-    MicrocontainerService service = (MicrocontainerService)tracker.getService();
-  	mbeanServer = mcService.getMbeanServer();
-    mbeanServer.registerMBean(new Foo(), OBJECT_NAME);
-    </programlisting>
-    
-    <para>The test then accesses the registered MBean.</para>
+    <para>The test accesses the registered MBean.</para>
 
     <programlisting role="JAVA">
-    FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, OBJECT_NAME, getServer());
-    assertEquals("hello", foo.echo("hello"));
+    @Test
+    public void testServiceRoundTrip() throws Exception
+    {
+      SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, MBEAN_NAME, runtime.getMBeanServer());
+      assertEquals("hello", someBean.echo("hello"));
+      assertEquals("hello", someBean.callSomeService("hello"));
+    }
     </programlisting>
   </sect1>
   

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java	2009-06-03 13:10:12 UTC (rev 89732)
@@ -38,7 +38,7 @@
 import org.junit.Test;
 
 /**
- * A test that checks whether the MicrocontainerService can be accessed
+ * A test that calls a service from an MC bean and vica versa
  * 
  * @author thomas.diesler at jboss.com
  * @since 12-Feb-2009
@@ -75,9 +75,8 @@
    }
 
    @Test
-   public void testBeansDeployment() throws Exception
+   public void testServiceRoundTrip() throws Exception
    {
-      // Access the bean through JMX
       SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, MBEAN_NAME, runtime.getMBeanServer());
       assertEquals("hello", someBean.echo("hello"));
       assertEquals("hello", someBean.callSomeService("hello"));

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundleB/SomeBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundleB/SomeBean.java	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundleB/SomeBean.java	2009-06-03 13:10:12 UTC (rev 89732)
@@ -24,7 +24,6 @@
 //$Id$
 
 import javax.management.MBeanServer;
-import javax.management.ObjectName;
 
 import org.jboss.test.osgi.example.microcontainer.bundleA.SomeService;
 import org.osgi.framework.BundleContext;
@@ -65,11 +64,11 @@
 
    public void create() throws Exception
    {
-      mbeanServer.registerMBean(this, new ObjectName("jboss.osgi:bean=SomeBean"));
+      mbeanServer.registerMBean(this, MBEAN_NAME);
    }
    
    public void destroy() throws Exception
    {
-      mbeanServer.unregisterMBean(new ObjectName("jboss.osgi:bean=SomeBean"));
+      mbeanServer.unregisterMBean(MBEAN_NAME);
    }
 }

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java	2009-06-03 13:10:12 UTC (rev 89732)
@@ -25,7 +25,6 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeNotNull;
 
 import org.jboss.osgi.husky.BridgeFactory;
@@ -69,7 +68,6 @@
          
          // Install the bundle
          bundle = runtime.installBundle("example-simple-husky.jar");
-         assertTrue("Bundle installed", (Bundle.INSTALLED & bundle.getState()) > 0);
          
          // Start the bundle
          bundle.start();

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java	2009-06-03 13:05:18 UTC (rev 89731)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java	2009-06-03 13:10:12 UTC (rev 89732)
@@ -24,7 +24,6 @@
 //$Id$
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import org.jboss.osgi.spi.testing.OSGiBundle;
 import org.jboss.osgi.spi.testing.OSGiRuntime;
@@ -50,7 +49,6 @@
       {
          // Install the bundle
          OSGiBundle bundle = runtime.installBundle("example-simple.jar");
-         assertTrue("Bundle installed", (Bundle.INSTALLED & bundle.getState()) > 0);
 
          // Start the bundle
          bundle.start();




More information about the jboss-osgi-commits mailing list