[PAX-EXAM] Unknown protocol: wrap

497 views
Skip to first unread message

kai.scho...@gmail.com

unread,
Jul 22, 2015, 6:55:18 PM7/22/15
to OPS4J
Hi,

I'm trying to setup a test case using Pax-Exam with the Karaf container. When I start the test, I get an exception stating that the "wrap" protocol is unknown. I'm using "wrappedBundle" to install hamcrest-library into the container:

wrappedBundle(maven().groupId("org.hamcrest").artifactId("hamcrest-library").version("1.3"))

If I omit this line and remove all Hamcrest matchers from my test, then container startup is working.

These are my Pax-Exam related Maven dependencies:

<dependency>
   
<groupId>org.ops4j.pax.exam</groupId>
   
<artifactId>pax-exam-junit4</artifactId>
   
<version>${pax-exam.version}</version>
   
<scope>test</scope>
</dependency>
<dependency>
   
<groupId>org.ops4j.pax.url</groupId>
   
<artifactId>pax-url-wrap</artifactId>
   
<version>${pax-url.version}</version>
   
<scope>test</scope>
</dependency>
<dependency>
   
<groupId>org.ops4j.pax.url</groupId>
   
<artifactId>pax-url-aether</artifactId>
   
<version>${pax-url.version}</version>
   
<scope>test</scope>
</dependency>
<dependency>
   
<groupId>org.ops4j.pax.exam</groupId>
   
<artifactId>pax-exam-container-karaf</artifactId>
   
<version>${pax-exam.version}</version>
   
<scope>test</scope>
</dependency>


pax-exam.version is 4.5.0
and
pax-url.version is 2.4.1

Am I missing something?

Greetings,

Kai

Oliver Lietz

unread,
Jul 23, 2015, 1:55:29 AM7/23/15
to op...@googlegroups.com
On Wednesday 22 July 2015 15:55:18 kai.scho...@gmail.com wrote:
> Hi,

hi Kai,

> I'm trying to setup a test case using Pax-Exam with the Karaf container.
> When I start the test, I get an exception stating that the "wrap" protocol
> is unknown. I'm using "wrappedBundle" to install hamcrest-library into the
> container:
>
> wrappedBundle(maven().groupId("org.hamcrest").artifactId("hamcrest-library")
> .version("1.3"))
>
> If I omit this line and remove all Hamcrest matchers from my test, then
> container startup is working.
>
> These are my Pax-Exam related Maven dependencies:
>
[...]
>
>
> pax-exam.version is 4.5.0
> and
> pax-url.version is 2.4.1
>
> Am I missing something?

assuming you are using Karaf 4 you need the wrap feature, see SLING-4412.
https://issues.apache.org/jira/browse/SLING-4412

Regards,
O.

> Greetings,
>
> Kai

kai.scho...@gmail.com

unread,
Jul 23, 2015, 9:29:41 AM7/23/15
to OPS4J, in...@oliverlietz.de
Hi Oliver,

thanks for the reply. Yes, I'm using Karaf 4.0.0. My Pax-Exam test configuration looks like this:

@Configuration
public Option[] configuration() {

   
final MavenArtifactUrlReference karafUrl =
        maven
()
       
.groupId("org.apache.karaf")
       
.artifactId("apache-karaf")
       
.version("4.0.0")
       
.type("tar.gz");
   
   
final MavenUrlReference karafStandardRepo =
        maven
()
       
.groupId("org.apache.karaf.features")
       
.artifactId("standard")
       
.version("4.0.0")
       
.classifier("features")
       
.type("xml");
   
   
return options(
        karafDistributionConfiguration
().frameworkUrl(karafUrl).unpackDirectory(new File("target/pax-exam/karaf")).useDeployFolder(false),
        features
(karafStandardRepo, "scr"),
        features
(karafStandardRepo, "wrap"),
       
// ...

        wrappedBundle
(maven().groupId("org.hamcrest").artifactId("hamcrest-library").version("1.3"))

   
);
}


I thought features(karafStandardRepo, "wrap") should do the trick but the error remains.

Greetings,

Kai

Oliver Lietz

unread,
Jul 23, 2015, 11:54:50 AM7/23/15
to op...@googlegroups.com
On Thursday 23 July 2015 06:29:40 kai.scho...@gmail.com wrote:
> Hi Oliver,

hi,
look at https://github.com/sling-git/sling/commit/23d368fe285f300b987a9cdf0837e7f3630230df where Guillaume
fixed the issue with wrap. That should do the trick for you also.

Regards,
O.

> Greetings,
>
> Kai
[...]

Achim Nierbeck

unread,
Jul 23, 2015, 2:03:10 PM7/23/15
to op...@googlegroups.com
Hi, 

actually there is a slightly better solution to it. 
As your feature does have a requirement for the wrap feature, just declare it as is. 
With adding the following to your own feature: 

<feature prerequisite="true">wrap</feature>

That way you make sure the wrap feature is installed before your own features. This is
also helpful for the Karaf ITest since all features declared in this test are bootfeatures right away. 

regards, Achim 



--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
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 ops4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

kai.scho...@gmail.com

unread,
Jul 23, 2015, 5:42:35 PM7/23/15
to OPS4J, bcan...@googlemail.com
Hi Oliver and Achim.

The wrap feature is already listed as a boot feature in org.apache.karaf.features.cfg in Karaf 4.0.0, so I don't think that Guillaume's fix is applicable. Same for Achims suggestion with the feature descriptor. Nevertheless, I'll try both and let you know the results.

Thanks,

Kai

Achim Nierbeck

unread,
Jul 23, 2015, 5:45:43 PM7/23/15
to kai.scho...@gmail.com, OPS4J
Actually as I already tried to point out. 
If you have it in your configuration of the test, the dependency isn't resolved as such. 
This is due to how features are installed in the test-container. 
With Pax-Exam all features configured in the Test are installed as boot-features. 
With the feature dependency and the marker prerequesit, the feature resolver of Karaf knows it needs to actually install that feature before it is able to start to resolve the rest of that feature. 

regards, Achim 

kai.scho...@gmail.com

unread,
Aug 5, 2015, 4:21:47 PM8/5/15
to OPS4J, kai.scho...@gmail.com
After a break, I'm back trying to get my test running.

Thanks for the hint, Achim. I've overlooked it in your first post. Do you know why Pax-Exam installs all features as boot features? Is there a compelling reason for that?

The problem with the missing wrap feature is gone, but now I'm having some other dependency problems. For some reason, Pax-Exam installs JUnit and Hamcrest-Core as test dependencies, even if I omit the "CoreOptions.junitBundles()" option. I'm using some matchers from Hamcrest-Library in my tests, but since there's a split package in Core/Library I can't just specify Hamcrest-Library as a dependency. I'd use Hamcrest-All, but its no use if I can't get rid of the Pax version of Hamcrest-Core.

For now, I think I'll just do without Hamcrest. I find it quite annoying, that it's such a hassle to get this running. If someone has managed to setup a test using the Karaf test container and Hamcrest matchers, please let me know how.

Best regards,

Kai
Reply all
Reply to author
Forward
0 new messages