Trouble running JUnit4 Integration Tests

234 views
Skip to first unread message

Tristan Bull

unread,
Jun 27, 2014, 5:05:42 PM6/27/14
to bndtool...@googlegroups.com
I have an issue that is very similar to this thread. However, the problem I'm running into is a little different. I keep seeing this error message: 

java.lang.Exception: Cannot load class org.example.tests.ExampleTest, was it included in the test bundle?

I would guess this to mean that either (a) the test is not in Test-Classes or (b) the JUnit3 test runner is being invoked. I am using JUnit4 annotations in my test. I've been stumped for a while though. Here is the full trace output of a sample run. If I can provide any further information, please ask. Thanks for the help!

# properties {launch.name=TestBundle3, launch.noreferences=false, tester.port=54621, tester.dir=C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\test-reports, launch.trace=true, tester.names=org.example.tests.ExampleTest, launch.services=true, launch.activators=aQute.junit.Activator, launch.system.packages=sun.reflect,org.osgi.framework.startlevel;uses:="org.osgi.framework";version="1.0",org.osgi.framework.wiring;uses:="org.osgi.resource,org.osgi.framework";version="1.1",org.osgi.framework.hooks.bundle;uses:="org.osgi.framework";version="1.1",org.osgi.framework.hooks.service;uses:="org.osgi.framework";version="1.1",org.osgi.framework.hooks.resolver;uses:="org.osgi.framework.wiring";version="1.0",org.osgi.framework.namespace;uses:="org.osgi.resource";version="1.0",org.osgi.framework.launch;uses:="org.osgi.framework";version="1.1",org.osgi.framework;version="1.7",org.osgi.framework.hooks.weaving;uses:="org.osgi.framework.wiring";version="1.0",org.osgi.resource;version="1.0",org.osgi.service.url;version="1.0",org.osgi.service.packageadmin;uses:="org.osgi.framework";version="1.2",org.osgi.service.startlevel;uses:="org.osgi.framework";version="1.1",org.osgi.util.tracker;uses:="org.osgi.framework";version="1.5.1",junit.framework;version="3.8";uses:="org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification",org.junit;version="4.10";uses:="org.hamcrest,org.junit.internal",org.junit.experimental;version="4.10";uses:="org.junit.runner,org.junit.runners.model",org.junit.experimental.categories;version="4.10";uses:="org.junit.runner,org.junit.runner.manipulation,org.junit.runners,org.junit.runners.model",org.junit.experimental.max;version="4.10";uses:="org.junit.runner,org.junit.runner.notification",org.junit.experimental.results;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runner.notification",org.junit.experimental.runners;version="4.10";uses:="org.junit.runners,org.junit.runners.model",org.junit.experimental.theories;version="4.10";uses:="org.junit.experimental.theories.internal,org.junit.internal,org.junit.runners,org.junit.runners.model",org.junit.experimental.theories.internal;version="4.10";uses:="org.junit.experimental.theories,org.junit.runners.model",org.junit.experimental.theories.suppliers;version="4.10";uses:="org.junit.experimental.theories",org.junit.internal;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runner.notification",org.junit.internal.builders;version="4.10";uses:="org.junit.runner,org.junit.runner.notification,org.junit.runners.model",org.junit.internal.matchers;version="4.10";uses:="org.hamcrest",org.junit.internal.requests;version="4.10";uses:="org.junit.runner,org.junit.runner.manipulation",org.junit.internal.runners;version="4.10";uses:="junit.framework,org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification",org.junit.internal.runners.model;version="4.10";uses:="org.junit.internal,org.junit.runner,org.junit.runner.notification,org.junit.runners.model",org.junit.internal.runners.rules;version="4.10";uses:="org.junit.runners.model",org.junit.internal.runners.statements;version="4.10";uses:="org.junit.runners.model",org.junit.matchers;version="4.10";uses:="org.hamcrest,org.junit.internal.matchers",org.junit.rules;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runners.model",org.junit.runner;version="4.10";uses:="junit.framework,org.junit.internal,org.junit.runner.manipulation,org.junit.runner.notification,org.junit.runners.model",org.junit.runner.manipulation;version="4.10";uses:="org.junit.runner",org.junit.runner.notification;version="4.10";uses:="org.junit.runner",org.junit.runners;version="4.10";uses:="org.junit.internal.runners,org.junit.rules,org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification,org.junit.runners.model",org.junit.runners.model;version="4.10";uses:="org.junit.runner",org.hamcrest;version="1.0.0",org.hamcrest.core;version="1.0.0";uses:="org.hamcrest",org.hamcrest.internal;version="1.0.0";uses:="org.hamcrest", launch.timeout=0, launch.embedded=false, tester.continuous=false, launch.storage.dir=C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\fw, launch.bundles=C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar,C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar, launch.keep=false, tester.trace=true}
# inited runbundles=[C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar, C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar] activators=[aQute.junit.Activator] timeout=0 properties=<no more arguments>
# version org.apache.felix.framework;version=4.4.0, biz.aQute.launcher;version=1.3.0.201404110949, biz.aQute.junit;version=1.2.0.20130927-173427
# using working dir: C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\fw
# deleting working dir C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\fw because not kept
# system packages used: sun.reflect,org.osgi.framework.startlevel;uses:="org.osgi.framework";version="1.0",org.osgi.framework.wiring;uses:="org.osgi.resource,org.osgi.framework";version="1.1",org.osgi.framework.hooks.bundle;uses:="org.osgi.framework";version="1.1",org.osgi.framework.hooks.service;uses:="org.osgi.framework";version="1.1",org.osgi.framework.hooks.resolver;uses:="org.osgi.framework.wiring";version="1.0",org.osgi.framework.namespace;uses:="org.osgi.resource";version="1.0",org.osgi.framework.launch;uses:="org.osgi.framework";version="1.1",org.osgi.framework;version="1.7",org.osgi.framework.hooks.weaving;uses:="org.osgi.framework.wiring";version="1.0",org.osgi.resource;version="1.0",org.osgi.service.url;version="1.0",org.osgi.service.packageadmin;uses:="org.osgi.framework";version="1.2",org.osgi.service.startlevel;uses:="org.osgi.framework";version="1.1",org.osgi.util.tracker;uses:="org.osgi.framework";version="1.5.1",junit.framework;version="3.8";uses:="org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification",org.junit;version="4.10";uses:="org.hamcrest,org.junit.internal",org.junit.experimental;version="4.10";uses:="org.junit.runner,org.junit.runners.model",org.junit.experimental.categories;version="4.10";uses:="org.junit.runner,org.junit.runner.manipulation,org.junit.runners,org.junit.runners.model",org.junit.experimental.max;version="4.10";uses:="org.junit.runner,org.junit.runner.notification",org.junit.experimental.results;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runner.notification",org.junit.experimental.runners;version="4.10";uses:="org.junit.runners,org.junit.runners.model",org.junit.experimental.theories;version="4.10";uses:="org.junit.experimental.theories.internal,org.junit.internal,org.junit.runners,org.junit.runners.model",org.junit.experimental.theories.internal;version="4.10";uses:="org.junit.experimental.theories,org.junit.runners.model",org.junit.experimental.theories.suppliers;version="4.10";uses:="org.junit.experimental.theories",org.junit.internal;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runner.notification",org.junit.internal.builders;version="4.10";uses:="org.junit.runner,org.junit.runner.notification,org.junit.runners.model",org.junit.internal.matchers;version="4.10";uses:="org.hamcrest",org.junit.internal.requests;version="4.10";uses:="org.junit.runner,org.junit.runner.manipulation",org.junit.internal.runners;version="4.10";uses:="junit.framework,org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification",org.junit.internal.runners.model;version="4.10";uses:="org.junit.internal,org.junit.runner,org.junit.runner.notification,org.junit.runners.model",org.junit.internal.runners.rules;version="4.10";uses:="org.junit.runners.model",org.junit.internal.runners.statements;version="4.10";uses:="org.junit.runners.model",org.junit.matchers;version="4.10";uses:="org.hamcrest,org.junit.internal.matchers",org.junit.rules;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runners.model",org.junit.runner;version="4.10";uses:="junit.framework,org.junit.internal,org.junit.runner.manipulation,org.junit.runner.notification,org.junit.runners.model",org.junit.runner.manipulation;version="4.10";uses:="org.junit.runner",org.junit.runner.notification;version="4.10";uses:="org.junit.runner",org.junit.runners;version="4.10";uses:="org.junit.internal.runners,org.junit.rules,org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification,org.junit.runners.model",org.junit.runners.model;version="4.10";uses:="org.junit.runner",org.hamcrest;version="1.0.0",org.hamcrest.core;version="1.0.0";uses:="org.hamcrest",org.hamcrest.internal;version="1.0.0";uses:="org.hamcrest"
# using META-INF/services
# found META-INF/services in jar:file:/C:/Users/tbull/.bnd/cache/https%253A%252F%252Fgithub.com%252Fbndtools%252Fbundle-hub%252Fraw%252Fmaster%252Forg.apache.felix.framework/org.apache.felix.framework-4.4.0.jar!/META-INF/services/org.osgi.framework.launch.FrameworkFactory
# org.apache.felix.framework.FrameworkFactory
# Framework factory org.apache.felix.framework.FrameworkFactory@27c170f0
# framework instance org.apache.felix.framework [0]
# inited system bundle org.apache.felix.framework [0]
# system bundle started ok
# start embedded activators
# adding activator aQute.junit.Activator@67117f44
# Updating framework with [C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar, C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar]
# installing C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar
# no reference: url false
# installing C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar
# no reference: url false
# Waiting for refresh to finish
# refresh ended
# bundles administered [C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar, C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar]
# Will start bundles: [TestBundle2 [1], TestBundle3 [2]]
# starting TestBundle2
# started  TestBundle2
# starting TestBundle3
### Starting Zar
# started  TestBundle3
------------------------------- REPORT --------------------------

