You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Christian Eugster <c....@docuteam.ch> on 2015/03/18 11:19:19 UTC

Obtaining project path while executing a pax exam test in a karaf container

Hi, 

I want to point to a file located in a project folder in a pax-exam integration test in karaf container. While running the test, the root_path seems to change to the karaf container. Is there a direct way, how I can obtain the projects path within the test method?

Regards

Christian

Christian Eugster
Docuteam GmbH
Langacker 16
Postfach
CH-5405 Baden-Dättwil
+41 (0)56 470 03 37
c.eugster@docuteam.ch






Re: Obtaining project path while executing a pax exam test in a karaf container

Posted by Christian Eugster <c....@docuteam.ch>.
Hi Tcharl,

thank you for your response. I think I did not express my problem in the right way. Let me try again: I have a test class that runs in a karaf container. In a test method I try the following:

File file = new File("src/test/resources/a/test.file") // Notice the relative file path
template.sendBody("direct:start, file);

If I examine the absolute path of file while execution of test method with System.out.println(file.getAbsolutePath());
The I get something like: /Users/christian/Projekte/../Workspace/myproject/target/paxexam/container/12ef34ab56cd78ab90/src/test/resources/a/test.file

The absolute path changes while execution of test. So the test does not find my file. How can I ensure, that the file is recognized by the test without setting an absolute path and - if possible without something like

../../../../src/test/resources/a/test.file ?

Thanks and regards

Christian


Christian Eugster
Docuteam GmbH
Langacker 16
Postfach
CH-5405 Baden-Dättwil
+41 (0)56 470 03 37
c.eugster@docuteam.ch





> Am 18.03.2015 um 13:01 schrieb Charlie Mordant <cm...@gmail.com>:
> 
> Hi,
> 
> You can use the file: protocol to reference your file within your karaf feature. the file: with an absolute path should also work in exam.
> 
> Sample for solution 1: https://github.com/OsgiliathEnterprise/net.osgiliath.parent/blob/master/net.osgiliath.samples/net.osgiliath.hello/net.osgiliath.hello.features/src/main/resources/net.osgiliath.hello.features.xml <https://github.com/OsgiliathEnterprise/net.osgiliath.parent/blob/master/net.osgiliath.samples/net.osgiliath.hello/net.osgiliath.hello.features/src/main/resources/net.osgiliath.hello.features.xml>
> 
> Regards,
> 
> 2015-03-18 11:19 GMT+01:00 Christian Eugster <c.eugster@docuteam.ch <ma...@docuteam.ch>>:
> Hi, 
> 
> I want to point to a file located in a project folder in a pax-exam integration test in karaf container. While running the test, the root_path seems to change to the karaf container. Is there a direct way, how I can obtain the projects path within the test method?
> 
> Regards
> 
> Christian
> 
> Christian Eugster
> Docuteam GmbH
> Langacker 16
> Postfach
> CH-5405 Baden-Dättwil
> +41 (0)56 470 03 37 <tel:%2B41%20%280%2956%20470%2003%2037>
> c.eugster@docuteam.ch <ma...@docuteam.ch>
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> Charlie Mordant
> 
> Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent <https://github.com/OsgiliathEnterprise/net.osgiliath.parent>


Re: Obtaining project path while executing a pax exam test in a karaf container

Posted by Charlie Mordant <cm...@gmail.com>.
Hi,

You can use the file: protocol to reference your file within your karaf
feature. the file: with an absolute path should also work in exam.

Sample for solution 1:
https://github.com/OsgiliathEnterprise/net.osgiliath.parent/blob/master/net.osgiliath.samples/net.osgiliath.hello/net.osgiliath.hello.features/src/main/resources/net.osgiliath.hello.features.xml

Regards,

2015-03-18 11:19 GMT+01:00 Christian Eugster <c....@docuteam.ch>:

> Hi,
>
> I want to point to a file located in a project folder in a pax-exam
> integration test in karaf container. While running the test, the root_path
> seems to change to the karaf container. Is there a direct way, how I can
> obtain the projects path within the test method?
>
> Regards
>
> Christian
>
> Christian Eugster
> Docuteam GmbH
> Langacker 16
> Postfach
> CH-5405 Baden-Dättwil
> +41 (0)56 470 03 37
> c.eugster@docuteam.ch
>
>
>
>
>
>


-- 
Charlie Mordant

Full OSGI/EE stack made with Karaf:
https://github.com/OsgiliathEnterprise/net.osgiliath.parent