de.akquinet.jbosscc.needle.junit
Class DatabaseRule

java.lang.Object
  extended by de.akquinet.jbosscc.needle.db.DatabaseTestcase
      extended by de.akquinet.jbosscc.needle.junit.DatabaseRule
All Implemented Interfaces:
InjectionProvider<Object>, InjectionVerifier, org.junit.rules.MethodRule

public class DatabaseRule
extends DatabaseTestcase
implements org.junit.rules.MethodRule

The 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);
        }
 }
 

See Also:
DatabaseTestcase, DBOperation

Constructor Summary
DatabaseRule()
           
DatabaseRule(Class<?>... clazzes)
          Deprecated. 
DatabaseRule(DBOperation dbOperation)
           
DatabaseRule(DBOperation dbOperation, Class<?>... clazzes)
          Deprecated. 
DatabaseRule(String persistenceUnitName)
           
DatabaseRule(String persistenceUnitName, DBOperation dbOperation)
           
 
Method Summary
 org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)
           
 
Methods inherited from class de.akquinet.jbosscc.needle.db.DatabaseTestcase
after, before, getEntityManager, getEntityManagerFactory, getInjectedObject, getKey, getTransactionHelper, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseRule

public DatabaseRule()
See Also:
DatabaseTestcase.DatabaseTestcase()

DatabaseRule

@Deprecated
public DatabaseRule(Class<?>... clazzes)
Deprecated. 

See Also:
DatabaseTestcase.DatabaseTestcase(Class...)

DatabaseRule

@Deprecated
public DatabaseRule(DBOperation dbOperation,
                               Class<?>... clazzes)
Deprecated. 

See Also:
DatabaseTestcase.DatabaseTestcase(DBOperation, Class...)

DatabaseRule

public DatabaseRule(DBOperation dbOperation)
See Also:
DatabaseTestcase.DatabaseTestcase(DBOperation)

DatabaseRule

public DatabaseRule(String persistenceUnitName,
                    DBOperation dbOperation)
See Also:
DatabaseTestcase.DatabaseTestcase(String, DBOperation)

DatabaseRule

public DatabaseRule(String persistenceUnitName)
See Also:
DatabaseTestcase.DatabaseTestcase(String)
Method Detail

apply

public final org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
                                                     org.junit.runners.model.FrameworkMethod method,
                                                     Object target)
Specified by:
apply in interface org.junit.rules.MethodRule


Copyright © 2013 akquinet AG. All Rights Reserved.