Framework                               class org.apache.felix.framework.Felix
Framework type                          META-INF/services
Storage                                 C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\fw
Keep                                    false
Security                                false
Run bundles                             C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar
                                        C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar
Classpath                               C:\Users\tbull\.bnd\cache\https%3A%2F%2Fgithub.com%2Fbndtools%2Fbundle-hub%2Fraw%2Fmaster%2Forg.apache.felix.framework\org.apache.felix.framework-4.4.0.jar
                                        C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\cnf\buildrepo\biz.aQute.launcher\biz.aQute.launcher-latest.jar
                                        C:\Users\tbull\.bnd\cache\https%3A%2F%2Fgithub.com%2Fbndtools%2Fbundle-hub%2Fraw%2Fmaster%2Fbiz.aQute.junit\biz.aQute.junit-1.2.0.jar
System Packages                         sun.reflect
                                        org.osgi.framework.startlevel;uses:="org.osgi.framework";version="1.0"
                                        org.osgi.framework.wiring;uses:="org.osgi.resource
                                        org.osgi.framework";version="1.1"
                                        org.osgi.framework.hooks.bundle;uses:="org.osgi.framework";version="1.1"
                                        org.osgi.framework.hooks.service;uses:="org.osgi.framework";version="1.1"
                                        org.osgi.framework.hooks.resolver;uses:="org.osgi.framework.wiring";version="1.0"
                                        org.osgi.framework.namespace;uses:="org.osgi.resource";version="1.0"
                                        org.osgi.framework.launch;uses:="org.osgi.framework";version="1.1"
                                        org.osgi.framework;version="1.7"
                                        org.osgi.framework.hooks.weaving;uses:="org.osgi.framework.wiring";version="1.0"
                                        org.osgi.resource;version="1.0"
                                        org.osgi.service.url;version="1.0"
                                        org.osgi.service.packageadmin;uses:="org.osgi.framework";version="1.2"
                                        org.osgi.service.startlevel;uses:="org.osgi.framework";version="1.1"
                                        org.osgi.util.tracker;uses:="org.osgi.framework";version="1.5.1"
                                        junit.framework;version="3.8";uses:="org.junit.runner
                                        org.junit.runner.manipulation
                                        org.junit.runner.notification"
                                        org.junit;version="4.10";uses:="org.hamcrest
                                        org.junit.internal"
                                        org.junit.experimental;version="4.10";uses:="org.junit.runner
                                        org.junit.runners.model"
                                        org.junit.experimental.categories;version="4.10";uses:="org.junit.runner
                                        org.junit.runner.manipulation
                                        org.junit.runners
                                        org.junit.runners.model"
                                        org.junit.experimental.max;version="4.10";uses:="org.junit.runner
                                        org.junit.runner.notification"
                                        org.junit.experimental.results;version="4.10";uses:="org.hamcrest
                                        org.junit.runner
                                        org.junit.runner.notification"
                                        org.junit.experimental.runners;version="4.10";uses:="org.junit.runners
                                        org.junit.runners.model"
                                        org.junit.experimental.theories;version="4.10";uses:="org.junit.experimental.theories.internal
                                        org.junit.internal
                                        org.junit.runners
                                        org.junit.runners.model"
                                        org.junit.experimental.theories.internal;version="4.10";uses:="org.junit.experimental.theories
                                        org.junit.runners.model"
                                        org.junit.experimental.theories.suppliers;version="4.10";uses:="org.junit.experimental.theories"
                                        org.junit.internal;version="4.10";uses:="org.hamcrest
                                        org.junit.runner
                                        org.junit.runner.notification"
                                        org.junit.internal.builders;version="4.10";uses:="org.junit.runner
                                        org.junit.runner.notification
                                        org.junit.runners.model"
                                        org.junit.internal.matchers;version="4.10";uses:="org.hamcrest"
                                        org.junit.internal.requests;version="4.10";uses:="org.junit.runner
                                        org.junit.runner.manipulation"
                                        org.junit.internal.runners;version="4.10";uses:="junit.framework
                                        org.junit.runner
                                        org.junit.runner.manipulation
                                        org.junit.runner.notification"
                                        org.junit.internal.runners.model;version="4.10";uses:="org.junit.internal
                                        org.junit.runner
                                        org.junit.runner.notification
                                        org.junit.runners.model"
                                        org.junit.internal.runners.rules;version="4.10";uses:="org.junit.runners.model"
                                        org.junit.internal.runners.statements;version="4.10";uses:="org.junit.runners.model"
                                        org.junit.matchers;version="4.10";uses:="org.hamcrest
                                        org.junit.internal.matchers"
                                        org.junit.rules;version="4.10";uses:="org.hamcrest
                                        org.junit.runner
                                        org.junit.runners.model"
                                        org.junit.runner;version="4.10";uses:="junit.framework
                                        org.junit.internal
                                        org.junit.runner.manipulation
                                        org.junit.runner.notification
                                        org.junit.runners.model"
                                        org.junit.runner.manipulation;version="4.10";uses:="org.junit.runner"
                                        org.junit.runner.notification;version="4.10";uses:="org.junit.runner"
                                        org.junit.runners;version="4.10";uses:="org.junit.internal.runners
                                        org.junit.rules
                                        org.junit.runner
                                        org.junit.runner.manipulation
                                        org.junit.runner.notification
                                        org.junit.runners.model"
                                        org.junit.runners.model;version="4.10";uses:="org.junit.runner"
                                        org.hamcrest;version="1.0.0"
                                        org.hamcrest.core;version="1.0.0";uses:="org.hamcrest"
                                        org.hamcrest.internal;version="1.0.0";uses:="org.hamcrest"
