Ihr Spezialist für komplexe IT-Systeme
 

The Oracle ADF Toystore uses several Database Tables to retrieve data about the products and store information about customers and orders. Therefore the testcases of the next chapters will modify or add data within that tables. To check and handle that changes within our testcases we are going to use DBUnit [DBUnit] which was developt to adress exactly that purpose.

The picture above shows a few important tables of the ADF Toystore schema. We have to handle several different jobs:

  • Initialize that tables to provide a clean basis for the testcases.
  • After our tests have run we need DBUnit to compare the tables with an reference, to see if the test values are reflected it the tables as we want it to be.
  • Export the tables to become the initial state or the reference used to check against.

DBUnit can also be used as an extension to the popular build tool ant. So we will define several targets to implement this jobs.


<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE project [
  <!ATTLIST dbunit
    driver CDATA "oracle.jdbc.driver.OracleDriver" 
    url    CDATA "jdbc:oracle:thin:@//192.168.1.70:1521/B02" 
    userid CDATA "toystore" 
    password CDATA "toystore" 
    datatypeFactory CDATA "org.dbunit.ext.oracle.OracleDataTypeFactory"
  >
]>

<project name="MyDBUnitSampleTest" basedir="." default="main">

  <property name="oracle.home" value="/opt/oracle/ora10g"/>

  <path id="task.path">
    <pathelement location="${basedir}/dbunit-2.1.jar"/>
    <fileset dir="${oracle.home}" includes="jdbc/lib/*.jar"/>
  </path>
 
  <taskdef name="dbunit" 
           classname="org.dbunit.ant.DbUnitTask" 
           classpathref="task.path"/>

  <target name="main">
  </target>
</project>

The above ant file gives you the outline. We will go and insert our targets in the following sections.