[jboss-cvs] jboss-seam/doc/reference/en/modules ...

Peter Muir peter at bleepbleep.org.uk
Sun Oct 7 18:22:15 EDT 2007


  User: pmuir   
  Date: 07/10/07 18:22:15

  Modified:    doc/reference/en/modules  testing.xml
  Log:
  JBSEAM-1644
  
  Revision  Changes    Path
  1.17      +61 -0     jboss-seam/doc/reference/en/modules/testing.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: testing.xml
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/doc/reference/en/modules/testing.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- testing.xml	6 Aug 2007 13:19:01 -0000	1.16
  +++ testing.xml	7 Oct 2007 22:22:15 -0000	1.17
  @@ -337,6 +337,67 @@
             </imageobject>
           </mediaobject>
           
  +        <section>
  +          <title>Integration Testing with Mock Data</title>
  +          
  +          <para>
  +            If you need to insert or clean data in your database before each 
  +            test you can use Seam's integration with DBUnit.  To do this, extend 
  +            DBUnitSeamTest rather than SeamTest.
  +         </para>
  +         
  +         <para>
  +            You need to provide a dataset for DBUnit:
  +         </para>
  +          
  +          <programlisting><![CDATA[<dataset>
  +   
  +   <ARTIST 
  +      id="1"
  +      dtype="Band"
  +      name="Pink Floyd" />
  +      
  +   <DISC
  +      id="1"
  +      name="Dark Side of the Moon"
  +      artist_id="1" />
  +      
  +</dataset>]]></programlisting>
  +
  +         <para>
  +            and tell Seam about it by overriding <literal>prepareDBUnitOperations()</literal>:
  +         </para>
  +      
  +         <programlisting><![CDATA[protected void prepareDBUnitOperations() {
  +    beforeTestOperations.add(
  +       new DataSetOperation("my/datasets/BaseData.xml")
  +    );
  + }]]></programlisting>
  + 
  +         <para>
  +           <literal>DataSetOperation</literal> defaults to <literal>DatabaseOperation.CLEAN_INSERT</literal>
  +           if no other operation is specified as a constructor argument. The 
  +           above example cleans all tables defined <literal>BaseData.xml</literal>, 
  +           then inserts all rows declared in <literal>BaseData.xml</literal> 
  +           before each <literal>@Test</literal> method is invoked.
  +         </para>
  +         
  +         <para>
  +           If you require extra cleanup after a test method executes, add 
  +           operations to <literal>afterTestOperations</literal> list.
  +         </para>
  +         
  +         <para>
  +           You need to tell DBUnit about the datasource you are using by 
  +           setting a TestNG test parameter named <literal>datasourceJndiName</literal>:
  +         </para>
  +         
  +         <programlisting>
  +   <![CDATA[<parameter name="datasourceJndiName" value="java:/seamdiscsDatasource"/>]]>
  +         </programlisting> 
  +          
  +        </section>
  +        
       </section>
   	
   </chapter>
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list