Properties                              
launch.name                             TestBundle3
launch.noreferences                     false
tester.port                             54621
tester.dir                              C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\test-reports
launch.trace                            true
tester.names                            org.example.tests.ExampleTest
launch.services                         true
launch.activators                       aQute.junit.Activator
launch.system.packages                  sun.reflect,org.osgi.framework.startlevel;uses:="org.osgi.framework";version="1.0",org.osgi.framework.wiring;uses:="org.osgi.resource,org.osgi.framework";version="1.1",org.osgi.framework.hooks.bundle;uses:="org.osgi.framework";version="1.1",org.osgi.framework.hooks.service;uses:="org.osgi.framework";version="1.1",org.osgi.framework.hooks.resolver;uses:="org.osgi.framework.wiring";version="1.0",org.osgi.framework.namespace;uses:="org.osgi.resource";version="1.0",org.osgi.framework.launch;uses:="org.osgi.framework";version="1.1",org.osgi.framework;version="1.7",org.osgi.framework.hooks.weaving;uses:="org.osgi.framework.wiring";version="1.0",org.osgi.resource;version="1.0",org.osgi.service.url;version="1.0",org.osgi.service.packageadmin;uses:="org.osgi.framework";version="1.2",org.osgi.service.startlevel;uses:="org.osgi.framework";version="1.1",org.osgi.util.tracker;uses:="org.osgi.framework";version="1.5.1",junit.framework;version="3.8";uses:="org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification",org.junit;version="4.10";uses:="org.hamcrest,org.junit.internal",org.junit.experimental;version="4.10";uses:="org.junit.runner,org.junit.runners.model",org.junit.experimental.categories;version="4.10";uses:="org.junit.runner,org.junit.runner.manipulation,org.junit.runners,org.junit.runners.model",org.junit.experimental.max;version="4.10";uses:="org.junit.runner,org.junit.runner.notification",org.junit.experimental.results;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runner.notification",org.junit.experimental.runners;version="4.10";uses:="org.junit.runners,org.junit.runners.model",org.junit.experimental.theories;version="4.10";uses:="org.junit.experimental.theories.internal,org.junit.internal,org.junit.runners,org.junit.runners.model",org.junit.experimental.theories.internal;version="4.10";uses:="org.junit.experimental.theories,org.junit.runners.model",org.junit.experimental.theories.suppliers;version="4.10";uses:="org.junit.experimental.theories",org.junit.internal;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runner.notification",org.junit.internal.builders;version="4.10";uses:="org.junit.runner,org.junit.runner.notification,org.junit.runners.model",org.junit.internal.matchers;version="4.10";uses:="org.hamcrest",org.junit.internal.requests;version="4.10";uses:="org.junit.runner,org.junit.runner.manipulation",org.junit.internal.runners;version="4.10";uses:="junit.framework,org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification",org.junit.internal.runners.model;version="4.10";uses:="org.junit.internal,org.junit.runner,org.junit.runner.notification,org.junit.runners.model",org.junit.internal.runners.rules;version="4.10";uses:="org.junit.runners.model",org.junit.internal.runners.statements;version="4.10";uses:="org.junit.runners.model",org.junit.matchers;version="4.10";uses:="org.hamcrest,org.junit.internal.matchers",org.junit.rules;version="4.10";uses:="org.hamcrest,org.junit.runner,org.junit.runners.model",org.junit.runner;version="4.10";uses:="junit.framework,org.junit.internal,org.junit.runner.manipulation,org.junit.runner.notification,org.junit.runners.model",org.junit.runner.manipulation;version="4.10";uses:="org.junit.runner",org.junit.runner.notification;version="4.10";uses:="org.junit.runner",org.junit.runners;version="4.10";uses:="org.junit.internal.runners,org.junit.rules,org.junit.runner,org.junit.runner.manipulation,org.junit.runner.notification,org.junit.runners.model",org.junit.runners.model;version="4.10";uses:="org.junit.runner",org.hamcrest;version="1.0.0",org.hamcrest.core;version="1.0.0";uses:="org.hamcrest",org.hamcrest.internal;version="1.0.0";uses:="org.hamcrest"
launch.timeout                          0
launch.embedded                         false
tester.continuous                       false
launch.storage.dir                      C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\fw
launch.bundles                          C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle2\target\TestBundle2-1.0.0-SNAPSHOT.jar,C:\dev\git\bnd\bnd-maven-plugin-parent\samples\sample-projects\TestBundle3\target\TestBundle3-1.0.0-SNAPSHOT.jar
launch.keep                             false
tester.trace                            true

