You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "William E. Kempf" <we...@cox.net> on 2003/01/17 14:26:38 UTC

JUnit and bootclasspath

We've got some JUnit tasks that work fine on Windows, but fail on Linux. 
On Linux they complain about not being able to find various classes we've
added to the "pluggable look and feel".  I *believe* the issue can be
found at the following site:
http://java.sun.com/products/jfc/tsc/articles/sce/.  To quote: "The only
problem we encountered during our work on the project occurred because
JDKTM 1.2 is currently unable to load custom look-and-feels from the
CLASSPATH, so look-and-feel classes must be placed on the BOOTCLASSPATH.
This is a bug in JDK 1.2 which Sun is aware of, and which will get fixed
in the upcoming JDK 1.2.2 release."

OK, I don't mind specififying the "bootclasspath" if that will help here,
but how do I go about doing this in an Ant script using a classpath
variable?

William E. Kempf
wekempf@cox.net



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JUnit and bootclasspath

Posted by "William E. Kempf" <we...@cox.net>.
Stefan Bodewig said:
> On Fri, 17 Jan 2003, William E. Kempf <we...@cox.net> wrote:
>
>>> If you are forking <junit>, you could specify the -bootclasspath
>>> option as <jvmarg>.  Adding <bootclasspath> to side <classpath> to
>>> the JUnit task could be a very valid enhancement request.
>>
>> Part of my question is how to use a classpathref here.
>
> <property name="path.as.property" refid="your-ref"/>
> <junit fork="true"...>
>   ...
>   <jvmarg value="-Xbootclasspath:${path.as.property}"/>
> </junit>

OK, this is probably now much more of a general Java question than Ant
related, but since it has to do with the original question and answer...

Here's how I supply the bootclasspath:

<property name="bootclasspath" refid="mylib.classpath" />
<junit printsummary="no"
       errorProperty="test.failed"
       failureProperty="test.failed"
       fork="yes">
        <classpath refid="mylib.classpath"/>
        <jvmarg value="-Xbootclasspath:${bootclasspath}" />
        <sysproperty key="docs.dir" value="${junit.data.dir}" />
        <sysproperty key="index.dir" value="${junit.data.dir}/index" />
        <formatter type="xml" />
        <formatter type="brief" usefile="false" />
        <test name="${testcase}" if="testcase" />
        <batchtest todir="${junit.data.dir}" unless="testcase">
                <fileset dir="${build.dir}" includes="**/*Test.class" />
        </batchtest>
</junit>

And the result is:

    [junit] Error occurred during initialization of VM
    [junit] java/lang/NoClassDefFoundError: java/lang/Object
    [junit] TEST test.com.mylib.swing.DefaultMyJButtonTest FAILED

So, obviously setting the bootclasspath has issues, since it now doesn't
contain the normal path elements.  But what are the normal bootclasspath
elements?





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JUnit and bootclasspath

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 17 Jan 2003, William E. Kempf <we...@cox.net> wrote:

>> If you are forking <junit>, you could specify the -bootclasspath
>> option as <jvmarg>.  Adding <bootclasspath> to side <classpath> to
>> the JUnit task could be a very valid enhancement request.
> 
> Part of my question is how to use a classpathref here.

<property name="path.as.property" refid="your-ref"/>
<junit fork="true"...>
  ...
  <jvmarg value="-Xbootclasspath:${path.as.property}"/>
</junit>

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JUnit and bootclasspath

Posted by "William E. Kempf" <we...@cox.net>.
Stefan Bodewig said:
> On Fri, 17 Jan 2003, William E. Kempf <we...@cox.net> wrote:
>
>> OK, I don't mind specififying the "bootclasspath" if that will help
>> here, but how do I go about doing this in an Ant script using a
>> classpath variable?
>
> First of all, if you are not forking <junit>, it has to be on the
> bootclasspath of the VM running Ant.  This can be done by specifying
> java's -bootclasspath option in the ANT_OPTS environment variable.
>
> If you are forking <junit>, you could specify the -bootclasspath
> option as <jvmarg>.  Adding <bootclasspath> to side <classpath> to the
> JUnit task could be a very valid enhancement request.

Part of my question is how to use a classpathref here.  This is the
current code:

<junit printsummary="no"
       errorProperty="test.failed"
       failureProperty="test.failed"
       fork="yes">
	<classpath refid="mylib.classpath"/>
	<sysproperty key="docs.dir" value="${junit.data.dir}" />
	<sysproperty key="index.dir" value="${junit.data.dir}/index" />
	<formatter type="xml" />
	<formatter type="brief" usefile="false" />
	<test name="${testcase}" if="testcase" />
	<batchtest todir="${junit.data.dir}" unless="testcase">
		<fileset dir="${build.dir}" includes="**/*Test.class" />
	</batchtest>
</junit>

How do I reuse the "mylib.classpath" here?

<junit printsummary="no"
       errorProperty="test.failed"
       failureProperty="test.failed"
       fork="yes">
	<classpath refid="mylib.classpath"/>
	<jvmarg value="-bootclasspath=...

William E. Kempf
wekempf@cox.net



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JUnit and bootclasspath

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 17 Jan 2003, William E. Kempf <we...@cox.net> wrote:

> OK, I don't mind specififying the "bootclasspath" if that will help
> here, but how do I go about doing this in an Ant script using a
> classpath variable?

First of all, if you are not forking <junit>, it has to be on the
bootclasspath of the VM running Ant.  This can be done by specifying
java's -bootclasspath option in the ANT_OPTS environment variable.

If you are forking <junit>, you could specify the -bootclasspath
option as <jvmarg>.  Adding <bootclasspath> to side <classpath> to the
JUnit task could be a very valid enhancement request.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>