Well, let's go step by step over the classpath definitions that you can
find in the example I attached a few mails ago.
The first classpath definition is required to tell the <sql> task where
to find the implementation of the mysql driver (as far as I know, you
did that successfully because the oracle error disappeared).
The second classpath definition is required to define the JUnit task
(<taskdef> ant task), and also seems to be alright.
Finally, the third classpath definition is required to tell the JUnit
task, where will find the required classes to execute the tests. This is
the classpath definition that you possibly made wrong. You can find this
classpath definition just below the line that reads <junit
haltonfailure...>.
Check whether you have these lines or not. Maybe, if you have these
lines written properly and it's still failing, could be because you
failed listing the all the classes that your tests require to be executed.
To include a whole folder or part of it to your classpath, you can use
as much <fileset> tags as you want (to reference a set of libraries that
are in the same folder) or <pathelement> tags to specify single
libraries. I advise you to place all the required jars into one single
folder and reference all of them at once by using the <fileset> tag.
<property name="lib" value="path/to/directory/containing/jars" />
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
As you can see in the source code from above, I point the fileset element to
the folder where all the required jars are enclosed and then , I include only
those files that match the specified pattern (*.jar) to the classpath.
Tip: If your .jar files where distributed into several folders hanging from a common root (As
you can see below), use the following expression <include name="**/*.jar" /> to
tell ant that the required files could be found anywhere contained below that point.
lib (root)
|
|-> sub-lib1
| |
| |-> file1.jar
| |
| |-> file2.jar
|-> sub-lib2
|
|-> file3.jar
Regards.
Carlos
tmni escribió:
I thought I had included the junit.jar in the classpath, but maybe it's
defined improperly.
I didn't see it in your sample, where do you define that part of the
classpath? I think I'm
getting confused about the different places the classpaths are defined, and
how to list
multiple files/directories...
Carlos Alonso-2 wrote:
Have you included the java junit.jar library into the classpath provided
for the junit task?
The TestListener class is actually included in that .jar file.
Regards.
Carlos
tmni escribió:
I appreciate both attempts to help.
I had already viewed that other web page and tried to follow it. It
doesn't
provide quite enough
detail for me.
I did try using some of the sample code provided. I was able to
eliminate
the error about not
finding the oracle driver. But now when I try to include a junit
taskdef, I
get a classpath error that
a class needed by JUnitTask (TestListener) is not found. As far as I can
tell, it is on the classpath, so no
idea what this all about. I tried a couple ways of including it in the
classpath within the build.xml file.
Sure would be nice if someone had a sample who had also written junit
tests
using dbunit for a web app
using Hibernate and Oracle. I simply cannot get this to work;very
frustrating...
Carlos Alonso-2 wrote:
Hi tmni,
About the authentication exception that you're getting, I cannot guess
neither cause nor solution, but I think the following source code could
be helpful.
The first point is the problem you're getting with the oracle driver
load. I think that the point is that you have not defined where Ant can
find the class that implements the driver. I've never used Oracle, but I
don't think it differs much on mysql. In the following source code you
can check that the .jar file where the driver is implemented is directly
pointed out by the classpath argument, so try adding the .jar file to
the classpath.
<sql
driver = "com.mysql.jdbc.Driver"
password = "pass"
url = "jdbc:mysql://127.0.0.1/"
userid = "pass"
autocommit = "true"
classpath = "${lib}/mysql-connector-java-5.0.4-bin.jar"
>
.
.
.
</sql>
Regarding now to the second problem to set the tests you want to be
executed, have a look at the code below, instead of dbunit I use Junit
as you can see, but I don't think they are very different.
As for the previous situation, you'll have to define a classpath from
which your tests will be compiled, and then, include them in a <fileset>
resource into the <batchtest> task.
The formatter elements that you can see over specify the output that the
junit task will produce.
<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
classpath="${scripts}/tools/ant-junit.jar"
/>
<junit haltonfailure="no" printsummary="on" fork="yes">
<classpath >
<pathelement location="${build}"/>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml" />
<batchtest todir="${results}" >
<fileset dir="${src}" includes="**/*Tests/Test*.java"/>
</batchtest>
</junit>
I hope it may help you.
Regards.
Carlos
tmni escribió:
I am relatively new to ant and am having trouble setting up a target to
run a
series of junit tests.
These tests all run fine when I launch them via eclipse. But if I try
to
run ant directly via command prompt, I get errors. First, I was
getting
error like:
Error 'Unexpected failure during bean definition parsing in resource
URL
[file:spring-misc-junit.xml] at:
Bean 'mailSender'; nested exception is java.lang.SecurityException:
class
“javax.mail.AuthenticationFailedException”’s signer information does
not
match signer information of other classes in the same package.
I thought it might have something to do with authenticating to
database,
so
tried adding the following
dbunit info. I got an error that there must be at least 1 step in a
dbunit
task. I tried adding a task to do
an insert, but don't know why this would be necessary since the test
themselves set up the test data, accessing a test data xml file. Even
with
that change, I get error that oracle driver cannot be loaded.
The tests use dbunit and the underlying database is Oracle (accessed
via
Hibernate in application).
I can't figure out how to define the test target and I cannot find a
sample
that does this. Does
anyone have a sample ant build file that runs junit tests that use
dbunit/hibernate/oracle combination??
<target name="test2" depends="init,compile">
<taskdef classpathref="project.class.path" name="dbunit"
classname="org.dbunit.ant.DbUnitTask" />
<dbunit driver="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@server:port:dbname"
userid="me"
password="password">
</dbunit>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]