Id    State Modified      Location
0     ACTIV <>            System Bundle
1     ACTIV <>            file:/C:/dev/git/bnd/bnd-maven-plugin-parent/samples/sample-projects/TestBundle2/target/TestBundle2-1.0.0-SNAPSHOT.jar
2     ACTIV <>            file:/C:/dev/git/bnd/bnd-maven-plugin-parent/samples/sample-projects/TestBundle3/target/TestBundle3-1.0.0-SNAPSHOT.jar
# starting activator aQute.junit.Activator@67117f44
# framework=org.apache.felix.framework [0]
# registered launcher with arguments for syncing
# will call main
# running in main thread
# test cases org.example.tests.ExampleTest
# using port 54621
# receivednames of classes to test org.example.tests.ExampleTest
# testing bundle null with org.example.tests.ExampleTest
# changed streams
! No class found: org.example.tests.ExampleTest, target bundle: null
# Installed bundles:
# System Bundle ACTIVE false
# file:/C:/dev/git/bnd/bnd-maven-plugin-parent/samples/sample-projects/TestBundle2/target/TestBundle2-1.0.0-SNAPSHOT.jar ACTIVE false
# file:/C:/dev/git/bnd/bnd-maven-plugin-parent/samples/sample-projects/TestBundle3/target/TestBundle3-1.0.0-SNAPSHOT.jar ACTIVE false
#   add error to junit.framework.TestSuite@4ec6a292 : Cannot load class org.example.tests.ExampleTest, was it included in the test bundle?
java.lang.Exception: Cannot load class org.example.tests.ExampleTest, was it included in the test bundle?
at aQute.junit.Activator.addTest(Activator.java:322)
at aQute.junit.Activator.createSuite(Activator.java:296)
at aQute.junit.Activator.test(Activator.java:249)
at aQute.junit.Activator.run(Activator.java:91)
at aQute.launcher.Launcher$4.call(Launcher.java:1107)
at aQute.launcher.Launcher$4.call(Launcher.java:1105)
at aQute.launcher.Launcher.run(Launcher.java:239)
at aQute.launcher.Launcher.main(Launcher.java:90)
# created suite junit.framework.TestSuite@4ec6a292
# >>>> null, tests []
# running suite junit.framework.TestSuite@4ec6a292
# <<<<
# unset streams
Tests run  : 0
Passed     : -1
Errors     : 1
Failures   : 0

