= ComplianceTesting

== Enterprise OSGi Compliance Tests

The Enterprise OSGi compliance tests are provided byt the http://www.osgi.org[OSGi Alliance]  to Apache committers who have signed the appropriate Non Disclosure Agreement.

The tests are supplied with the BND configuration files used to run the tests against the OSGi implementation of the Enterprise Specification.
The configuration files require some modification to run the tests against Aries components.

Instructions for obtaining and running the tests are given http://felix.apache.org/site/using-the-osgi-compliance-tests.html[here], or see below.

== Test results

At each Aries release the tests are run against Aries components.
The results for the most recent release can be found link:/downloads/testresults.html[here] . +++<a name="ComplianceTesting-Runningthetests">++++++</a>+++

== How to run the tests for Aries components

=== Legal stuff

Complete an Apache http://apache.org/jcp/ApacheNDA.pdf[Non Disclosure Agreement]  and email it to secretary@apache.org

Write a note to jcp-open@apache.org with the subject "OSGi CT access" which contains (something like) the following text:

"I'm a committer on the Apache Aries project and would like access to the OSGi CT.
I've submitted an NDA."

NOTE: You should subscribe to jcp-open@apache.org first.
If you don't your note will languish in 'moderation' forever :-)

=== Get the tests

Anyone with an NDA on file should be able to get access to the tests https://svn.apache.org/repos/tck/osgi-cts/[here] .

The group of tests that are required for Aries is called osgi.enterprise.tests.
Download the jar for the appropriate level - currently 4.2.0.

=== Running the tests

Extract the jar into a test directory, say ~/AriesTests.
After you have extracted the file you will find:

* A subdirectory call 'jar' which contains all the tests
* A set of *.bnd files which are used to run the tests

The tests are run using bnd, the command line used to run a set of tests looks like this:

 java -jar jar/bnd.jar runtests -title osgi.ct
 org.osgi.test.cases.blueprint.bnd

The command above would, for example, run the blueprint tests.

Before running the tests it will be necessary to make some changes to the bnd files, to download some additional pre-reqs and to assemble the aries components to be tested.
The http://felix.apache.org/site/using-the-osgi-compliance-tests.html[Felix]  pages give a good indication of what is necessary.

=== Debugging the tests

If you want to debug the code then you need to add the following line to the .bnd file:

 -runvm=-Xdebug,"-Xrunjdwp:transport=dt_socket,server=y,address=localhost:7777"

You can change 7777 to any number you want.

=== Modifying the bnd files

==== General

First, it is necessary to add a couple of lines, like this:

 -runpath = \
     commonjars/osgi-3.5.0.v20090520.jar;version=file, \

 commonjars/com.springsource.junit-3.8.2.jar;version=file;export="junit.framework;version=3.8",

Secondly, if you are using the Eclipse Framework, it is necessary to remove the line

 osgi.resolverMode="strict", \

from the 'runproperties' section.

It's convenient (but not necessary) to keep the the jars required to run the test jars and the code being tested in separate subdirectories.
Create:

* commonjars - any common dependencies, eg pax-logging
* ariesjars - the aries code to be tested

The easiest way to find most of the aries jars and their dependencies is to copy every aries jar in the ~/samples/blog/blog-assembly/target folder into ariesjars and every non-aries jar from the same directory into 'commonjars'.

The _.bnd files that are used to run the tests assume that the person running the tests has access to org.osgi.impl_ jars.
In general this is not the case - so wherever an org.osgi.impl* jar has been used it must be replaced with an equivalent implementation.
Such implementations can usually be found in either http://felix.apache.org/site/downloads.cgi[Felix], http://download.eclipse.org/equinox/[Equinox]  or http://www.knopflerfish.org/releases/3.0.0/osgi/jars/[Knopflerfish].

==== Blueprint

There are four other dependencies needed to run the tests, download these:

* org.osgi.compendium-4.2.0.jar
* osgi-3.5.0.v20090520.jar
* org.eclipse.equinox.event-1.1.100.jar
* org.apache.felix.configadmin-1.2.4.jar

from Maven and put them in commonjars.

After modifications the bnd configuration file to run the blueprint tests will look like this:

....
-include= ~shared.inc
build=.

-target = \
    jar/org.osgi.test.cases.blueprint-4.2.0.jar;version=file,

-runpath = \
    commonjars/osgi-3.5.0.v20090520.jar;version=file, \

commonjars/com.springsource.junit-3.8.2.jar;version=file;export="junit.framework;version=3.8",


-runbundles = \

    commonjars/org.osgi.compendium-4.2.0.jar;version=file;strategy="lowest", \
    commonjars/pax-logging-api-1.4.jar;version=file, \
    commonjars/pax-logging-service-1.4.jar;version=file, \
    commonjars/cm-3.2.0-v20070116.jar;version=file, \
    commonjars/org.eclipse.equinox.event-1.1.100.jar;version=file, \
    commonjars/org.apache.felix.configadmin-1.2.4.jar;version=file, \
    ariesjars/org.apache.aries.blueprint-0.2-incubating.jar;version=file

