I'm trying to upgrade an open source project that I'm running
(https://github.com/rest-assured/rest-assured) from Groovy 2.4.x to 2.5.x.
Groovy 2.5 uses fragment bundles and I cannot seem to get this working in
Pax Exam. Here's a test (you can find it here
<https://github.com/rest-assured/rest-assured/blob/master/examples/rest-assured-itest-java-osgi/src/test/java/io/restassured/test/osgi/XmlPathOSGiITest.java>
):
@RunWith(PaxExam.class)
public class XmlPathOSGiITest {
@Configuration
public static Option[] configure() {
return new Option[]
{
mavenBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.hamcrest", "1.3_1"),
junitBundles(),
systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy-xml").version("2.5.6").noStart(),
mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy-json").version("2.5.6").noStart(),
mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy").version("2.5.6"),
/* Transitive dependencies needed in the Pax Exam
container.
Some of these need to be wrapped because they are not
available as OSGi bundles */
mavenBundle("org.apache.commons",
"commons-lang3").versionAsInProject(),
wrappedBundle(mavenBundle().groupId("org.ccil.cowan.tagsoup").artifactId("tagsoup").versionAsInProject()),
wrappedBundle(mavenBundle("javax.xml.bind",
"jaxb-api").versionAsInProject()),
wrappedBundle(mavenBundle("javax.activation",
"activation").version("1.1.1")),
wrappedBundle(mavenBundle("org.apache.httpcomponents",
"httpclient").versionAsInProject()),
wrappedBundle(mavenBundle("org.apache.httpcomponents",
"httpmime").versionAsInProject()),
wrappedBundle(mavenBundle("org.apache.httpcomponents",
"httpcore").versionAsInProject()),
/* Rest Assured dependencies needed in the Pax Exam
container to be able to execute the tests below */
mavenBundle("io.rest-assured",
"json-path").versionAsInProject(),
mavenBundle("io.rest-assured",
"xml-path").versionAsInProject(),
mavenBundle("io.rest-assured",
"rest-assured").versionAsInProject(),
mavenBundle("io.rest-assured",
"rest-assured-common").versionAsInProject()
};
}
@Test
public void getUUIDParsesAStringResultToUUID() {
final String UUID_XML = "<some>\n" +
" <thing
id=\"1\">db24eeeb-7fe5-41d3-8f06-986b793ecc91</thing>\n" +
" <thing
id=\"2\">d69ded28-d75c-460f-9cbe-1412c60ed4cc</thing>\n" +
"</some>";
final UUID uuid = from(UUID_XML).getUUID("some.thing[0]");
assertThat(uuid,
Matchers.equalTo(UUID.fromString("db24eeeb-7fe5-41d3-8f06-986b793ecc91")));
}
}
When I run this test it'll fail with:
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
: Enabling SLF4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
: Enabling Jakarta Commons Logging API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
: Enabling Log4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
: Enabling Avalon Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
: Enabling JULI Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
: Enabling Log4J v2 API support. Ignored FQCN:
org.apache.logging.log4j.spi.AbstractLogger
ERROR: Bundle io.rest-assured.json-path [27] Error starting
file:/var/folders/9z/tqq6c03j3l33pv9k1c24hsnw0000gn/T/1553246897478-0/pax-exam-downloads/io.rest-assured.json-path_3.3.1.SNAPSHOT.jar
(org.osgi.framework.BundleException: Unable to resolve
io.rest-assured.json-path [27](R 27.0): missing requirement
[io.rest-assured.json-path [27](R 27.0)] osgi.wiring.package;
(&(osgi.wiring.package=groovy.json)(version>=2.5.0)(!(version>=2.6.0)))
[caused by: Unable to resolve groovy-json [19](R 19.0): missing requirement
[groovy-json [19](R 19.0)] osgi.wiring.host;
(&(osgi.wiring.host=groovy)(bundle-version>=0.0.0))] Unresolved
requirements: [[io.rest-assured.json-path [27](R 27.0)]
osgi.wiring.package;
(&(osgi.wiring.package=groovy.json)(version>=2.5.0)(!(version>=2.6.0)))])
org.osgi.framework.BundleException: Unable to resolve
io.rest-assured.json-path [27](R 27.0): missing requirement
[io.rest-assured.json-path [27](R 27.0)] osgi.wiring.package;
(&(osgi.wiring.package=groovy.json)(version>=2.5.0)(!(version>=2.6.0)))
[caused by: Unable to resolve groovy-json [19](R 19.0): missing requirement
[groovy-json [19](R 19.0)] osgi.wiring.host;
(&(osgi.wiring.host=groovy)(bundle-version>=0.0.0))] Unresolved
requirements: [[io.rest-assured.json-path [27](R 27.0)]
osgi.wiring.package;
(&(osgi.wiring.package=groovy.json)(version>=2.5.0)(!(version>=2.6.0)))]
at
org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4362)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2277)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1535)
at
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:748)
org.osgi.framework.BundleException: Unable to resolve io.rest-assured
[29](R 29.0): missing requirement [io.rest-assured [29](R 29.0)]
osgi.wiring.package;
(&(osgi.wiring.package=io.restassured.internal.path.json.mapping)(version>=3.3.0)(!(version>=4.0.0)))
[caused by: Unable to resolve io.rest-assured.json-path [27](R 27.0):
missing requirement [io.rest-assured.json-path [27](R 27.0)]
osgi.wiring.package;
(&(osgi.wiring.package=groovy.json)(version>=2.5.0)(!(version>=2.6.0)))
[caused by: Unable to resolve groovy-json [19](R 19.0): missing requirement
[groovy-json [19](R 19.0)] osgi.wiring.host;
(&(osgi.wiring.host=groovy)(bundle-version>=0.0.0))]] Unresolved
requirements: [[io.rest-assured [29](R 29.0)] osgi.wiring.package;
(&(osgi.wiring.package=io.restassured.internal.path.json.mapping)(version>=3.3.0)(!(version>=4.0.0)))]
ERROR: Bundle io.rest-assured [29] Error starting
file:/var/folders/9z/tqq6c03j3l33pv9k1c24hsnw0000gn/T/1553246897478-0/pax-exam-downloads/io.rest-assured_3.3.1.SNAPSHOT.jar
(org.osgi.framework.BundleException: Unable to resolve io.rest-assured
[29](R 29.0): missing requirement [io.rest-assured [29](R 29.0)]
osgi.wiring.package;
(&(osgi.wiring.package=io.restassured.internal.path.json.mapping)(version>=3.3.0)(!(version>=4.0.0)))
[caused by: Unable to resolve io.rest-assured.json-path [27](R 27.0):
missing requirement [io.rest-assured.json-path [27](R 27.0)]
osgi.wiring.package;
(&(osgi.wiring.package=groovy.json)(version>=2.5.0)(!(version>=2.6.0)))
[caused by: Unable to resolve groovy-json [19](R 19.0): missing requirement
[groovy-json [19](R 19.0)] osgi.wiring.host;
(&(osgi.wiring.host=groovy)(bundle-version>=0.0.0))]] Unresolved
requirements: [[io.rest-assured [29](R 29.0)] osgi.wiring.package;
(&(osgi.wiring.package=io.restassured.internal.path.json.mapping)(version>=3.3.0)(!(version>=4.0.0)))])
at
org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4362)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2277)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1535)
at
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:748)
org.ops4j.pax.exam.TestContainerException: There are unresolved bundles.
See previous ERROR log messages for details.
at
org.ops4j.pax.exam.forked.ForkedTestContainer.verifyThatBundlesAreResolved(ForkedTestContainer.java:345)
at
org.ops4j.pax.exam.forked.ForkedTestContainer.installAndStartBundles(ForkedTestContainer.java:309)
at
org.ops4j.pax.exam.forked.ForkedTestContainer.start(ForkedTestContainer.java:165)
at
org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:79)
at
org.ops4j.pax.exam.junit.impl.ProbeRunner$2.evaluate(ProbeRunner.java:267)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:98)
at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
The io.rest-assured.json-path module has the following maven configuration
<https://github.com/rest-assured/rest-assured/blob/master/json-path/pom.xml#L42>
related to OSGi:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
io.restassured.path.json.*,
io.restassured.internal.path.json.*
</Export-Package>
<Import-Package>
groovy.*;version="${groovy.range}",
org.codehaus.groovy.*;version="${groovy.range}",
*
</Import-Package>
</instructions>
</configuration>
</plugin>
So from what I can tell it ought to import the "groovy.json" package from
the "groovy-json" fragment bundle. The manifest file in groovy.json is
defined like this:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.11
Created-By: Gradle
Bundle-ManifestVersion: 2
Tool: Bnd-3.4.0.201707252008
Export-Package: groovy.json;version="2.5.6",org.apache.groovy.json;ver
sion="2.5.6",org.apache.groovy.json.internal;version="2.5.6"
Import-Package: groovy.io;resolution:=optional,groovy.json;resolution:
=optional;version="[2.5,3)",groovy.lang;resolution:=optional,groovy.t
ransform.stc;resolution:=optional,groovy.util;resolution:=optional,or
g.apache.groovy.io;resolution:=optional,org.apache.groovy.json;resolu
tion:=optional;version="[2.5,3)",org.apache.groovy.json.internal;reso
lution:=optional;version="[2.5,3)",org.codehaus.groovy.runtime;resolu
tion:=optional,org.codehaus.groovy.runtime.memoize;resolution:=option
al
Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.service
loader.registrar)",osgi.extender;filter:="(osgi.extender=osgi.service
loader.processor)",osgi.serviceloader;filter:="(osgi.serviceloader=or
g.apache.groovy.json.FastStringServiceFactory)";cardinality:=multiple
,osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
Provide-Capability: osgi.serviceloader;osgi.serviceloader="org.apache.
groovy.json.FastStringServiceFactory"
Fragment-Host: groovy
Bundle-Version: 2.5.6
Automatic-Module-Name: org.codehaus.groovy.json
Bundle-SymbolicName: groovy-json
Specification-Title: Groovy: a powerful, dynamic language for the JVM
Specification-Version: 2.5.6
Specification-Vendor: The Apache Software Foundation
Implementation-Title: Groovy: a powerful, dynamic language for the JVM
Implementation-Version: 2.5.6
Implementation-Vendor: The Apache Software Foundation
Bundle-Vendor: The Apache Software Foundation
Bundle-ClassPath: .
Eclipse-BuddyPolicy: dependent
DynamicImport-Package: *
Note that my pax exam tests used to work when using Groovy 2.4 (which had a
groovy-all artifact with all packages "bundled" together in this single
artifact). Also note that I cannot start the "groovy-json" artifact from
Pax Exam since then it says that "Fragment Bundles cannot be started".
What am I doing wrong and how can this be fixed?
Regards
/Johan
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.