0

I use jni to call .so (shared library).

All work fine in execution environnement.

But i woul'd like to add some unit test on them.

I has a libCBareme.so that depends on libUtil_Cade.so

I use maven2.2.1 with surefire plugin and i added in pom.xml file :

 <configuration>
             <forkMode>once</forkMode>
             <workingDirectory>target</workingDirectory>
             <argLine>-Djava.library.path=${project.basedir}/src/test/resources/om_lib/</argLine>
 </configuration>

i added System.out.println(System.getProperty("java.library.path")); and path is ok as you can see in next log.

but when i launch the test i get:

TrtBaremeTest  Time elapsed: 3.032 sec  <<< ERROR!
java.lang.UnsatisfiedLinkError: /data/tmp/pam/workspace/CTR_SCA/OutilsMetier/src/test/resources/om_lib/libCBareme.so: libUtil_CADE.so: cannot open shared object file: No such file or directory

in this directory i have

ls /data/tmp/pam/workspace/CTR_SCA/OutilsMetier/src/test/resources/om_lib/*.so /data/tmp/pam/workspace/CTR_SCA/OutilsMetier/src/test/resources/om_lib/libCBareme.so /data/tmp/pam/workspace/CTR_SCA/OutilsMetier/src/test/resources/om_lib/libUtil_CADE.so

why my unit test say cannot open shared object file ?

I wouldn't add .so in %JAVA_HOME%\bin because it's unit test so i don't want to be platform dependant.

someone have an idea to solve this?

thanks a lot

1 Answers1

0

i just try this:

     <configuration>
           <forkMode>once</forkMode>
           <workingDirectory>target</workingDirectory>
           <environmentVariables>
               <LD_LIBRARY_PATH>${project.basedir}/src/test/resources/om_lib/</LD_LIBRARY_PATH>
            </environmentVariables>
     </configuration>

and it seems to work!

but on windows it's not working, i see that i need to replace LD_LIBRARY_PATH by PATH like this:

  <configuration>
           <forkMode>once</forkMode>
           <workingDirectory>target</workingDirectory>
           <environmentVariables>
               <PATH>${project.basedir}/src/test/resources/om_lib/</PATH>
            </environmentVariables>
     </configuration>

in debug mode i see Setting environment variable [PATH]=[d:\MarcoPolo\SVN\CASTOR_trunk\CTR_SCA\OutilsMetier..\OM_LIB_DLL]

but i put a system.out.println to see my java.library.path and my path is not add like under linux :(

did someone have find an issue for this?

i post this as an answer if it could help