-runproperties = \
    report="true", \
    osgi.compatibility.bootdelegation="false", \
    osgi.support.multipleHosts="true"
....

==== JNDI

The only additional bundle required for these tests is:

* osgi.enterprise.jar

which can be found at the http://www.osgi.org/Main/HomePage[OSGi Alliance]  site.

The .bnd file required to run the JNDI tests looks like this:

....
-include= ~shared.inc
build=.

-target = \
    jar/org.osgi.test.cases.jndi-4.2.0.jar;version=file,

-runpath = \
    commonjars/osgi-3.5.0.v20090520.jar;version=file, \

commonjars/com.springsource.junit-3.8.2.jar;version=file;export="junit.framework;version=3.8",

-runbundles = \
    commonjars/osgi.enterprise-4.2.0.jar;version=file;strategy="lowest", \
    ariesjars/org.apache.aries.util-0.2-incubating.jar;version=file, \
    ariesjars/org.apache.aries.jndi-0.2-incubating.jar;version=file

-runproperties = \
    report="true", \
    osgi.compatibility.bootdelegation="false", \
    osgi.support.multipleHosts="true", \
    org.osgi.framework.bootdelegation="com.sun.*"
....

==== JMX

It is necessary to download the following:

* http://www.knopflerfish.org/releases/3.0.0/osgi/jars/useradmin/useradmin_all-3.0.1.jar
* http://www.knopflerfish.org/releases/3.0.0/osgi/jars/log/log_api-3.0.1.jar
* org.apache.felix.log-1.0.0.jar
* org.apache.felix.http.bundle-2.0.4.jar

and use them to replace the three org.osgi.impl* jars in the runbundles section.

....
-include= ~shared.inc
build=.

-target = \
    jar/org.osgi.test.cases.jmx-4.2.0.jar;version=file,

-runpath = \
    commonjars/osgi-3.5.0.v20090520.jar;version=file, \

jar/com.springsource.junit-3.8.2.jar;version=file;export="junit.framework;version=3.8",

-runbundles = \
    commonjars/osgi.enterprise-4.2.0.jar;version=file;strategy="lowest", \
    commonjars/org.apache.felix.configadmin-1.2.4.jar;version=file, \
    ariesjars/org.apache.aries.jmx-0.2-incubating.jar;version=file, \
    commonjars/useradmin_all-3.0.1.jar;version=file, \
    commonjars/log_api-3.0.1.jar;version=file, \
    commonjars/org.apache.felix.log-1.0.0.jar;version=file, \
    commonjars/org.osgi.compendium-4.2.0.jar;version=file, \
    commonjars/org.eclipse.equinox.ip_1.1.100.v20100503.jar;version=file, \
    commonjars/org.eclipse.equinox.util_1.0.200.v20100503.jar;version=file, \
    commonjars/org.apache.felix.http.bundle-2.0.4.jar;version=file

-runproperties = \
    report="true", \
    osgi.compatibility.bootdelegation="false", \
    osgi.support.multipleHosts="true", \
    osgi.console="1111", \

    org.osgi.test.cases.jmx.system.packages.extra="junit.framework;version=3.8", \

    org.osgi.test.cases.jmx.bundles="jar/osgi.enterprise-4.2.0.jar,jar/org.apache.aries.jmx-0.2-incubating.jar"
....

==== Transaction

Nothing more to download here.
Here is the configuration file:

....
-include= ~shared.inc
build=.

-target = \
    jar/org.osgi.test.cases.transaction-4.2.0.jar;version=file,

-runpath = \
    commonjars/osgi-3.5.0.v20090520.jar;version=file, \

commonjars/com.springsource.junit-3.8.2.jar;version=file;export="junit.framework;version=3.8",

-runbundles = \
    commonjars/osgi.enterprise-4.2.0.jar;version=file;strategy="lowest", \
    commonjars/pax-logging-api-1.4.jar;version=file, \
    commonjars/pax-logging-service-1.4.jar;version=file, \
    commonjars/geronimo-jta_1.1_spec-1.1.1.jar;version=file, \
    commonjars/geronimo-transaction-2.1.3.jar;version=file, \
    commonjars/geronimo-j2ee-connector_1.5_spec-2.0.0.jar;version=file, \
    commonjars/org.apache.felix.configadmin-1.2.4.jar;version=file, \
    ariesjars/org.apache.aries.blueprint-0.2-incubating.jar;version=file, \
    ariesjars/org.apache.aries.transaction.blueprint-0.2-incubating.jar;version=file, \
    ariesjars/org.apache.aries.transaction.manager-0.2-incubating.jar;version=file, \
    ariesjars/org.apache.aries.transaction.wrappers-0.2-incubating.jar;version=file

-runproperties = \
    report="true", \
    osgi.compatibility.bootdelegation="false", \
    osgi.support.multipleHosts="true", \
    org.osgi.test.cases.transaction.waittime="30"
....
