public class DatabaseRule extends DatabaseTestcase implements org.junit.rules.MethodRule
DatabaseRule
provides access to the configured Database and
execute optional configured DBOperation
before and after a test.
public class EntityTestcase { @Rule public DatabaseRule databaseRule = new DatabaseRule(); @Test public void testPersist() throws Exception { User user = new User(); // ... databaseRule.getEntityMnager().persist(user); } }
DatabaseTestcase
,
DBOperation
Constructor and Description |
---|
DatabaseRule() |
DatabaseRule(Class<?>... clazzes)
Deprecated.
|
DatabaseRule(DBOperation dbOperation) |
DatabaseRule(DBOperation dbOperation,
Class<?>... clazzes)
Deprecated.
|
DatabaseRule(String persistenceUnitName) |
DatabaseRule(String persistenceUnitName,
DBOperation dbOperation) |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runners.model.FrameworkMethod method,
Object target) |
getEntityManager, getEntityManagerFactory, getInjectedObject, getKey, getTransactionHelper, verify
public DatabaseRule()
DatabaseTestcase.DatabaseTestcase()
@Deprecated public DatabaseRule(Class<?>... clazzes)
@Deprecated public DatabaseRule(DBOperation dbOperation, Class<?>... clazzes)
public DatabaseRule(DBOperation dbOperation)
public DatabaseRule(String persistenceUnitName, DBOperation dbOperation)
public DatabaseRule(String persistenceUnitName)
public final org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)
apply
in interface org.junit.rules.MethodRule
Copyright © 2014. All rights reserved.