ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Doyle <jdo...@iso-ne.com>
Subject Running junit tests that access EJBs
Date Tue, 10 Apr 2001 20:18:38 GMT
Hi,
    I looked on this list for some suggestions about how to use Ant to
manage unit tests for EJBs,
and it seemed that a couple people had the approach of running the
server in one Ant instance (using wlrun) and running the junit test in
another Ant instance.  I've got the server part working fine, but I'm
having trouble with my client.

    I can run the JUnit test from the command line with no problem.  I
can also run it with a forked java task, like this:
  <property name="jdbc.driver.class.path"
value="c:/JavaTools/Oracle/JDBCdrivers/oracle8.1.7-jdk1.2/lib/classes12.zip"/>

  <property name="weblogic.home"
value="c:/JavaTools/weblogic/weblogic51"/>
  <property name="weblogic.class.path"
value="${jdbc.driver.class.path};${weblogic.home}/lib/weblogic510sp8.jar;${weblogic.home}/classes;${weblogic.home}/lib/weblogicaux.jar"/>

  <target name="test.ejb.java.fork" depends="compile">
    <java classname="junit.textui.TestRunner" fork="yes">
      <sysproperty key="java.naming.provider.url"
value="t3://localhost:7001"/>
      <arg value="PowerSystemEjbTest"/>
      <classpath
path="${basedir};c:/JavaTools/Junit/junit3.2/junit.jar;${weblogic.class.path}"/>

    </java>
  </target>

But I would like to use the junit task, which I use for my other unit
tests, and that doesn't work unless I put weblogic in my CLASSPATH for
Ant.  I've tried:
  <target name="test.ejb.cp" depends="compile">
    <junit haltonfailure="yes">
      <sysproperty key="java.naming.provider.url"
value="t3://localhost:7001"/>
      <classpath path="${weblogic.class.path}"/>
      <batchtest>
        <formatter type="plain" usefile="no"/>
        <fileset dir="${basedir}">
          <include name="PowerSystemEjbTest.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>
but it throws a "java.lang.NoClassDefFoundError:
javax/ejb/CreateException".
I've also tried eliminating the classpath element, and it throws a
"javax.naming.NoInitialContextException,
java.lang.ClassNotFoundException:
weblogic.jndi.WLInitialContextFactory".

If I put my weblogic classpath into the Ant classpath, it works OK, but
I'd prefer to have the classpath in my build file.

So:
1) Does anybody know why the class loading is behaving the way it does?
I can dump some debugging output if it would help.
2) How are others out there running JUnit tests that use EJBs?  Do you
use a forked java task, or put weblogic in Ant's CLASSPATH, or is there
some other way?

Thanks for your help!

--
Jim Doyle
jdoyle@iso-ne.com



Mime
View raw message