Peter Kriens

unread,
Jun 30, 2014, 3:25:48 AM6/30/14
to bndtool...@googlegroups.com
It looks like the test class is not in your test bundle. 

! No class found: org.example.tests.ExampleTest, target bundle: null

Could you also goto the target directories of the test bundle 2 and 3, double click the JAR TestBundle{2,3}-1.0.0-SNAPSHOT.jar in there, select the print tab and copy that output and paste it in the mail?

Also please provide the bnd files for the two test projects.

Did you also try to run with just a single test bundle? Did that work?

Kind regards,

Peter Kriens


--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tristan Bull

unread,
Jun 30, 2014, 10:22:46 AM6/30/14
to bndtool...@googlegroups.com
Hello Peter, thanks for the response. You are correct. There are no class files in TestBundle3. However, I'm not sure why. The bnd files for both projects look similar.

TestBundle2

bnd.bnd:

Private-Package: org.foo.zar
Bundle-Activator: org.foo.zar.Zar
Bundle-Version: 1.0.0.SNAPSHOT

-buildpath:  \
osgi.core;version=5.0,\
junit.osgi,\
biz.aQute.bnd.annotation
-runfw: org.apache.felix.framework;version='[4.4.0,4.4.0]'
-runee: JavaSE-1.6
-outputmask = ${@bsn}-${version;===S;${@version}}.jar
target-dir = target
bin = target/classes
src = src/main/java
testsrc = src/test/java
testbin = target/test-classes
Import-Package:  \
org.osgi.framework;version='[1.7, 2)',\
*
Export-Package:  \
org.foo.zar.api

