com.bm.testsuite
Class PoJoFixture

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jmock.core.VerifyingTestCase
              extended by org.jmock.core.MockObjectSupportTestCase
                  extended by org.jmock.MockObjectTestCase
                      extended by com.bm.testsuite.BaseTest
                          extended by com.bm.testsuite.PoJoFixture
Type Parameters:
T - - the type of the service
All Implemented Interfaces:
junit.framework.Test

public abstract class PoJoFixture
extends BaseTest

Supports entity manager and flat file db injection for pojos.

Since:
12.11.2005
Author:
Daniel Wiese

Field Summary
 
Fields inherited from class org.jmock.core.MockObjectSupportTestCase
ANYTHING, NOT_NULL, NULL
 
Constructor Summary
PoJoFixture(java.lang.Class<?>[] usedEntityBeans)
          Constructor.
PoJoFixture(java.lang.Class<?>[] usedEntityBeans, InitialDataSet... initialData)
          Constructor.
 
Method Summary
protected
<T> void
deleteAll(java.lang.Class<T> clazz)
          Deletes all rows of the given class in the database.
protected
<T> java.util.List<T>
findAll(java.lang.Class<T> clazz)
          Find all rows of the given class in the database.
 javax.sql.DataSource getDataSource()
          Liefert die datasource.
 javax.persistence.EntityManager getEntityManager()
          Returns a isntance of a EntityManager.
protected
<T> java.util.List<T>
persist(java.util.List<T> complexObjectGraph)
          Persists all objects in the database.
protected  void setUp()
           
protected  void tearDown()
           
 
Methods inherited from class com.bm.testsuite.BaseTest
assertCollectionsEqual, assertFalse, assertFalse, assertInstanceOf, assertInstanceOf, setValueForField, testNothing
 
Methods inherited from class org.jmock.MockObjectTestCase
atLeastOnce, defaultMockNameForType, mock, mock, never, newCoreMock, once, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, throwException
 
Methods inherited from class org.jmock.core.MockObjectSupportTestCase
and, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, isA, newDummy, newDummy, newDummy, not, or, same, stringContains
 
Methods inherited from class org.jmock.core.VerifyingTestCase
registerToVerify, runBare, unregisterToVerify, verify
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PoJoFixture

public PoJoFixture(java.lang.Class<?>[] usedEntityBeans)
Constructor.

Parameters:
usedEntityBeans - - the used entity beans

PoJoFixture

public PoJoFixture(java.lang.Class<?>[] usedEntityBeans,
                   InitialDataSet... initialData)
Constructor.

Parameters:
usedEntityBeans - - the used entity beans
initialData - - the initial data to create in the db
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception
Since:
16.10.2005
See Also:
TestCase.setUp()

findAll

protected <T> java.util.List<T> findAll(java.lang.Class<T> clazz)
Find all rows of the given class in the database.

Type Parameters:
T - the tyme of the persistent object
Parameters:
clazz - the class of of the persistent object
Returns:
all DB instances

deleteAll

protected <T> void deleteAll(java.lang.Class<T> clazz)
Deletes all rows of the given class in the database.

Type Parameters:
T - the tyme of the persistent object
Parameters:
clazz - the class of of the persistent object

persist

protected <T> java.util.List<T> persist(java.util.List<T> complexObjectGraph)
Persists all objects in the database.

Type Parameters:
T - the tyme of the persistent object
Parameters:
complexObjectGraph - th egraph to persist
Returns:
the persisted objects

tearDown

protected void tearDown()
                 throws java.lang.Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception
Since:
16.10.2005
See Also:
TestCase.tearDown()

getDataSource

public javax.sql.DataSource getDataSource()
Liefert die datasource.

Returns:
die data source.

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Returns a isntance of a EntityManager.

Returns:
- a instance of an entity manager
Since:
12.11.2005


Copyright © 2008. All Rights Reserved.