Object Specialties

This section contains a set of loosly coupled information that will not take a complete section on its own.

Special Keywords

Special Keywords
NameDescription
!NULL!Used to specify that a certain field/object should be null
!EMPTY!Used to specify an empty String object. - Restricted to type String!
!BLANK!Used to specify a blank String (one Space char). - Restricted to type String!
Here is an example
<obj id="myExample" type="junitx.ddtunit.resources.SimpleVO">!NULL!</obj>
will initialize the instance of SimpleVO with null. So use special key '!NULL! every time you want to explicitly assign null to an object.

Using Simple Date

Processing information about date - java.util.Date, java.sql.Date, java.text.Date
Three examples

<obj id="myDate" hint="date" type="java.util.Date">01.05.2005 00:00:00.000</obj>
<obj id="myDate" hint="date" type="date">01.05.2005 00:00:00</obj>
<obj id="myDate" hint="date" type="udate">01.05.2005</obj>
The predefined date formats are specified in the resource /junitx/ddtunit/ddtunitConfig.properties.
For specifiing your own format the new xml attributes 'dateformat' and 'locale' were introduced. A simple example
<obj id="myDate" hint="date" type="date" dateformat="EEE MMM dd HH:mm:ss zzz yyyy" 
  locale="en_US"> Thu Dec 06 12:15:00 CET 2007</obj>
More examples can be found in the test junitx.ddtunit.functest.ProcessDateDataTest. Because java.util.Date implements java.lang.Comparable the DDTUnit assert actions on this type can be used.

To specify an actual date or time new keywords are introduced

Special Keywords
NameDescription
!SYSDATE!Specifies the actual date of test execution, time is set to zero
!SYSTIME!Specifies the actual date and time of test execution.

Using Selfdefined Date Formats

Because there were a few requests on special date format support DDTUnit it is now possible to process the following example test as used in the functional testing suite of DDTUnit:

   <test id="readFreeDate">
    <objs>
     <obj id="myDate" hint="date" type="date" dateformat="EEE MMM dd HH:mm:ss zzz yyyy">Thu Dec 06 10:11:12 CET 2007</obj>
    </objs>
    <asserts>
     <assert id="result" hint="date" type="date" action="isEqual">06.12.2007 10:11:12</assert>
    </asserts>
   </test>
   <test id="readFreeDateWithLocale">
    <objs>
     <obj id="myDate" hint="date" type="date" dateformat="EE MMM dd HH:mm:ss zzz yyyy" locale="de_DE">Di Dez 06 10:11:12 MET 2007</obj>
    </objs> 
    <asserts>
     <assert id="result" hint="date" type="date" action="isEqual">06.12.2007 10:11:12</assert>
    </asserts>
   </test>

This date format is interpreted during parse time and instanciates the requested Date.

sf logo