jar file:

[MANIFEST TestBundle2-1.0.0-SNAPSHOT.jar]
Bnd-LastModified                         1404137291107                           
Bundle-Activator                         org.foo.zar.Zar                         
Bundle-ManifestVersion                   2                                       
Bundle-Name                              TestBundle2                             
Bundle-SymbolicName                      TestBundle2                             
Bundle-Version                           1.0.0.SNAPSHOT                          
Created-By                               1.8.0_05 (Oracle Corporation)           
Export-Package                           org.foo.zar.api;version="1.0"           
Import-Package                           org.osgi.framework;version="[1.7,2)",junit.framework;version="[3.8,4)"
Manifest-Version                         1.0                                     
Private-Package                          org.foo.zar                             
Require-Capability                       osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool                                     Bnd-2.3.0.201405100607                  

[IMPEXP]
Import-Package
  junit.framework                        {version=[3.8,4)}
  org.osgi.framework                     {version=[1.7,2)}
Export-Package
  org.foo.zar.api                        {version=1.0}

[USES]
org.foo.zar                              java.io
                                         java.lang
                                         junit.framework
                                         org.osgi.framework
org.foo.zar.api                          java.lang

[USEDBY]
java.io                                  org.foo.zar
java.lang                                org.foo.zar
                                         org.foo.zar.api
