how to specify dll file as dependency to maven runtime

When running my test cases (using mvn test), my test case fails; because one of the library I use internally calls a dll file. My test case fails, saying the file is not in java library path. Below is my pom file and test output (from mvn test). i copied the dll file to src/test/resource but it didnt help

<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${artifactId}-${version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<!--  <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> -->
<testSourceDirectory>src/test</testSourceDirectory>
<resources>
  <resource>
    <directory>src/main/resources</directory>
  </resource>
</resources>
<testResources>
  <testResource>
    <directory>src/test/resources</directory>
  </testResource>
</testResources>

 <pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.16</version>
    </plugin>
  </plugins>
</pluginManagement>


T E S T S
1 [main] DEBUG Sigar  - no sigar-amd64-winnt.dll in java.library.path
 org.hyperic.sigar.SigarException: no sigar-amd64-winnt.dll in java.library.path
    at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
    at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
    at org.hyperic.sigar.cmd.Shell.<init>(Shell.java:50)
    at org.hyperic.sigar.cmd.SigarCommandBase.<init>(SigarCommandBase.java:75)
    at com.harmonia.cbm.dataaquisition.pal.CpuInfoTest.<init>(CpuInfoTest.java:41)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:357)
    at java.lang.Class.newInstance(Class.java:310)
    at org.apache.maven.surefire.junit.PojoTestSet.<init>(PojoTestSet.java:63)
    at    rg.apache.maven.surefire.junit.JUnit3Provider.createTestSet(JUnit3Provider.java:117)
    at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(Fork
  edBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

Answers


Basically either need to put your DLL file's path in Windows' %PATH% variable, or explicitly set it using Maven's Surefire plugin as explained in this post since you are getting this error in TEST phase.


Need Your Help

Knockoutjs remove multiple by selecting checkbox

javascript jquery knockout.js

I have a list of "assets" that I am displaying using foreach bind.

How to unit test business rules?

unit-testing business-rules

I need a unit test to make sure I am accumulating vacation hours properly. But vacation hours accumulate according to a business rule, if the rule changes, then the unit test breaks.