Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use <a href="http://www.dbunit.org/" rel="nofollow">DBUnit</a> in conjunction with H2 database and untils &amp; Spring. Works nicely:</p> <pre><code>@SpringApplicationContext({ "classpath:test-context-dbunit.xml" }) @Transactional(TransactionMode.ROLLBACK) @DataSet public class ApplicationDaoTest extends UnitilsTestNG { @SpringBeanByType private ApplicationDao applicationDao; @Test public void findAll() throws Exception { List&lt;Application&gt; actual = applicationDao.findAll(); assertNotNull(actual); assertEquals(actual.size(), 3); } } </code></pre> <p>The data is set in an XML file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;dataset&gt; &lt;APPLICATION APPLICATION_ID="1" name="APP3" enabled="1" application_type="TRADE" api_key="AK1" auto_create_topics="1" /&gt; &lt;APPLICATION APPLICATION_ID="2" name="APP1" enabled="1" application_type="TRADE" api_key="AK2" auto_create_topics="1" /&gt; &lt;APPLICATION APPLICATION_ID="3" name="APP2" enabled="0" application_type="TRADE" api_key="AK3" auto_create_topics="1" /&gt; &lt;/dataset&gt; </code></pre> <p>In Spring test context you define your datasource as such:</p> <pre><code>&lt;bean id="dataSource" class="org.unitils.database.UnitilsDataSourceFactoryBean"/&gt; </code></pre> <p>As dialect you use: <code>org.hibernate.dialect.H2Dialect</code> </p> <p>Finally a unitils.properties in your classpath like:</p> <pre><code>database.driverClassName=org.h2.Driver database.url=jdbc:h2:mem:test database.user=sa database.password= database.schemaNames=public database.dialect=hsqldb </code></pre> <hr> <p><strong>UPDATE</strong></p> <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;property name="packagesToScan" value="..."/&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.H2Dialect&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.hbm2ddl.auto"&gt;create-drop&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload