org.wamblee.test.persistence
Class JpaTester

java.lang.Object
  extended by org.wamblee.test.persistence.JpaTester

public class JpaTester
extends java.lang.Object

This class is the entry point for JPA tests. Test code should construct a JpaTester in the @Before method and call start() on it in that method. Also, test code should call stop() on it in the @After method. This class is constructed with a description of the persistence unit to be tested. The principle is that an existing persistence.xml can be tested without change in unit test code. It then takes care of the following:

The main entry point for all this functionality is the PersistenceUnitDescription which describes the persistence unit and must be provided at construction of the JpaTester NOTE: Persistence XML files should be explicitly configured with the classes that are part of the persistence unit since scanning of classes does not work correctly in a unit test environment. This is currently the only limitation.


Constructor Summary
JpaTester(PersistenceUnitDescription aPersistenceUnit)
          Constructs the tester.
 
Method Summary
 javax.sql.DataSource getDataSource()
          Gets the datasource.
 Database getDb()
          Gets the database.
 DatabaseUtils getDbUtils()
          Gets the database utilities.
 JpaBuilder getJpaBuilder()
          Gets the jpa builder.
 PersistenceUnitDescription getPersistenceUnit()
          Gets the persistence unit.
 void start()
          Starts the tester.
 void stop()
          Stops the tester.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaTester

public JpaTester(PersistenceUnitDescription aPersistenceUnit)
Constructs the tester.

Parameters:
aPersistenceUnit - Persistence unit under test.
Method Detail

start

public void start()
           throws java.lang.Exception
Starts the tester. This must be called prior to running the test.

Throws:
java.lang.Exception

stop

public void stop()
Stops the tester. This must be called after the test.


getDb

public Database getDb()
Gets the database.

Returns:
Database.

getDataSource

public javax.sql.DataSource getDataSource()
Gets the datasource.

Returns:
Datasource.

getDbUtils

public DatabaseUtils getDbUtils()
Gets the database utilities.

Returns:
Database utilities.

getJpaBuilder

public JpaBuilder getJpaBuilder()
Gets the jpa builder.

Returns:
JPA builder.

getPersistenceUnit

public PersistenceUnitDescription getPersistenceUnit()
Gets the persistence unit.

Returns:
Persistence unit.


Copyright © 2010. All Rights Reserved.