ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tmni <tere...@ucia.gov>
Subject Re: Defining ant target to run junit tests using dbunit
Date Tue, 20 May 2008 19:20:48 GMT

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: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Defining-ant-target-to-run-junit-tests-using-dbunit-tp17342896p17348563.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Mime
View raw message