Hi,
I am using Ubuntu 9.10 and using PAX-EXAM 0.3.0 with Equinox. Please read on -
I have also tried PAX-EXAM 0.5.0 and 0.6.0 too.
Am attempting to get a testcase working as given in the excellent book "Modular
Java - Creating flexible apps with OSGi and Spring" by Craig Walls.
Also want to say that the PAX suite is great convenience, thanks to all
involved!
However, I have an issue when executing mvn test against the following testcase
(relevant section only):-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.equinox;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
import dwmj.domain.JarFile;
import dwmj.index.IndexService;
@RunWith(JUnit4TestRunner.class)
public class IndexServiceBundleTest {
@Inject
private BundleContext bundleContext;
@Configuration
public static Option[] configuration()
{
return options(equinox(), provision(
mavenBundle().groupId("org.ops4j.pax.logging").
artifactId("pax-logging-service"),
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api"),
mavenBundle().groupId("com.dudewheresmyjar").artifactId("domain"),
mavenBundle().groupId("com.dudewheresmyjar").artifactId("index"),
mavenBundle().groupId("com.dudewheresmyjar.dwmj").
artifactId("org.compass-project.compass").version("2.1.1-001-SNAPSHOT")
));
}
@Test
public void bundleContextShouldNotBeNull() {
assertNotNull(bundleContext);
}
I get the following error (pax-exam 0.3.0) - (note when I comment out the
configuration() method above and only run the little test alone it works):-
-------------------------------------------------------------------------------
Test set: dwmj.index.test.IndexServiceBundleTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 44.601 sec <<<
FAILURE!
bundleContextShouldNotBeNull [equinox](dwmj.index.test.IndexServiceBundleTest)
Time elapsed: 27.194 se
org.ops4j.pax.exam.spi.container.TestContainerException: Cannot get the remote
bundle context
at
org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient.getRemoteBundleContext(RemoteBundleC
at
org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient.installBundle(RemoteBundleContextCli
at
org.ops4j.pax.exam.container.def.internal.PaxRunnerTestContainer.installBundle(PaxRunnerTest
at
org.ops4j.pax.exam.junit.internal.JUnit4TestMethod.invoke(JUnit4TestMethod.java:101)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.ops4j.pax.exam.junit.internal.JUnit4MethodRoadie.runBeforesThenTestThenAfters(JUnit4Meth
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner.invokeTestMethod(JUnit4TestRunner.java:245)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner.runMethods(JUnit4TestRunner.java:195)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner$2.run(JUnit4TestRunner.java:185)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner.run(JUnit4TestRunner.java:181)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryT
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuit
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.1.1;
nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at
org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient.getRemoteBundleContext(RemoteBundleContextClient.java:234)
... 24 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at java.net.Socket.<init>(Socket.java:372)
at java.net.Socket.<init>(Socket.java:186)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
... 29 more
shouldIndexAndFindAJarFileObject
[equinox](dwmj.index.test.IndexServiceBundleTest) Time elapsed: 17.144 sec
<<< ERROR!
org.ops4j.pax.exam.spi.container.TestContainerException: Cannot get the remote
bundle context
at
org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient.getRemoteBundleContext(RemoteBundleContextClient.java:256)
I saw the following advice at :-
http://www.mail-archive.com/[email protected]/msg05500.html
The solution above was to upgrade the version of PAX-EXAM
Upgrading pax exam to 0.5.0 or 0.6.0 gets rid of this particular problem but I
get the following instead -
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.086 sec <<<
FAILURE!
initializationError0(dwmj.index.test.IndexServiceBundleTest) Time elapsed:
0.025 sec <<< ERROR!
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.ops4j.pax.exam.junit.internal.DefaultConfigMethod.getOptions(DefaultConfigMethod.java:133)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner.getOptions(JUnit4TestRunner.java:353)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner.getTestMethods(JUnit4TestRunner.java:97)
at
org.ops4j.pax.exam.junit.JUnit4TestRunner.<init>(JUnit4TestRunner.java:80)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.junit.internal.requests.ClassRequest.buildRunner(ClassRequest.java:33)
at
org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:28)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)
at
org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
at
org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.NoSuchMethodError:
org.ops4j.pax.exam.CoreOptions.mavenBundle()Lorg/ops4j/pax/exam/options/MavenUrlProvisionOption;
at
dwmj.index.test.IndexServiceBundleTest.configuration(IndexServiceBundleTest.java:36)
... 25 more
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
at
org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.NoSuchMethodError:
org.ops4j.pax.exam.CoreOptions.mavenBundle()Lorg/ops4j/pax/exam/options/MavenUrlProvisionOption;
at
dwmj.index.test.IndexServiceBundleTest.configuration(IndexServiceBundleTest.java:36)
Re. no such method error - Has the API changed ? If so, could someone
please offer the alternative code snippet to use instead for the testcase to
work.
My POM dependencies are below:
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-default</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit-extender-impl</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
Any help greatly appreciated. Will try to dig deeper but any
suggestions along the way most welcome...!
Best regards,
Richard._______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general