|
JSF-Spring | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 de.mindmatters.faces.spring.test.AbstractJsfSpringContextTests
public abstract class AbstractJsfSpringContextTests
Convenient superclass for integration tests depending on a JSF-Spring context hierarchy. The test instance itself is populated by Dependency Injection.
This test mocks the servlet-api and builds up a fully working JSF
implementation based upon any production environment you choose (e.g. MyFaces
with the help of the MyFacesStartupDriver
or SunRI with
JsfRIStartupDriver
).
Subclasses have to implement getResourceBasePath()
which should
point to an 'unzipped' WAR. All relevant context files will be automatically
loaded and you are able to test your production setup or build up 'fake' web
applications for testing your managed beans.
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 | |
---|---|
AbstractJsfSpringContextTests()
Default constructor - populating protected variables via dependency injection is turned on. |
Method Summary | |
---|---|
protected java.lang.String |
contextKeyString(java.lang.Object contextKey)
Subclasses can override this to return a String representation of their context key for use in logging. |
protected javax.servlet.ServletContext |
createServletContext()
Creates the ServletContext mock implementation - default is MockServletContext . |
protected java.lang.String[] |
getConfigLocations()
Subclasses must implement this method to return the locations of their config files. |
protected abstract java.lang.String |
getResourceBasePath()
|
protected javax.servlet.ServletContext |
getServletContext()
|
protected WebApplicationContext |
getWebApplicationContext()
|
protected ConfigurableWebApplicationContext |
loadContext(javax.servlet.ServletContext servletContext)
Loads the FacesWebApplicationContext by
default - with the parent loaded by
loadParentContext(ServletContext) . |
protected ConfigurableApplicationContext |
loadContextLocations(java.lang.String[] locations)
Load an ApplicationContext from the given config locations. |
protected JsfEnvironment |
loadJsfEnvironment(javax.servlet.ServletContext servletContext)
Loads the JsfEnvironment of the particular test case. |
protected JsfStartupDriver |
loadJsfImplementation(javax.servlet.ServletContext servletContext)
Loads the current JSF implementation startup driver used for configuration and initialization purposes. |
protected ConfigurableWebApplicationContext |
loadParentContext(javax.servlet.ServletContext servletContext)
Loads the parent WebApplicationContext - the
ContextLoader is used for loading
and initialization by default. |
protected void |
onSetUp()
Subclasses can override this method in place of the setUp() method, which is final in this class. |
protected void |
onTearDown()
Subclasses can override this to add custom behavior on teardown. |
protected void |
prepareTestInstance()
Prepare this test instance, injecting dependencies into its protected fields and its bean properties. |
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
---|
getAutowireMode, isDependencyCheck, isPopulateProtectedVariables, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables |
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests |
---|
contextKey, getLoadCount, loadContext, setDirty, setUp, tearDown |
Methods inherited from class org.springframework.test.AbstractSpringContextTests |
---|
addContext, 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractJsfSpringContextTests()
Method Detail |
---|
protected final void prepareTestInstance() throws java.lang.Exception
prepareTestInstance
in class AbstractDependencyInjectionSpringContextTests
java.lang.Exception
protected final ConfigurableApplicationContext loadContextLocations(java.lang.String[] locations) throws java.lang.Exception
loadContextLocations
in class AbstractSingleSpringContextTests
locations
- the config locations
java.lang.Exception
protected javax.servlet.ServletContext createServletContext()
MockServletContext
.
protected JsfEnvironment loadJsfEnvironment(javax.servlet.ServletContext servletContext) throws java.lang.Exception
JsfEnvironment
of the particular test case.
servletContext
- the current ServletContext
java.lang.Exception
- in case of errorsprotected ConfigurableWebApplicationContext loadContext(javax.servlet.ServletContext servletContext) throws java.lang.Exception
FacesWebApplicationContext
by
default - with the parent loaded by
loadParentContext(ServletContext)
.
servletContext
- the current ServletContext
WebApplicationContext
java.lang.Exception
- in case of errorsprotected JsfStartupDriver loadJsfImplementation(javax.servlet.ServletContext servletContext) throws java.lang.Exception
servletContext
- the current ServletContext
JsfStartupDriver
java.lang.Exception
- in case of errorsprotected final java.lang.String contextKeyString(java.lang.Object contextKey)
contextKeyString
in class AbstractSpringContextTests
contextKey
- the context keyprotected ConfigurableWebApplicationContext loadParentContext(javax.servlet.ServletContext servletContext) throws java.lang.Exception
WebApplicationContext
- the
ContextLoader
is used for loading
and initialization by default.
servletContext
- the current ServletContext
WebApplicationContext
java.lang.Exception
- in case of errorsprotected javax.servlet.ServletContext getServletContext()
ServletContext
mock implementationprotected final java.lang.String[] getConfigLocations()
getConfigLocations
in class AbstractSingleSpringContextTests
protected abstract java.lang.String getResourceBasePath()
protected void onSetUp() throws java.lang.Exception
setUp()
method, which is final in this class.
This implementation does nothing.
onSetUp
in class AbstractSingleSpringContextTests
java.lang.Exception
- simply let any exception propagateprotected void onTearDown() throws java.lang.Exception
onTearDown
in class AbstractSingleSpringContextTests
java.lang.Exception
- simply let any exception propagateprotected WebApplicationContext getWebApplicationContext()
WebApplicationContext
|
JSF-Spring | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |