ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From volker.augus...@allianz.de
Subject Antwort: <junit> fails when using JDK 1.4.2 but works with JDK 1.4.1?
Date Mon, 19 Jan 2004 13:28:20 GMT

Solved the problem myself. The key to success is to use the reloading
option in the junit task:

      <target name="test" depends="compile" description="regression test -
reports will be printed on the console">
        <junit fork="no" printsummary="no" haltonfailure="no" reloading
="false" >
          <batchtest fork="no" todir="${test.reports}" >
            <fileset dir="${build}">
              <include name="**/*Test.class" />
              <exclude name="com/allianz/mcs/domain/DomainTest.class" />
            </fileset>
          </batchtest>
          <formatter type="plain" usefile="false" />
          <classpath refid="test.classpath" />
        </junit>
      </target>

Also, I managed to get it to work by placing the jar files in ANT_HOME\lib
and using <taskdef ...>.

However, I first had two internal test targets both of which used classes
which loaded specified dll. I then had another test target which depended
on both of these. In this situation the first internal test succeeds but
the second fails because it tries to load its own dll it seems. The
"solution" was to create a third internal test target which contained the
test setup for *both* previous internal tests. However, this is only
possible with simple setups and defeats the whole purpose of the dependency
stuff.
Maybe the classloaders should somehow be unloaded that the dll can be
loaded again?



|---------+----------------------------------------->
|         |           Volker                        |
|         |           Augustin/HV/AGR/Allianz-Sach@A|
|         |           llianz-Sach                   |
|         |                                         |
|         |           19.01.04 12:04                |
|         |           Bitte antworten an "Ant Users |
|         |           List"                         |
|         |                                         |
|---------+----------------------------------------->
  >-------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                      
                                        |
  |        An:      user@ant.apache.org                                                  
                                        |
  |        Kopie:                                                                        
                                        |
  |        Thema:   <junit> fails when using JDK 1.4.2 but works with JDK 1.4.1?   
                                              |
  >-------------------------------------------------------------------------------------------------------------------------------|



Hello,

I have the following directory structure:

c:\paramconv\
c:\paramconv\build
c:\paramconv\src

The build file which can be found below works fine with JDK 1.4.1 and ant
1.5.3 or 1.6.0.

<project name="paramconv" default="compile" basedir=".">
      <property name="src" value="src" />
      <property name="build" value="build" />
      <property name="dist" value="dist" />
      <property name="pack" value="pack" />
      <property name="test.reports" value="reports" />
      <property name="debug" value="true" />


      <path id="project.class.path">
            <pathelement path="${java.class.path}/" />
      </path>

      <path id="test.classpath">
      <pathelement path="${java.class.path}/" />
      <pathelement location="${build}" />
      </path>

      <target name="buildinit">
            <mkdir dir="${build}" />
            <copy file="resources/libraries/dflib.dll" todir="${build}" />
      </target>

      <target name="test" depends="compile" description="regression test -
reports will be printed on the console">
        <junit fork="yes" printsummary="no" haltonfailure="no">
          <batchtest fork="yes" todir="${test.reports}" >
            <fileset dir="${build}">
              <include name="**/*Test.class" />
            </fileset>
          </batchtest>
          <formatter type="plain" usefile="false" />
          <classpath refid="test.classpath" />
        </junit>
      </target>

</project>

However, after switching to JDK 1.4.2, i couldn't run the test any more.
After reading through the archive it seems the only way to solve this is to
create
c:\paramconv\jars and place junit.jar, ant-junit.jar and log4j-1.2.8.jar
there. Moreover, I had to create an extra taskdef and disallow forking.

      <taskdef name="junit" classname
="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

      <target name="test" depends="compile" description="regression test -
reports will be printed on the console">
        <junit fork="no" printsummary="no" haltonfailure="no">
          <batchtest fork="no" todir="${test.reports}" >
            <fileset dir="${build}">
              <include name="**/*Test.class" />
            </fileset>
          </batchtest>
          <formatter type="plain" usefile="false" />
          <classpath refid="test.classpath" />
        </junit>
      </target>