junit.framework                          org.foo.zar
org.osgi.framework                       org.foo.zar

[COMPONENTS]

[LIST]
META-INF
  MANIFEST.MF extra='\uFFFD\uFFFD\u0000\u0000'
OSGI-OPT
OSGI-OPT/src
OSGI-OPT/src/org
OSGI-OPT/src/org/foo
OSGI-OPT/src/org/foo/zar
  Zar.java
OSGI-OPT/src/org/foo/zar/api
  Greeting.java
  packageinfo
org
org/foo
org/foo/zar
  Zar.class
  ZarTest.class
org/foo/zar/api
  Greeting.class
  packageinfo


TestBundle3:

bnd.bnd:

Bundle-Version: 1.0.0.SNAPSHOT
-runee: JavaSE-1.8
-runvm: -ea
-runfw: org.apache.felix.framework
-buildpath:  \
TestBundle2;version=latest,\
osgi.core;version=latest,\
osgi.cmpn,\
biz.aQute.junit
-runsystempackages: sun.reflect

-outputmask = ${@bsn}-${version;===S;${@version}}.jar
target-dir = target
bin = target/classes
src = src/main/java
testsrc = src/test/java
testbin = target/test-classes
-runtrace:true
-runbundles:  \
TestBundle2;version=latest
Test-Cases:  \
org.example.tests.ExampleTest
Private-Package:  \
org.example.tests

jar file:

[MANIFEST TestBundle3-1.0.0-SNAPSHOT.jar]
Bnd-LastModified                         1404137327753                           
Bundle-ManifestVersion                   2                                       
Bundle-Name                              TestBundle3                             
Bundle-SymbolicName                      TestBundle3                             
Bundle-Version                           1.0.0.SNAPSHOT                          
Created-By                               1.8.0_05 (Oracle Corporation)           
Manifest-Version                         1.0                                     
Private-Package                          org.example.tests                       
Test-Cases                               org.example.tests.ExampleTest           
Tool                                     Bnd-2.3.0.201405100607                  

[IMPEXP]

[USES]

[USEDBY]

[COMPONENTS]

[LIST]
META-INF
  MANIFEST.MF extra='\uFFFD\uFFFD\u0000\u0000'

For what it's worth, I am trying to modify the bnd-maven-plugin sample that is on github. My ultimate goal is to convert a large PDE project to bnd if possible. However, we already have a lot of junit4 integration tests, so converting them to junit3 is not really an option.

<span
...

Peter Kriens

unread,
Jun 30, 2014, 10:39:39 AM6/30/14
to bndtool...@googlegroups.com
The problem is that you put the OSGi JUnit test code in the src/test/java ... bnd will never JAR anything from these directories, just like in maven, the src/test/java directory is reserved for plain old JUnit tests, without any OSGi.

If you make an OSGi testcase your test code is ending up in the JAR so it is an actual bundle. This implies that this kind of test code must live inside the src/main/java directory for you.

