The file you included seems to be a cross between a build.xml file and a sqlunit test file. They are actually two separate files. The build.xml will define the sqlunit task using the taskdef and invoke sqlunit using the sqlunit tag, like so:
----- build.xml
<project name="SysSql Teting" default="run-postgres-test" basedir="..">
<taskdef name="sqlunit"
classname="net.sourceforge.sqlunit.ant.SqlunitTask">
<classpath>
<pathelement location="I:\sourcefor\sqlunit\sqlunit\lib\sqlunit-4.6.jar"/>
</classpath>
</taskdef>
<target name="run-postgres-test">
<sqlunit testfile="yourfile.xml" />
</target>
</project>
and yourfile.xml will contain the actual sqlunit call, where the root element is sqlunit, etc, like so:
---- sqlunit test file
<sqlunit>
<connection>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@nls-jhelum:1521:tcweb</url>
<user>tclp</user>
<password>tclp</password>
</connection>
<test name="ADD/CVD Detail">
<sql>
<stmt>
SELECT nim_adcvd_mftr.case_ref_no ,
nim_adcvd_mftr.actual_case_no ,
nim_adcvd_mftr.case_no ,
nim_adcvd_mftr.shipper_id ,
nim_adcvd_mftr.manuf_name ,
nim_adcvd_mftr.mid ,
nim_adcvd_mftr.deposit_rate1 ,
nim_adcvd_mftr.deposit_rate2 ,
nim_adcvd_mftr.deposit_rate3 ,
nim_adcvd_mftr.eff_entry_date ,
nim_adcvd_mftr.expiry_date ,
nim_adcvd_mftr.eff_export_date
FROM nim_adcvd_mftr
WHERE NIM_ADCVD_MFTR.CASE_STATUS NOT IN ('R','E','T')
</stmt>
</sql>
<result>
<resultset id="1">
<row id="1">
<col id="1" name="nim_adcvd_mftr.case_ref_no" type="VARCHAR">1</col>
</row>
</resultset>
</result>
</test>
</sqlunit>
HTH
Sujit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Sujit.
Connection Error is resolved.
But I am getting the following error when the running the script.
run-postgres-test:
[sqlunit] *** Running SQLUnit file: sam.xml
[sqlunit] Getting connection(1)
[sqlunit] Setting up test...
[sqlunit] Running test[1]: ADD / CVD DetailsError (java.lang.NullPointerException) encountered: null
[sqlunit] sqlunit-ant: System error (java.lang.NullPointerException): null
[sqlunit] One or more SQLUnit Tests failed, see the console for details.
The SQL Statement I am using is:
SELECT nim_adcvd_mftr.case_ref_no ,
nim_adcvd_mftr.actual_case_no ,
nim_adcvd_mftr.case_no ,
nim_adcvd_mftr.shipper_id ,
nim_adcvd_mftr.manuf_name ,
nim_adcvd_mftr.mid ,
nim_adcvd_mftr.deposit_rate1 ,
nim_adcvd_mftr.deposit_rate2 ,
nim_adcvd_mftr.deposit_rate3 ,
nim_adcvd_mftr.eff_entry_date ,
nim_adcvd_mftr.expiry_date ,
nim_adcvd_mftr.eff_export_date
FROM nim_adcvd_mftr
WHERE NIM_ADCVD_MFTR.CASE_STATUS NOT IN ('R','E','T')
Thanks
Meghanath
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you using the 4.6 release, or the current CVS version. If you are using the 4.6 release, the problem looks like you are giving the connection an id but are not referring to the id in your tests. If you do not give your connection an id, it will use a pseudo id DEFAULT which you do not have to specify. The current version in CVS should give you a more meaningful error message.
-sujit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I am getting the following errro , when I tried to ran the xml file.
I:\sourcefor\sqlunit\sqlunit\tcdb_tests\sam.xml:21: The <sqlunit> type doesn't s
upport the nested "connection" element.
My XML is like this:
<?xml version="1.0"?>
<!DOCTYPE sqlunit SYSTEM "file:I:\sourcefor\sqlunit\sqlunit\docs\sqlunit.dtd">
<!--
$Id: test.xml,v 1.2 2004/06/25 23:31:00 spal Exp $
$Source: /cvsroot/sqlunit/sqlunit/test/oracle/test.xml,v $
Desc: Input specification for testing Oracle PL/SQL stored procedures.
Contributed by Satheesh Donthy.
-->
<project name="SysSql Teting" default="run-postgres-test" basedir="..">
<taskdef name="sqlunit"
classname="net.sourceforge.sqlunit.ant.SqlunitTask">
<classpath>
<pathelement location="I:\sourcefor\sqlunit\sqlunit\lib\sqlunit-4.6.jar"/>
</classpath>
</taskdef>
<target name="run-postgres-test">
<sqlunit>
<connection>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@nls-jhelum:1521:tcweb</url>
<user>tclp</user>
<password>tclp</password>
</connection>
<test name="ADD/CVD Detail">
<sql>
<stmt>
SELECT nim_adcvd_mftr.case_ref_no ,
nim_adcvd_mftr.actual_case_no ,
nim_adcvd_mftr.case_no ,
nim_adcvd_mftr.shipper_id ,
nim_adcvd_mftr.manuf_name ,
nim_adcvd_mftr.mid ,
nim_adcvd_mftr.deposit_rate1 ,
nim_adcvd_mftr.deposit_rate2 ,
nim_adcvd_mftr.deposit_rate3 ,
nim_adcvd_mftr.eff_entry_date ,
nim_adcvd_mftr.expiry_date ,
nim_adcvd_mftr.eff_export_date
FROM nim_adcvd_mftr
WHERE NIM_ADCVD_MFTR.CASE_STATUS NOT IN ('R','E','T')
</stmt>
</sql>
<result>
<resultset id="1">
<row id="1">
<col id="1" name="nim_adcvd_mftr.case_ref_no" type="VARCHAR">1</col>
</row>
</resultset>
</result>
</test>
</sqlunit>
</target>
</project>
Try removing the <project> and <target> tags. I notice those tags do not exist in the samples I looked at.
HTH,
Dave
Hi
I ran the ant script without those tags, but still it s giving as taskdef not defined ot sqlunit not defined.
But for an ant script to run you need a project.
Thanks
Meghanath
Hi Meghanath,
The file you included seems to be a cross between a build.xml file and a sqlunit test file. They are actually two separate files. The build.xml will define the sqlunit task using the taskdef and invoke sqlunit using the sqlunit tag, like so:
----- build.xml
<project name="SysSql Teting" default="run-postgres-test" basedir="..">
<taskdef name="sqlunit"
classname="net.sourceforge.sqlunit.ant.SqlunitTask">
<classpath>
<pathelement location="I:\sourcefor\sqlunit\sqlunit\lib\sqlunit-4.6.jar"/>
</classpath>
</taskdef>
<target name="run-postgres-test">
<sqlunit testfile="yourfile.xml" />
</target>
</project>
and yourfile.xml will contain the actual sqlunit call, where the root element is sqlunit, etc, like so:
---- sqlunit test file
<sqlunit>
<connection>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@nls-jhelum:1521:tcweb</url>
<user>tclp</user>
<password>tclp</password>
</connection>
<test name="ADD/CVD Detail">
<sql>
<stmt>
SELECT nim_adcvd_mftr.case_ref_no ,
nim_adcvd_mftr.actual_case_no ,
nim_adcvd_mftr.case_no ,
nim_adcvd_mftr.shipper_id ,
nim_adcvd_mftr.manuf_name ,
nim_adcvd_mftr.mid ,
nim_adcvd_mftr.deposit_rate1 ,
nim_adcvd_mftr.deposit_rate2 ,
nim_adcvd_mftr.deposit_rate3 ,
nim_adcvd_mftr.eff_entry_date ,
nim_adcvd_mftr.expiry_date ,
nim_adcvd_mftr.eff_export_date
FROM nim_adcvd_mftr
WHERE NIM_ADCVD_MFTR.CASE_STATUS NOT IN ('R','E','T')
</stmt>
</sql>
<result>
<resultset id="1">
<row id="1">
<col id="1" name="nim_adcvd_mftr.case_ref_no" type="VARCHAR">1</col>
</row>
</resultset>
</result>
</test>
</sqlunit>
HTH
Sujit
Hi
Thanks Sujit.
Connection Error is resolved.
But I am getting the following error when the running the script.
run-postgres-test:
[sqlunit] *** Running SQLUnit file: sam.xml
[sqlunit] Getting connection(1)
[sqlunit] Setting up test...
[sqlunit] Running test[1]: ADD / CVD DetailsError (java.lang.NullPointerException) encountered: null
[sqlunit] sqlunit-ant: System error (java.lang.NullPointerException): null
[sqlunit] One or more SQLUnit Tests failed, see the console for details.
The SQL Statement I am using is:
SELECT nim_adcvd_mftr.case_ref_no ,
nim_adcvd_mftr.actual_case_no ,
nim_adcvd_mftr.case_no ,
nim_adcvd_mftr.shipper_id ,
nim_adcvd_mftr.manuf_name ,
nim_adcvd_mftr.mid ,
nim_adcvd_mftr.deposit_rate1 ,
nim_adcvd_mftr.deposit_rate2 ,
nim_adcvd_mftr.deposit_rate3 ,
nim_adcvd_mftr.eff_entry_date ,
nim_adcvd_mftr.expiry_date ,
nim_adcvd_mftr.eff_export_date
FROM nim_adcvd_mftr
WHERE NIM_ADCVD_MFTR.CASE_STATUS NOT IN ('R','E','T')
Thanks
Meghanath
Hi Meghanath,
Are you using the 4.6 release, or the current CVS version. If you are using the 4.6 release, the problem looks like you are giving the connection an id but are not referring to the id in your tests. If you do not give your connection an id, it will use a pseudo id DEFAULT which you do not have to specify. The current version in CVS should give you a more meaningful error message.
-sujit