JBoss-OSGI SVN: r89761 - projects/jboss-osgi/trunk/docbook/en/modules.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 15:50:06 -0400 (Wed, 03 Jun 2009)
New Revision: 89761
Modified:
projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
Log:
link to husky API
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 19:36:43 UTC (rev 89760)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 19:50:06 UTC (rev 89761)
@@ -64,27 +64,39 @@
<para>Here is how it works </para>
<orderedlist>
- <listitem>A Bridge intercepts a test and determines the FQN of the test case and the test method from the call stack.
- It then delegates the execution to the same (or another) test in and isolated test environment.
- An isolated test environment is one that does not have the same class loading space as the test itself.</listitem>
+ <listitem>A <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">Bridge</ulink>
+ intercepts a test and determines the FQN of the test case and the test method from the call stack. It then delegates the execution to the same
+ (or another) test in and isolated test environment. An isolated test environment is one that does not have the same class loading space as
+ the test itself.</listitem>
- <listitem>A Bridge is associated with an Invoker. Invokers may be arbitarily complex. Local 'in proccess'
- invokers are possible just as well as remote invokers. </listitem>
+ <listitem>A Bridge is associated with an <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Invoker</ulink>. Invokers may be arbitarily complex. Local 'in proccess' invokers are possible just as well as remote invokers. </listitem>
- <listitem>The Invoker sends the Request to a Connector in the isolated test environment.</listitem>
+ <listitem>The Invoker sends the <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Request</ulink> to a <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Connector</ulink> in the isolated test environment.</listitem>
- <listitem>A Connector has associated PackageListeners that are responsible for processing test cases for their
- respective test packages.</listitem>
+ <listitem>A Connector has associated <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ PackageListeners</ulink> that are responsible for processing test cases for their respective test packages.</listitem>
- <listitem>A PackageListeners delegates the Request to a test Runner, typicaly this would be a JUnit runner.</listitem>
+ <listitem>A PackageListeners delegates the Request to a test <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Runner</ulink>, typicaly this would be a <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ JUnitRunner</ulink>.</listitem>
- <listitem>The Runner injects the Context and returns a Result, which the Connector returns to the Invoker.</listitem>
+ <listitem>The Runner injects the <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Context</ulink> into the test case and returns a <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Response</ulink>, which the Connector returns to the Invoker.</listitem>
- <listitem>The Bridge finally translates potential Failures that may be contained in the Result, to test failures on the client side.</listitem>
+ <listitem>The Bridge finally translates potential <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ Failures</ulink> that may be contained in the Result, to test failures on the client side.</listitem>
</orderedlist>
- <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-husky.jar</emphasis> bundle registers the Connectors. The JMXConnector is always
- registered. The SocketConnector is registered when the appropriate configuration options are set. It then registers the Extender,
+ <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-husky.jar</emphasis> bundle registers the Connectors.
+ The <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ JMXConnector</ulink> is always registered.
+ The <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">
+ SocketConnector</ulink> is registered when the appropriate configuration options are set. It then registers the
+ <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/hus...">HuskyExtender</ulink>,
which is a <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/BundleListener.html">BundleListener</ulink> that inspects every
incomming bundle for the <emphasis role="bold">Test-Package</emphasis> manifest header. The Extender creates a PackageListener
for every package in the 'Test-Package' manifest header and registers them with the available Connectors.</para>
15 years, 1 month
JBoss-OSGI SVN: r89760 - projects/jboss-osgi/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 15:36:43 -0400 (Wed, 03 Jun 2009)
New Revision: 89760
Modified:
projects/jboss-osgi/trunk/pom.xml
Log:
Use parent-1.0.0
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-06-03 19:27:49 UTC (rev 89759)
+++ projects/jboss-osgi/trunk/pom.xml 2009-06-03 19:36:43 UTC (rev 89760)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0</version>
</parent>
<!-- Modules -->
15 years, 1 month
JBoss-OSGI SVN: r89759 - projects/jboss-osgi/projects/parent/tags.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 15:27:49 -0400 (Wed, 03 Jun 2009)
New Revision: 89759
Added:
projects/jboss-osgi/projects/parent/tags/jboss-osgi-parent-1.0.0/
Log:
Release jboss-osgi-parent-1.0.0
Copied: projects/jboss-osgi/projects/parent/tags/jboss-osgi-parent-1.0.0 (from rev 89758, projects/jboss-osgi/projects/parent/trunk)
15 years, 1 month
JBoss-OSGI SVN: r89757 - projects/jboss-osgi/projects/parent/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 15:26:02 -0400 (Wed, 03 Jun 2009)
New Revision: 89757
Modified:
projects/jboss-osgi/projects/parent/trunk/pom.xml
Log:
jboss-osgi-parent-1.0.0
Modified: projects/jboss-osgi/projects/parent/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-06-03 19:14:56 UTC (rev 89756)
+++ projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-06-03 19:26:02 UTC (rev 89757)
@@ -156,7 +156,7 @@
-->
<repository>
<id>repository.jboss.org</id>
- <url>${maven.repository.root}</url>
+ <url>file://${maven.repository.root}</url>
</repository>
<snapshotRepository>
<id>snapshots.jboss.org</id>
15 years, 1 month
JBoss-OSGI SVN: r89755 - projects/jboss-osgi/projects/parent/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 15:01:15 -0400 (Wed, 03 Jun 2009)
New Revision: 89755
Modified:
projects/jboss-osgi/projects/parent/trunk/pom.xml
Log:
jboss-osgi-parent-1.0.0
Modified: projects/jboss-osgi/projects/parent/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-06-03 18:51:13 UTC (rev 89754)
+++ projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-06-03 19:01:15 UTC (rev 89755)
@@ -7,7 +7,7 @@
<artifactId>jboss-osgi-parent</artifactId>
<packaging>pom</packaging>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<url>http://www.jboss.org/community/wiki/JBossOSGi</url>
<description>JBossOSGi</description>
15 years, 1 month
JBoss-OSGI SVN: r89754 - in projects/jboss-osgi/trunk: testsuite/example/src/test/resources/simple and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 14:51:13 -0400 (Wed, 03 Jun 2009)
New Revision: 89754
Modified:
projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd
Log:
userguide - ok
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 17:40:20 UTC (rev 89753)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 18:51:13 UTC (rev 89754)
@@ -64,7 +64,8 @@
<para>Here is how it works </para>
<orderedlist>
- <listitem>A Bridge intercepts a test and delegates the execution to the same (or another) test in and isolated test environment.
+ <listitem>A Bridge intercepts a test and determines the FQN of the test case and the test method from the call stack.
+ It then delegates the execution to the same (or another) test in and isolated test environment.
An isolated test environment is one that does not have the same class loading space as the test itself.</listitem>
<listitem>A Bridge is associated with an Invoker. Invokers may be arbitarily complex. Local 'in proccess'
@@ -77,24 +78,115 @@
<listitem>A PackageListeners delegates the Request to a test Runner, typicaly this would be a JUnit runner.</listitem>
- <listitem>The Runner returns a Result, which the Connector returns to the Invoker.</listitem>
+ <listitem>The Runner injects the Context and returns a Result, which the Connector returns to the Invoker.</listitem>
<listitem>The Bridge finally translates potential Failures that may be contained in the Result, to test failures on the client side.</listitem>
</orderedlist>
+
+ <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-husky.jar</emphasis> bundle registers the Connectors. The JMXConnector is always
+ registered. The SocketConnector is registered when the appropriate configuration options are set. It then registers the Extender,
+ which is a <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/BundleListener.html">BundleListener</ulink> that inspects every
+ incomming bundle for the <emphasis role="bold">Test-Package</emphasis> manifest header. The Extender creates a PackageListener
+ for every package in the 'Test-Package' manifest header and registers them with the available Connectors.</para>
+
</sect1>
<sect1 xml:id="SecHuskyConfiguration">
<title>Configuration</title>
- <para>[TODO]</para>
+ <para>In the target OSGi Framework, which is the one that has the <emphasis role="bold">jboss-osgi-husky.jar</emphasis> bundle installed,
+ you set these properties</para>
+ <table>
+ <tr><th>Key</th><th>Value</th><th>Description</th></tr>
+ <tr valign="top">
+ <td>org.jboss.osgi.husky.runtime.connector.host</td>
+ <td>localhost</td>
+ <td>The Husky socket connector host poperty</td>
+ </tr>
+ <tr valign="top">
+ <td>org.jboss.osgi.husky.runtime.connector.port</td>
+ <td>5401</td>
+ <td>The Husky socket connector port poperty</td>
+ </tr>
+ </table>
+
+ <para>Both properties must be set for the SocketConnector to be available.</para>
+
+ <para>On the client side, you must configure the Invoker you want to use.</para>
+
+ <table>
+ <tr><th>Key</th><th>Value</th><th>Description</th></tr>
+ <tr valign="top">
+ <td>org.jboss.osgi.husky.Invoker</td>
+ <td>org.jboss.osgi.husky.internal.OSGiInvoker</td>
+ <td>The client side Husky Invoker</td>
+ </tr>
+ </table>
+
+ <para>This particular invoker will also look for the 'org.jboss.osgi.husky.runtime.connector.host' and
+ 'org.jboss.osgi.husky.runtime.connector.port' properties and if available will use a socket invocation.</para>
</sect1>
<sect1 xml:id="SecHuskyWritingTests">
<title>Writing Husky Tests</title>
- <para>[TODO]</para>
+ <para>In a typical Husky test you have</para>
+ <itemizedlist>
+ <listitem>A <emphasis role="bold">descriminator</emphasis> to distinguish between client and 'in container' execution</listitem>
+ <listitem>An <emphasis role="bold">interceptor</emphasis> that delegates the call to an Invoker (i.e. Bridge.run())</listitem>
+ </itemizedlist>
+
+ <para>For OSGi, the descriminator would be the <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/BundleContext.html">
+ BundleContext</ulink> that gets injected by the 'in container' test Runner</para>
+
+ <para>The interceptor would be a call to one of the Bridge.run() variants.</para>
+
+ <programlisting role="JAVA">
+ public class SimpleHuskyTestCase
+ {
+ @ProvideContext
+ public BundleContext context;
+ ...
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Tell Husky to run this test method within the OSGi Runtime
+ if (context == null)
+ BridgeFactory.getBridge().run();
+
+ // Stop here if the context is not injected
+ assumeNotNull(context);
+
+ // Get the SimpleService reference
+ ServiceReference sref = context.getServiceReference(SimpleService.class.getName());
+ assertNotNull("SimpleService Not Null", sref);
+
+ // Access the SimpleService
+ SimpleService service = (SimpleService)context.getService(sref);
+ assertEquals("hello", service.echo("hello"));
+ }
+ }
+ </programlisting>
+
+ <para>The bundle that contains the test case must have the <emphasis role="bold">Test-Package</emphasis> manifest header
+ configured. Here is the <ulink url="http://www.aqute.biz/Code/Bnd">aQute Bnd Tool</ulink> configuration for doing so.</para>
+
+ <programlisting>
+ Bundle-SymbolicName: example-simple-husky
+
+ Bundle-Activator: org.jboss.test.osgi.example.simple.bundle.SimpleActivator
+
+ Private-Package: org.jboss.test.osgi.example.simple.bundle
+
+ # Export the package that contains tthe test case
+ Export-Package: org.jboss.test.osgi.example.simple
+
+ # Tell Husky that there are test cases in this package
+ Test-Package: org.jboss.test.osgi.example.simple
+ </programlisting>
+
</sect1>
</chapter>
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd 2009-06-03 17:40:20 UTC (rev 89753)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd 2009-06-03 18:51:13 UTC (rev 89754)
@@ -4,10 +4,10 @@
Bundle-Activator: org.jboss.test.osgi.example.simple.bundle.SimpleActivator
+Private-Package: org.jboss.test.osgi.example.simple.bundle
+
# Export the package that contains tthe test case
Export-Package: org.jboss.test.osgi.example.simple
-Private-Package: org.jboss.test.osgi.example.simple.bundle
-
# Tell Husky that there are test cases in this package
-Test-Package: org.jboss.test.osgi.example.simple
\ No newline at end of file
+Test-Package: org.jboss.test.osgi.example.simple
15 years, 1 month
JBoss-OSGI SVN: r89753 - in projects/jboss-osgi/trunk: docbook/en/modules and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 13:40:20 -0400 (Wed, 03 Jun 2009)
New Revision: 89753
Modified:
projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
projects/jboss-osgi/trunk/pom.xml
Log:
husky design - done
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 17:28:46 UTC (rev 89752)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 17:40:20 UTC (rev 89753)
@@ -8,7 +8,12 @@
<sect1 xml:id="SecHuskyOverview">
<title>Overview</title>
- <para>For JBoss OSGi I was looking for ways to test bundles that are deployed to a remote instance of the
+ <para>JBoss OSGi Husky is a OSGi Test Framework that allows you to run plain JUnit4 test cases from within an OSGi Framework.
+ That the test is actually executed in the the OSGi Framework is transparent to your test case. There is no requirement to extend
+ a specific base class nor do you need a special test runner. Your OSGi tests execute along side with all your other (non OSGi specific)
+ test cases in Maven, Ant, or Eclipse.</para>
+
+ <para>Some time ago I was looking for ways to test bundles that are deployed to a remote instance of the
<link linkend="ChapRuntime">JBoss OSGi Runtime</link>. I wanted the solution to also work with an OSGi Framework
that is bootstrapped from within a JUnit test case.</para>
@@ -47,8 +52,8 @@
<sect1 xml:id="SecHuskyArchitecture">
<title>Architecture</title>
- <para>JBoss OSGi Husky is a OSGi test framework that can be installed in any OSGi Runtime. It comes with pluggable a
- test invocation layer suitable for in process and remote test method invocations.</para>
+ <para>JBoss OSGi Husky has client side interceptor that fields the test request to an embedded/remote OSGi Framework where the
+ test case is then actually executed.</para>
<mediaobject>
<imageobject>
@@ -58,6 +63,24 @@
<para>Here is how it works </para>
+ <orderedlist>
+ <listitem>A Bridge intercepts a test and delegates the execution to the same (or another) test in and isolated test environment.
+ An isolated test environment is one that does not have the same class loading space as the test itself.</listitem>
+
+ <listitem>A Bridge is associated with an Invoker. Invokers may be arbitarily complex. Local 'in proccess'
+ invokers are possible just as well as remote invokers. </listitem>
+
+ <listitem>The Invoker sends the Request to a Connector in the isolated test environment.</listitem>
+
+ <listitem>A Connector has associated PackageListeners that are responsible for processing test cases for their
+ respective test packages.</listitem>
+
+ <listitem>A PackageListeners delegates the Request to a test Runner, typicaly this would be a JUnit runner.</listitem>
+
+ <listitem>The Runner returns a Result, which the Connector returns to the Invoker.</listitem>
+
+ <listitem>The Bridge finally translates potential Failures that may be contained in the Result, to test failures on the client side.</listitem>
+ </orderedlist>
</sect1>
<sect1 xml:id="SecHuskyConfiguration">
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-06-03 17:28:46 UTC (rev 89752)
+++ projects/jboss-osgi/trunk/pom.xml 2009-06-03 17:40:20 UTC (rev 89753)
@@ -379,6 +379,17 @@
<enabled>false</enabled>
</snapshots>
</repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
</repositories>
<!-- Profiles -->
15 years, 1 month
JBoss-OSGI SVN: r89750 - in projects/jboss-osgi/trunk: docbook/en/modules and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 12:27:45 -0400 (Wed, 03 Jun 2009)
New Revision: 89750
Added:
projects/jboss-osgi/trunk/docbook/en/images/husky-design.png
projects/jboss-osgi/trunk/docbook/en/images/husky-problem.png
projects/jboss-osgi/trunk/docbook/src/main/graphics/jbossosgi-testing.odp
Removed:
projects/jboss-osgi/trunk/docbook/src/main/graphics/osgi-remote-logging.odp
Modified:
projects/jboss-osgi/trunk/docbook/en/modules/ch050-developer-guide.xml
projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.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/jndi/JNDITestCase.java
Log:
husky testing - WIP
Added: projects/jboss-osgi/trunk/docbook/en/images/husky-design.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/docbook/en/images/husky-design.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/jboss-osgi/trunk/docbook/en/images/husky-problem.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/docbook/en/images/husky-problem.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch050-developer-guide.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch050-developer-guide.xml 2009-06-03 15:54:29 UTC (rev 89749)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch050-developer-guide.xml 2009-06-03 16:27:45 UTC (rev 89750)
@@ -316,9 +316,7 @@
{
@ProvideContext
public BundleContext context;
-
...
-
@Test
public void testSimpleBundle() throws Exception
{
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 15:54:29 UTC (rev 89749)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 2009-06-03 16:27:45 UTC (rev 89750)
@@ -8,10 +8,58 @@
<sect1 xml:id="SecHuskyOverview">
<title>Overview</title>
- <para>[TODO]</para>
+ <para>For JBoss OSGi I was looking for ways to test bundles that are deployed to a remote instance of the
+ <link linkend="ChapRuntime">JBoss OSGi Runtime</link>. I wanted the solution to also work with an OSGi Framework
+ that is bootstrapped from within a JUnit test case.</para>
+
+ <para>The basic problem is of course that you cannot access the artefacts that you deploy in a bundle directly from your test case,
+ because they are loaded from different classloaders.</para>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/husky-problem.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>Former releases of JBoss OSGi used an approach which is documented in
+ <ulink url="http://jbossosgi.blogspot.com/2009/04/non-intrusive-osgi-bundle-testing.html">Non intrusive OSGi Bundle Testing</ulink> and
+ is still available. Although the remote logging approach worked for simple scenarios, it does not allow for fine grained interaction with
+ the OSGi Framework (i.e. access to the registry). An additional problem was the asynchronous nature of LogEntry delivery.</para>
+
+ <para>For this release however, I revisited the problem and added a few more requirements.</para>
+
+ <itemizedlist>
+ <listitem>Test cases SHOULD be plain JUnit4 POJOs</listitem>
+ <listitem>There SHOULD be no requirement to extend a specific test base class</listitem>
+ <listitem>There MUST be no requirement on a specific test runner (i.e. MUST run with Maven)</listitem>
+ <listitem>There SHOULD be a minimum test framework leakage into the test case</listitem>
+ <listitem>The test framework MUST support embedded and remote OSGi runtimes with no change required to the test</listitem>
+ <listitem>The same test case MUST be executable from outside as well as from within the OSGi Framework</listitem>
+ <listitem>There SHOULD be a pluggable communication layer from the test runner to the OSGi Framework</listitem>
+ <listitem>The test framework MUST NOT depend on OSGi Framework specific features</listitem>
+ <listitem>There MUST be no automated creation of test bundles required by the test framework</listitem>
+ </itemizedlist>
+
+ <para>The next section explains the solution that now comes as JBoss OSGi Husky</para>
+
</sect1>
+ <sect1 xml:id="SecHuskyArchitecture">
+ <title>Architecture</title>
+
+ <para>JBoss OSGi Husky is a OSGi test framework that can be installed in any OSGi Runtime. It comes with pluggable a
+ test invocation layer suitable for in process and remote test method invocations.</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/husky-design.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>Here is how it works </para>
+
+ </sect1>
+
<sect1 xml:id="SecHuskyConfiguration">
<title>Configuration</title>
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 15:54:29 UTC (rev 89749)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch070-provided-bundles.xml 2009-06-03 16:27:45 UTC (rev 89750)
@@ -172,10 +172,6 @@
<programlisting role="JAVA">
public class SomeService
{
- private BundleContext context;
-
- ...
-
public String callSomeBean(String msg)
{
ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
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 15:54:29 UTC (rev 89749)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml 2009-06-03 16:27:45 UTC (rev 89750)
@@ -69,7 +69,7 @@
<sect1 xml:id="SecSimpleExample">
<title>Simple Example</title>
- <para>The simple example is covered in: <link linked="SecWritingTests">Writing Test Cases</link></para>
+ <para>The simple example is covered in: <link linkend="SecWritingTests">Writing Test Cases</link></para>
</sect1>
<sect1 xml:id="SecJMXServiceExample">
@@ -124,9 +124,11 @@
}
</programlisting>
- <para>Please note that access to the MBeanServer from the test case is part of the
- <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss...">
- OSGiRuntime</ulink>abstraction.</para>
+ <note>
+ <para>Please note that access to the MBeanServer from the test case is part of the
+ <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss...">
+ OSGiRuntime</ulink> abstraction.</para>
+ </note>
</sect1>
@@ -168,9 +170,11 @@
}
</programlisting>
- <para>Please note that access to the InitialContext from the test case is part of the
- <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss...">
- OSGiRuntime</ulink>abstraction.</para>
+ <note>
+ <para>Please note that access to the InitialContext from the test case is part of the
+ <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss...">
+ OSGiRuntime</ulink> abstraction.</para>
+ </note>
</sect1>
Added: projects/jboss-osgi/trunk/docbook/src/main/graphics/jbossosgi-testing.odp
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/docbook/src/main/graphics/jbossosgi-testing.odp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: projects/jboss-osgi/trunk/docbook/src/main/graphics/osgi-remote-logging.odp
===================================================================
(Binary files differ)
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java 2009-06-03 15:54:29 UTC (rev 89749)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java 2009-06-03 16:27:45 UTC (rev 89750)
@@ -36,7 +36,6 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.osgi.framework.Bundle;
/**
* A test that deployes a bundle that binds a String to JNDI
15 years, 1 month
JBoss-OSGI SVN: r89741 - in projects/jboss-osgi/trunk: testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle and 8 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 10:44:55 -0400 (Wed, 03 Jun 2009)
New Revision: 89741
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java
Removed:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
Modified:
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/jndi/JNDITestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd
Log:
All chapters except Husky - ok
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 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml 2009-06-03 14:44:55 UTC (rev 89741)
@@ -14,7 +14,7 @@
and <ulink url="http://www.jboss.org/community/docs/DOC-13420">Hudson QA Environment</ulink>.</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>
+ a remote OSGi runtime. Here is how you build and run the against the embedded runtime.</para>
<programlisting>
[tdiesler@tddell example]$ mvn test
@@ -54,8 +54,9 @@
<para>To run the examples against a remote OSGi Runtime, you need to provide the
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>
+ <emphasis role="bold">target.container</emphasis> system property.</para>
+
+ <para>Suported target container values are:</para>
<itemizedlist>
<listitem>runtime</listitem>
@@ -68,19 +69,109 @@
<sect1 xml:id="SecSimpleExample">
<title>Simple Example</title>
-
<para>The simple example is covered in: <link linked="SecWritingTests">Writing Test Cases</link></para>
-
</sect1>
<sect1 xml:id="SecJMXServiceExample">
<title>JMX Service Example</title>
- <para>TODO</para>
+
+ <para>The <emphasis role="bold">example-jmx.jar</emphasis> bundle tracks the MBeanServer service and registers
+ a pojo with JMX. It then verifies the JMX access.
+ </para>
+
+ <programlisting role="JAVA">
+ public class FooServiceActivator implements BundleActivator
+ {
+ public void start(BundleContext context)
+ {
+ ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+ {
+ public Object addingService(ServiceReference reference)
+ {
+ MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
+ registerMBean(mbeanServer);
+ return mbeanServer;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ unregisterMBean((MBeanServer)service);
+ super.removedService(reference, service);
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ if (sref != null)
+ {
+ MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+ unregisterMBean(mbeanServer);
+ }
+ }
+ ...
+ }
+ </programlisting>
+
+ <programlisting role="JAVA">
+ public void testMBeanAccess() throws Exception
+ {
+ FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, MBEAN_NAME, runtime.getMBeanServer());
+ assertEquals("hello", foo.echo("hello"));
+ }
+ </programlisting>
+
+ <para>Please note that access to the MBeanServer from the test case is part of the
+ <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss...">
+ OSGiRuntime</ulink>abstraction.</para>
+
</sect1>
<sect1 xml:id="SecJNDIServiceExample">
<title>JNDI Service Example</title>
- <para>TODO</para>
+
+ <para>The <emphasis role="bold">example-jndi.jar</emphasis> bundle gets the InitialContext service and registers
+ a string with JNDI. It then verifies the JNDI access.
+ </para>
+
+ <programlisting role="JAVA">
+ ServiceReference sref = context.getServiceReference(InitialContext.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("Cannot access the InitialContext");
+
+ InitialContext iniContext = (InitialContext)context.getService(sref);
+ iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
+ </programlisting>
+
+ <programlisting role="JAVA">
+ public void testJNDIAccess() throws Exception
+ {
+ InitialContext iniCtx = runtime.getInitialContext();
+ String lookup = (String)iniCtx.lookup("test/Foo");
+ assertEquals("JNDI bound String expected", "Bar", lookup);
+
+ // Uninstall should unbind the object
+ bundle.uninstall();
+
+ try
+ {
+ iniCtx.lookup("test/Foo");
+ fail("NameNotFoundException expected");
+ }
+ catch (NameNotFoundException ex)
+ {
+ // expected
+ }
+ }
+ </programlisting>
+
+ <para>Please note that access to the InitialContext from the test case is part of the
+ <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss...">
+ OSGiRuntime</ulink>abstraction.</para>
+
</sect1>
<sect1 xml:id="SecHTTPServiceExample">
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java (from rev 89712, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,53 @@
+/*
+ * 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.example.http.bundle;
+
+//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 04-Feb-2009
+ */
+public class HttpExampleActivator implements BundleActivator
+{
+ /*
+ * Implements BundleActivator.start().
+ * Registers an instance of a HttpEndpoint Service using the bundle context.
+ */
+ public void start(BundleContext context)
+ {
+ EndpointService service = new EndpointService(context);
+ context.registerService(EndpointService.class.getName(), service, null);
+ }
+
+ /*
+ * Implements BundleActivator.stop().
+ */
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,53 +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.example.http.bundle;
-
-//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler(a)jboss.com
- * @since 04-Feb-2009
- */
-public class ServiceActivator implements BundleActivator
-{
- /*
- * Implements BundleActivator.start().
- * Registers an instance of a HttpEndpoint Service using the bundle context.
- */
- public void start(BundleContext context)
- {
- EndpointService service = new EndpointService(context);
- context.registerService(EndpointService.class.getName(), service, null);
- }
-
- /*
- * Implements BundleActivator.stop().
- */
- public void stop(BundleContext context)
- {
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,99 +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.example.jmx.bundle;
-
-//$Id$
-
-import static org.jboss.test.osgi.example.jmx.bundle.FooMBean.MBEAN_NAME;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler(a)jboss.com
- * @since 24-Apr-2009
- */
-public class FooServiceActivator implements BundleActivator
-{
- public void start(BundleContext context)
- {
- ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
- {
- public Object addingService(ServiceReference reference)
- {
- MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
- registerMBean(mbeanServer);
- return mbeanServer;
- }
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- unregisterMBean((MBeanServer)service);
- super.removedService(reference, service);
- }
- };
- tracker.open();
- }
-
- public void stop(BundleContext context)
- {
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- if (sref != null)
- {
- MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
- unregisterMBean(mbeanServer);
- }
- }
-
- private void registerMBean(MBeanServer mbeanServer)
- {
- try
- {
- mbeanServer.registerMBean(new Foo(), MBEAN_NAME);
- }
- catch (JMException ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-
- private void unregisterMBean(MBeanServer mbeanServer)
- {
- try
- {
- if (mbeanServer.isRegistered(MBEAN_NAME))
- mbeanServer.unregisterMBean(MBEAN_NAME);
- }
- catch (JMException ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java (from rev 89712, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,99 @@
+/*
+ * 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.example.jmx.bundle;
+
+//$Id$
+
+import static org.jboss.test.osgi.example.jmx.bundle.FooMBean.MBEAN_NAME;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class JMXExampleActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+ {
+ public Object addingService(ServiceReference reference)
+ {
+ MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
+ registerMBean(mbeanServer);
+ return mbeanServer;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ unregisterMBean((MBeanServer)service);
+ super.removedService(reference, service);
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ if (sref != null)
+ {
+ MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+ unregisterMBean(mbeanServer);
+ }
+ }
+
+ private void registerMBean(MBeanServer mbeanServer)
+ {
+ try
+ {
+ mbeanServer.registerMBean(new Foo(), MBEAN_NAME);
+ }
+ catch (JMException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ private void unregisterMBean(MBeanServer mbeanServer)
+ {
+ try
+ {
+ if (mbeanServer.isRegistered(MBEAN_NAME))
+ mbeanServer.unregisterMBean(MBEAN_NAME);
+ }
+ catch (JMException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -47,12 +47,16 @@
public class JNDITestCase
{
private static OSGiRuntime runtime;
+ private static OSGiBundle bundle;
@BeforeClass
public static void setUpClass() throws Exception
{
runtime = new OSGiTestHelper().getDefaultRuntime();
runtime.addCapability(new JNDICapability());
+
+ bundle = runtime.installBundle("example-jndi.jar");
+ bundle.start();
}
@AfterClass
@@ -64,11 +68,6 @@
@Test
public void testJNDIAccess() throws Exception
{
- OSGiBundle bundle = runtime.installBundle("example-jndi.jar");
- bundle.start();
-
- assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
-
InitialContext iniCtx = runtime.getInitialContext();
String lookup = (String)iniCtx.lookup("test/Foo");
assertEquals("JNDI bound String expected", "Bar", lookup);
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java (from rev 89712, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,76 @@
+/*
+ * 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.example.jndi.bundle;
+
+//$Id$
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class JNDIExampleActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ try
+ {
+ InitialContext iniCtx = getInitialContext(context);
+ iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot bind to JNDI", ex);
+ }
+ }
+
+ public void stop(BundleContext context)
+ {
+ try
+ {
+ InitialContext iniCtx = getInitialContext(context);
+ iniCtx.unbind("test");
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot unbind from JNDI", ex);
+ }
+ }
+
+ private InitialContext getInitialContext(BundleContext context)
+ {
+ ServiceReference sref = context.getServiceReference(InitialContext.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("Cannot access the InitialContext");
+
+ InitialContext initContext = (InitialContext)context.getService(sref);
+ return initContext;
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,76 +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.example.jndi.bundle;
-
-//$Id$
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler(a)jboss.com
- * @since 05-May-2009
- */
-public class ServiceActivator implements BundleActivator
-{
- public void start(BundleContext context)
- {
- try
- {
- InitialContext iniCtx = getInitialContext(context);
- iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot bind to JNDI", ex);
- }
- }
-
- public void stop(BundleContext context)
- {
- try
- {
- InitialContext iniCtx = getInitialContext(context);
- iniCtx.unbind("test");
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot unbind from JNDI", ex);
- }
- }
-
- private InitialContext getInitialContext(BundleContext context)
- {
- ServiceReference sref = context.getServiceReference(InitialContext.class.getName());
- if (sref == null)
- throw new IllegalStateException("Cannot access the InitialContext");
-
- InitialContext initContext = (InitialContext)context.getService(sref);
- return initContext;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java (from rev 89723, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,42 @@
+/*
+ * 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.example.log.bundle;
+
+//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class LogExampleActivator implements BundleActivator
+{
+ public void start(final BundleContext context)
+ {
+ ServiceA service = new ServiceA(context);
+ context.registerService(ServiceA.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ // Do Nothing. It is unnecessary to unregister services or Framework listeners
+ // because they must be clean up by the Framework anyway.
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,42 +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.example.log.bundle;
-
-//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class LogServiceActivator implements BundleActivator
-{
- public void start(final BundleContext context)
- {
- ServiceA service = new ServiceA(context);
- context.registerService(ServiceA.class.getName(), service, null);
- }
-
- public void stop(BundleContext context)
- {
- // Do Nothing. It is unnecessary to unregister services or Framework listeners
- // because they must be clean up by the Framework anyway.
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,6 +1,6 @@
# bnd build -classpath target/test-classes -output target/test-libs/example/example-http.jar src/test/resources/example/http/example-http.bnd
Bundle-SymbolicName: example-http
-Bundle-Activator: org.jboss.test.osgi.example.http.bundle.ServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.http.bundle.HttpExampleActivator
Export-Package: org.jboss.test.osgi.example.http.bundle
Include-Resource: res/message.txt=message.txt
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,5 +1,5 @@
# bnd build -classpath target/test-classes -output target/test-libs/example-jmx.jar src/test/resources/jmx/example-jmx.bnd
Bundle-SymbolicName: example-jmx
-Bundle-Activator: org.jboss.test.osgi.example.jmx.bundle.FooServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.jmx.bundle.JMXExampleActivator
Export-Package: org.jboss.test.osgi.example.jmx.bundle
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd 2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,6 +1,6 @@
# bnd build -classpath target/test-classes -output target/test-libs/jndi-test.jar src/test/resources/jndi/jndi-test.bnd
Bundle-SymbolicName: example-jndi
-Bundle-Activator: org.jboss.test.osgi.example.jndi.bundle.ServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.jndi.bundle.JNDIExampleActivator
Export-Package: org.jboss.test.osgi.example.jndi.bundle
Import-Package: javax.naming, org.osgi.framework
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd 2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd 2009-06-03 14:44:55 UTC (rev 89741)
@@ -2,5 +2,5 @@
Bundle-SymbolicName: example-log
-Bundle-Activator: org.jboss.test.osgi.example.log.bundle.LogServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.log.bundle.LogExampleActivator
Export-Package: org.jboss.test.osgi.example.log.bundle
15 years, 1 month