Now, the tests are found (though I do not really like that solution).
However, the classes which are tested load a library dflib.dll from either
c:\winnt\dflib.dll or the local directory (which is c:\paramconv\build)
when the test is run. And this library can now be loaded during the first
test. But when the second test starts, this fails with the following
exception:

    [junit] java.lang.UnsatisfiedLinkError: Native Library C:
\WINNT\dflib.dll already loaded in another classloader
    [junit]       at
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1525)
    [junit]       at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1485)
    [junit]       at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    [junit]       at java.lang.System.loadLibrary(System.java:834)
    [junit]       at lib.dflib.<clinit>(dflib.java:48)
    ....
    [junit]       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
    [junit]       at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    [junit]       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    [junit]       at java.lang.reflect.Method.invoke(Method.java:324)
    [junit]       at junit.framework.TestCase.runTest(TestCase.java:154)
    [junit]       at junit.framework.TestCase.runBare(TestCase.java:127)
    [junit]       at
junit.framework.TestResult$1.protect(TestResult.java:106)
    [junit]       at
junit.framework.TestResult.runProtected(TestResult.java:124)
    [junit]       at junit.framework.TestResult.run(TestResult.java:109)
    [junit]       at junit.framework.TestCase.run(TestCase.java:118)
    [junit]       at junit.framework.TestSuite.runTest(TestSuite.java:208)
    [junit]       at junit.framework.TestSuite.run(TestSuite.java:203)
    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:326)

    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:991)

    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:663)

    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:637)

    [junit]       at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
    [junit]       at org.apache.tools.ant.Task.perform(Task.java:401)
    [junit]       at org.apache.tools.ant.Target.execute(Target.java:338)
    [junit]       at
org.apache.tools.ant.Target.performTasks(Target.java:365)
    [junit]       at
org.apache.tools.ant.Project.executeTarget(Project.java:1237)
    [junit]       at
org.apache.tools.ant.Project.executeTargets(Project.java:1094)
    [junit]       at org.apache.tools.ant.Main.runBuild(Main.java:669)
    [junit]       at org.apache.tools.ant.Main.startAnt(Main.java:220)
    [junit]       at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
    [junit]       at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
    [junit] java.lang.UnsatisfiedLinkError: Can't load library: C:
\paramconv\dflib.dll
    [junit]       at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1459)
    [junit]       at java.lang.Runtime.load0(Runtime.java:737)
    [junit]       at java.lang.System.load(System.java:811)
    [junit]       at lib.dflib.<clinit>(dflib.java:62)
    ...
    [junit]       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
    [junit]       at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    [junit]       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    [junit]       at java.lang.reflect.Method.invoke(Method.java:324)
    [junit]       at junit.framework.TestCase.runTest(TestCase.java:154)
    [junit]       at junit.framework.TestCase.runBare(TestCase.java:127)
    [junit]       at
junit.framework.TestResult$1.protect(TestResult.java:106)
    [junit]       at
junit.framework.TestResult.runProtected(TestResult.java:124)
    [junit]       at junit.framework.TestResult.run(TestResult.java:109)
    [junit]       at junit.framework.TestCase.run(TestCase.java:118)
    [junit]       at junit.framework.TestSuite.runTest(TestSuite.java:208)
    [junit]       at junit.framework.TestSuite.run(TestSuite.java:203)
    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:326)

    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:991)

    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:663)
    [junit]       at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:637)

    [junit]       at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
    [junit]       at org.apache.tools.ant.Task.perform(Task.java:401)
    [junit]       at org.apache.tools.ant.Target.execute(Target.java:338)
    [junit]       at
org.apache.tools.ant.Target.performTasks(Target.java:365)
    [junit]       at
org.apache.tools.ant.Project.executeTarget(Project.java:1237)
    [junit]       at
org.apache.tools.ant.Project.executeTargets(Project.java:1094)
    [junit]       at org.apache.tools.ant.Main.runBuild(Main.java:669)
    [junit]       at org.apache.tools.ant.Main.startAnt(Main.java:220)
    [junit]       at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
    [junit]       at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
    [junit] Couldn't find statistics library. The library is named either
dflib.dll or dflib.so,
    [junit] depending on your operating system. Please include the library
file into your
    [junit] system path or the working directory from which you start ...

Any ideas? Also, I would be interested why the setup which worked
previously (JDK 1.4.1) does not work anymore now.

Cheers,
Volker Augustin



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org







---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message