public class JpaTester extends Object
@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:
DatabaseBuilder
for more information on how a
databse is obtained.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 and Description |
---|
JpaTester(PersistenceUnitDescription aPersistenceUnit)
Constructs the tester.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public JpaTester(PersistenceUnitDescription aPersistenceUnit)
aPersistenceUnit
- Persistence unit under test.public void start() throws Exception
Exception
public void stop()
public Database getDb()
public DataSource getDataSource()
public DatabaseUtils getDbUtils()
public JpaBuilder getJpaBuilder()
public PersistenceUnitDescription getPersistenceUnit()
Copyright © 2022. All rights reserved.