org.springunit.framework
Class SpringUnitTransactionalTest
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.springframework.test.ConditionalTestCase
org.springframework.test.AbstractSpringContextTests
org.springframework.test.AbstractSingleSpringContextTests
org.springframework.test.AbstractDependencyInjectionSpringContextTests
org.springframework.test.AbstractTransactionalSpringContextTests
org.springunit.framework.SpringUnitTransactionalTest
- All Implemented Interfaces:
- Test
- Direct Known Subclasses:
- SpringUnit4TransactionalTest
public abstract class SpringUnitTransactionalTest
- extends AbstractTransactionalSpringContextTests
Extends Spring's test framework to support transactional data-driven tests.
Data-driven tests separate data values from test logic,
keeping data values in external files and test logic in Java code.
Every descendent of SpringUnitTransactionalTest is required by convention
to have a bean called Classname
of type
SpringUnitContext, where Classname
is
the simple name of the subclass of SpringUnitTransactionalTest.
Note that the simple names of subclasses must be unique,
that is, they must not be distinguished solely by different
package qualifiers.
- Author:
- Ted Velkoff
Method Summary |
protected String[] |
getConfigLocations()
Return list of file names that the
Spring test framework uses in order to create beans for testing. |
protected
|
getObject(String key)
Search for object identified by key
in the hierarchy of contexts. |
protected void |
onSetUpInTransaction()
Subclasses should override this method to perform any setup operations,
such as populating a database table, within the transaction
created by this class. |
protected void |
onSetUpInTransactionAtBeginning()
Deprecated. Subclasses should instead override onSetUpInTransaction
directly.
This method is maintained for backward compatibility but will be removed
in a future release. |
protected void |
onTearDownAfterTransaction()
Calls onTearDownAfterTransactionEnds so that subclasses can
insert behavior at conclusion of transaction. |
protected void |
onTearDownAfterTransactionEnds()
Subclasses can override this method to perform cleanup here. |
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests |
endTransaction, onSetUp, onSetUpBeforeTransaction, onTearDown, onTearDownInTransaction, preventTransaction, setComplete, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction |
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests |
contextKey, createApplicationContext, customizeBeanFactory, getApplicationContext, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, setDirty, setUp, tearDown |
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, format |
SpringUnitTransactionalTest
protected SpringUnitTransactionalTest()
- Default constructor.
SpringUnitTransactionalTest
protected SpringUnitTransactionalTest(String name)
- Constructor with JUnit name.
Sets AutowireMode to "by name" (overriding the default, which is "by type").
Creates a hierarchy of contexts.
- Parameters:
fName
- Name of JUnit test
getConfigLocations
protected final String[] getConfigLocations()
- Return list of file names that the
Spring test framework uses in order to create beans for testing.
- Overrides:
getConfigLocations
in class AbstractSingleSpringContextTests
- Returns:
- Array of string filenames
getObject
protected final <T> T getObject(String key)
throws Exception
- Search for object identified by
key
in the hierarchy of contexts.
- Parameters:
key
- Identifier of data value to find
- Returns:
- Object if found or null
- Throws:
Exception
- if errors occur when using reflection
to access the SpringUnitContext for any
class in the list
onSetUpInTransaction
protected void onSetUpInTransaction()
throws Exception
- Subclasses should override this method to perform any setup operations,
such as populating a database table, within the transaction
created by this class.
NB: Not called if there is no transaction management, due to no
transaction manager being provided in the context.
Note: This overriding of onSetUpInTransaction
is deprecated in SpringUnit and will be removed in a future release.
Subclasses that previously overrode onSetUpInTransactionAtBeginning
should instead override this method.
- Overrides:
onSetUpInTransaction
in class AbstractTransactionalSpringContextTests
- Throws:
Exception
- simply let any exception propagate
onSetUpInTransactionAtBeginning
protected void onSetUpInTransactionAtBeginning()
throws Exception
- Deprecated. Subclasses should instead override
onSetUpInTransaction
directly.
This method is maintained for backward compatibility but will be removed
in a future release.
- Throws:
Exception
onTearDownAfterTransaction
protected final void onTearDownAfterTransaction()
throws Exception
- Calls onTearDownAfterTransactionEnds so that subclasses can
insert behavior at conclusion of transaction.
The transaction is not open anymore at this point.
Follows by calling setDirty so that all beans created
from configuration files are refreshed.
- Overrides:
onTearDownAfterTransaction
in class AbstractTransactionalSpringContextTests
- Throws:
Exception
- simply let any exception propagate
onTearDownAfterTransactionEnds
protected void onTearDownAfterTransactionEnds()
throws Exception
- Subclasses can override this method to perform cleanup here.
The transaction is not open anymore at this point.
- Throws:
Exception
- simply let any exception propagate
Copyright © 2007 null. All Rights Reserved.