org.lambico.test.spring.hibernate
Class DBTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.ConditionalTestCase
              extended by org.springframework.test.AbstractSpringContextTests
                  extended by org.springframework.test.AbstractSingleSpringContextTests
                      extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                          extended by org.springframework.test.AbstractTransactionalSpringContextTests
                              extended by org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
                                  extended by org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests
                                      extended by org.lambico.test.spring.EnhancedTestCase
                                          extended by org.lambico.test.spring.hibernate.DBTest
All Implemented Interfaces:
junit.framework.Test

public abstract class DBTest
extends EnhancedTestCase

A base class for tests that populate the DB with the fixture data.

Author:
Jacopo Murador

Field Summary
protected  java.util.HashMap daoMap
          The map of DAOs.
protected  java.util.Map<java.lang.Class,java.lang.Object[]> fixtures
          The fixtures.
protected  org.hibernate.SessionFactory sessionFactory
          The session factory.
 
Fields inherited from class org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests
profileValueSource, simpleJdbcTemplate
 
Fields inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
jdbcTemplate
 
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
transactionDefinition, transactionManager, transactionStatus
 
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO
 
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests
applicationContext
 
Constructor Summary
DBTest()
           
 
Method Summary
protected  void endTransaction()
          At the end of the test the method endTransaction call a rollback for the transaction although a explicit rollback call is did.
protected  java.lang.String[] getConfigLocations()
           
 java.lang.Class[] getFixtureClasses()
          Returns a reverse-ordered array of the models that need to be loaded.
 java.util.Set<java.lang.Class> getFixtureClassSet()
          Returns a set of the models that need to be loaded.
 java.lang.Class[] getReverseOrderFixtureClasses()
          Returns a reverse-ordered array of the models that need to be loaded.
 void onSetUpBeforeTransaction()
          Delete the rows from the tables, and reinsert all data.
protected  void prepareTestInstance()
           
 
Methods inherited from class org.lambico.test.spring.EnhancedTestCase
assertEmpty, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsIgnoreCase, assertNotEmpty, assertNotEmpty, assertNotEmpty, assertNotEmpty, assertSize
 
Methods inherited from class org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests
findUniqueProfileValueSourceFromContext, getTestMethod, isDisabledInThisEnvironment, isRollback, runBare, setDataSource
 
Methods inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
countRowsInTable, deleteFromTables, executeSqlScript, getJdbcTemplate, setComplete, setSqlScriptEncoding
 
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
isDefaultRollback, onSetUp, onSetUpInTransaction, onTearDown, onTearDownAfterTransaction, onTearDownInTransaction, preventTransaction, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables
 
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, prepareApplicationContext, setDirty, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
addContext, contextKeyString, getContext, hasCachedContext, isContextKeyEmpty, setDirty
 
Methods inherited from class org.springframework.test.ConditionalTestCase
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled
 
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, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fixtures

protected java.util.Map<java.lang.Class,java.lang.Object[]> fixtures
The fixtures.


sessionFactory

protected org.hibernate.SessionFactory sessionFactory
The session factory.


daoMap

protected java.util.HashMap daoMap
The map of DAOs.

Constructor Detail

DBTest

public DBTest()
Method Detail

getReverseOrderFixtureClasses

public final java.lang.Class[] getReverseOrderFixtureClasses()
Returns a reverse-ordered array of the models that need to be loaded.

Returns:
The array of class models.

getFixtureClasses

public java.lang.Class[] getFixtureClasses()
Returns a reverse-ordered array of the models that need to be loaded. NB: It must always return a new object, not a reference to an already existent object.

Returns:
The array of class models.

getFixtureClassSet

public final java.util.Set<java.lang.Class> getFixtureClassSet()
Returns a set of the models that need to be loaded.

Returns:
The set of class models.

onSetUpBeforeTransaction

public void onSetUpBeforeTransaction()
                              throws java.lang.Exception
Delete the rows from the tables, and reinsert all data.

Overrides:
onSetUpBeforeTransaction in class org.springframework.test.AbstractTransactionalSpringContextTests
Throws:
java.lang.Exception - In case of error.

getConfigLocations

protected java.lang.String[] getConfigLocations()
Overrides:
getConfigLocations in class org.springframework.test.AbstractSingleSpringContextTests

prepareTestInstance

protected void prepareTestInstance()
                            throws java.lang.Exception
Overrides:
prepareTestInstance in class org.springframework.test.AbstractDependencyInjectionSpringContextTests
Throws:
java.lang.Exception

endTransaction

protected void endTransaction()
At the end of the test the method endTransaction call a rollback for the transaction although a explicit rollback call is did. This raise a false exception.

Overrides:
endTransaction in class org.springframework.test.AbstractTransactionalSpringContextTests


Copyright © 2009-2010 Lambico Team. All Rights Reserved.