Some comments on your settings

1) You should move the following properties to cnf/build.bnd so you do not repeat yourself:
target-dir = target
bin = target/classes
src = src/main/java
testsrc = src/test/java
testbin = target/test-classes
-runfw: org.apache.felix.framework;version='[4.4.0,4.4.0]'
-runee: JavaSE-1.8
-outputmask = ${@bsn}-${version;===S;${@version}}.jar

2) Never, ever import-package anything  until you are REALLY familiar with bnd. bnd is much better than you ever will be in handling the versions. 
Import-Package:  \
org.osgi.framework;version='[1.7, 2)',\ ### wrong!
*

3) You're exporting 
Export-Package:  \
org.foo.zar.api
This adds org.foo.zar.api to your package ... however your printout tells me that you also got org.foo.zar in a Private-Package statement. So your bnd.bnd file cannot be the version that generated the printed JAR?

4) Pay attention to the warnings, I am pretty sure the 3 project has warnings that told you nothing was added to the bundle.

Kind regards,

Peter Kriens


Tristan Bull

unread,
Jun 30, 2014, 12:12:35 PM6/30/14
to bndtool...@googlegroups.com
I think it will be easiest to respond to your points one by one:


On Monday, June 30, 2014 9:39:39 AM UTC-5, Peter Kriens wrote:
The problem is that you put the OSGi JUnit test code in the src/test/java ... bnd will never JAR anything from these directories, just like in maven, the src/test/java directory is reserved for plain old JUnit tests, without any OSGi.

If you make an OSGi testcase your test code is ending up in the JAR so it is an actual bundle. This implies that this kind of test code must live inside the src/main/java directory for you.

You are correct. The reason the test class in TestBundle3 was not included in the jar is that it was in src/ and not src/main/java. Curiously, this was the original configuration of the project, and the test case would execute before I tried converting the project to Junit4. After moving it, the test class is now included in the jar file. However, I still see the same error message when running the test... 
 

Some comments on your settings

1) You should move the following properties to cnf/build.bnd so you do not repeat yourself:
target-dir = target
bin = target/classes
src = src/main/java
testsrc = src/test/java
testbin = target/test-classes
-runfw: org.apache.felix.framework;version='[4.4.0,4.4.0]'
-runee: JavaSE-1.8
-outputmask = ${@bsn}-${version;===S;${@version}}.jar
 Done.

2) Never, ever import-package anything  until you are REALLY familiar with bnd. bnd is much better than you ever will be in handling the versions. 
Import-Package:  \
org.osgi.framework;version='[1.7, 2)',\ ### wrong!
*

This Import-Package statement was in the sample project before I started modifying it.  I've removed it, and it doesn't seem to have caused any problems...

3) You're exporting 
Export-Package:  \
org.foo.zar.api
This adds org.foo.zar.api to your package ... however your printout tells me that you also got org.foo.zar in a Private-Package statement. So your bnd.bnd file cannot be the version that generated the printed JAR?

Sorry for the dumb question, but how did you come to this conclusion? The class files for org.foo.zar were included in the jar. 


4) Pay attention to the warnings, I am pretty sure the 3 project has warnings that told you nothing was added to the bundle.

This is true. I should have paid closer attention to the warning. However, as I mentioned above, I modified the structure of the project to resolve the warning, yet I still see the same error message when attempting to run the test? 

Thanks again for your help.

...

Tristan Bull

unread,
Jun 30, 2014, 4:07:16 PM6/30/14
to bndtool...@googlegroups.com
For what it's worth, I was able to get this working. I reached a point where my tests were no longer running at all. So I stashed my changes and started over. This time, I just modified the projects to use JUnit4 annotations, and included a bundle containing the junit4 classpath in my Local repo, and everything worked as expected. I created a pull request in case anyone is interested.
                  &nbs
...

Peter Kriens

unread,
Jul 1, 2014, 5:19:29 AM7/1/14
to bndtool...@googlegroups.com
Thanks, we'll take a good look at and see if we can update the example to follow all best practices.

Kind regards,

Peter Kriens

Reply all
Reply to author
Forward
0 new messages