From jboss-osgi-commits at lists.jboss.org Wed Jun 3 15:00:23 2009 Content-Type: multipart/mixed; boundary="===============1640929678947263249==" MIME-Version: 1.0 From: jboss-osgi-commits at lists.jboss.org To: jboss-osgi-commits at lists.jboss.org Subject: [jboss-osgi-commits] JBoss-OSGI SVN: r89754 - in projects/jboss-osgi/trunk: testsuite/example/src/test/resources/simple and 1 other directory. Date: Wed, 03 Jun 2009 14:51:13 -0400 Message-ID: --===============1640929678947263249== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/ex= ample-simple-husky.bnd Log: userguide - ok Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 20= 09-06-03 17:40:20 UTC (rev 89753) +++ projects/jboss-osgi/trunk/docbook/en/modules/ch060-husky-testing.xml 20= 09-06-03 18:51:13 UTC (rev 89754) @@ -64,7 +64,8 @@ Here is how it works = - A Bridge intercepts a test and delegates the execution to = the same (or another) test in and isolated test environment. = + A Bridge intercepts a test and determines the FQN of the t= est 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 clas= s loading space as the test itself. = A Bridge is associated with an Invoker. Invokers may be ar= bitarily complex. Local 'in proccess' = @@ -77,24 +78,115 @@ = A PackageListeners delegates the Request to a test Runner,= typicaly this would be a JUnit runner. = - The Runner returns a Result, which the Connector returns t= o the Invoker. + The Runner injects the Context and returns a Result, which= the Connector returns to the Invoker. = The Bridge finally translates potential Failures that may = be contained in the Result, to test failures on the client side. + = + The JBoss OSGi jboss-osgi-husky.jar bundle registers the Connectors. The JMXConnector is always = + registered. The SocketConnector is registered when the appropriate con= figuration options are set. It then registers the Extender, = + which is a BundleListener that inspects every + incomming bundle for the Test-Package manifest header. The Extender creates a PackageListener + for every package in the 'Test-Package' manifest header and registers = them with the available Connectors. + = = = Configuration = - [TODO] + In the target OSGi Framework, which is the one that has the jboss-osgi-husky.jar bundle installed, + you set these properties = + + + + + + + + + + + + +
KeyValueDescription
org.jboss.osgi.husky.runtime.connector.hostlocalhostThe Husky socket connector host poperty
org.jboss.osgi.husky.runtime.connector.port5401The Husky socket connector port poperty
+ = + Both properties must be set for the SocketConnector to be availa= ble. + = + On the client side, you must configure the Invoker you want to u= se. + = + + + + + + + +
KeyValueDescription
org.jboss.osgi.husky.Invokerorg.jboss.osgi.husky.internal.OSGiInvokerThe client side Husky Invoker
+ = + This particular invoker will also look for the 'org.jboss.osgi.h= usky.runtime.connector.host' and = + 'org.jboss.osgi.husky.runtime.connector.port' properties and if availa= ble will use a socket invocation.
= = Writing Husky Tests = - [TODO] + In a typical Husky test you have = + + A descriminator to dist= inguish between client and 'in container' execution + An interceptor that del= egates the call to an Invoker (i.e. Bridge.run()) + + = + For OSGi, the descriminator would be the + BundleContext that gets injected by the 'in container' test Ru= nner + = + The interceptor would be a call to one of the Bridge.run() varia= nts. + = + + 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 =3D=3D null) + BridgeFactory.getBridge().run(); + = + // Stop here if the context is not injected + assumeNotNull(context); + = + // Get the SimpleService reference + ServiceReference sref =3D context.getServiceReference(SimpleServ= ice.class.getName()); + assertNotNull("SimpleService Not Null", sref); + = + // Access the SimpleService = + SimpleService service =3D (SimpleService)context.getService(sref= ); + assertEquals("hello", service.echo("hello")); + } + } + + = + The bundle that contains the test case must have the Test-Package manifest header + configured. Here is the a= Qute Bnd Tool configuration for doing so. + + + Bundle-SymbolicName: example-simple-husky + = + Bundle-Activator: org.jboss.test.osgi.example.simple.bundle.SimpleActi= vator + = + 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 + + = = Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/si= mple/example-simple-husky.bnd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/e= xample-simple-husky.bnd 2009-06-03 17:40:20 UTC (rev 89753) +++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/e= xample-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 --===============1640929678947263249==--