You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Marco Westermann <mw...@intersales.de> on 2015/07/31 13:59:09 UTC
get bundle version in pax exam test
Hi,
I try to test if my feature works as expected via pax exam.
Imagine my project structure as follows:
|
|-my.bundle
|-features
|-itests
|-pom.xml
so I have a parent pom which defines the version for all child poms. the
feature contains the installation of the my.bundle with version
${project.version}. In the itest I would like to test if the correct
version of my.bundle is installed without errors.
therefor I install the feature in the configure method and now I would
like to test if the bundle is installed. I got it working to test if the
bundle is installed but I struggle around with the correct version as I
don't know the correct version in the test. What I would like to do is:
get the ${project.version} value in the test method. First I tried to
provide it via system-property via surefire configuration, but I guess
the system property is not available in karaf container when executing
the test.
The next approach was to get the test bundle version via:
bundleContext.getBundle().getVersion().toString() but the provisioning
bundle created by pax exam always has the version 0.0.0
Is there another way to determine the correct version?
best regards, Marco
--
++ Business-Software aus einer Hand ++
++ Internet, Warenwirtschaft, Linux, Virtualisierung ++
http://www.intersales.de
http://www.eisxen.org
http://www.tarantella-partner.de
http://www.medisales.de
http://www.eisfair.net
interSales AG Internet Commerce
Weinsbergstr. 190
50825 Köln
Tel 02 21 - 27 90 50
Fax 02 21 - 27 90 517
Mail isinfo@intersales.de
Mail mw@intersales.de
Web www.intersales.de
Handelsregister Köln HR B 30904
Ust.-Id.: DE199672015
Finanzamt Köln-Nord. UstID: nicht vergeben
Aufsichtsratsvorsitzender: Michael Hippler
Vorstand: Andrej Radonic, Peter Zander
Re: get bundle version in pax exam test
Posted by Łukasz Dywicki <lu...@code-house.org>.
If you work with features then declare its descriptor as dependency to itests:
<dependency>
<groupId>org.code-house.webconsole</groupId>
<artifactId>features</artifactId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
Then use servicemix-depends plugin to drop all the versions from maven into property file used by pax-exam:
<build>
<plugins>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-depends-file</id>
<goals>
<goal>generate-depends-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
At the end you can reference artifact in your tests without any problem:
@Configuration
public Option[] config() {
String featuresUrl = maven("org.code-house.webconsole", "features").classifier("features").type("xml").versionAsInProject().getURL();
String karafVersion = MavenUtils.getArtifactVersion("org.apache.karaf", "apache-karaf");
MavenArtifactUrlReference frameworkURL = maven("org.apache.karaf", "apache-karaf").type("zip").version(karafVersion);
return new Option[]{
karafDistributionConfiguration().karafVersion(karafVersion).frameworkUrl(frameworkURL),
editConfigurationFileExtend("etc/org.apache.karaf.features.cfg", "featuresRepositories", "," + featuresUrl),
editConfigurationFileExtend("etc/org.ops4j.pax.url.mvn.cfg", "org.ops4j.pax.url.mvn.repositories", "," +
"additional project repositories"),
};
}
Kind regards,
Lukasz
—
Apache Karaf commiter & PMC
Code-House http://code-house.org <http://code-house.org/>
Blog http://dywicki.pl <http://dywicki.pl/>
Twitter @ldywicki
> Wiadomość napisana przez Marco Westermann <mw...@intersales.de> w dniu 31 lip 2015, o godz. 13:59:
>
> Hi,
>
> I try to test if my feature works as expected via pax exam.
>
> Imagine my project structure as follows:
>
> |
> |-my.bundle
> |-features
> |-itests
> |-pom.xml
>
>
> so I have a parent pom which defines the version for all child poms. the feature contains the installation of the my.bundle with version ${project.version}. In the itest I would like to test if the correct version of my.bundle is installed without errors.
>
> therefor I install the feature in the configure method and now I would like to test if the bundle is installed. I got it working to test if the bundle is installed but I struggle around with the correct version as I don't know the correct version in the test. What I would like to do is: get the ${project.version} value in the test method. First I tried to provide it via system-property via surefire configuration, but I guess the system property is not available in karaf container when executing the test.
>
> The next approach was to get the test bundle version via:
>
> bundleContext.getBundle().getVersion().toString() but the provisioning bundle created by pax exam always has the version 0.0.0
>
>
> Is there another way to determine the correct version?
>
> best regards, Marco
>
> --
> ++ Business-Software aus einer Hand ++
> ++ Internet, Warenwirtschaft, Linux, Virtualisierung ++
> http://www.intersales.de <http://www.intersales.de/>
> http://www.eisxen.org <http://www.eisxen.org/>
> http://www.tarantella-partner.de <http://www.tarantella-partner.de/>
> http://www.medisales.de <http://www.medisales.de/>
> http://www.eisfair.net <http://www.eisfair.net/>
>
> interSales AG Internet Commerce
> Weinsbergstr. 190
> 50825 Köln
>
> Tel 02 21 - 27 90 50
> Fax 02 21 - 27 90 517
> Mail isinfo@intersales.de <ma...@intersales.de>
> Mail mw@intersales.de <ma...@intersales.de>
> Web www.intersales.de <http://www.intersales.de/>
>
> Handelsregister Köln HR B 30904
> Ust.-Id.: DE199672015
> Finanzamt Köln-Nord. UstID: nicht vergeben
> Aufsichtsratsvorsitzender: Michael Hippler
> Vorstand: Andrej Radonic, Peter Zander