org.springunit.framework
Class SpringUnitTest

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.springunit.framework.SpringUnitTest
All Implemented Interfaces:
Test
Direct Known Subclasses:
SpringUnit4Test

public abstract class SpringUnitTest
extends AbstractDependencyInjectionSpringContextTests

Extends Spring's test framework to support 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 SpringUnitTest is required by convention to have a bean called Classname of type SpringUnitContext, where Classname is the simple name of the subclass of SpringUnitTest. 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

Field Summary
 
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
 
Fields inherited from class org.springframework.test.ConditionalTestCase
logger
 
Constructor Summary
protected SpringUnitTest()
          Default constructor.
protected SpringUnitTest(String fName)
          Constructor with JUnit name.
 
Method Summary
protected  String[] getConfigLocations()
          Return list of file names that the Spring test framework uses in order to create beans for testing.
protected
<T> T
getObject(String key)
          Search for object identified by key in the hierarchy of contexts.
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables
 
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createApplicationContext, customizeBeanFactory, getApplicationContext, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, onSetUp, onTearDown, setDirty, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
addContext, contextKeyString, getContext, hasCachedContext, setDirty
 
Methods inherited from class org.springframework.test.ConditionalTestCase
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled, runBare
 
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, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpringUnitTest

protected SpringUnitTest()
Default constructor.


SpringUnitTest

protected SpringUnitTest(String fName)
Constructor with JUnit name. Sets AutowireMode to "by name" (overriding the default, which is "by type"). Creates a context contexts that stores the hierarchy of test contexts.

Parameters:
fName - Name of JUnit test
Method Detail

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


Copyright © 2007 null. All Rights Reserved.