public class ApplicationContextInit
extends org.junit.rules.ExternalResource
spring application context.
Example usage:
public class YourTestClass
{
// Parameterless construction brings up the default Alfresco spring configuration.
@ClassRule public static final ApplicationContextInit APP_CONTEXT_RULE = new ApplicationContextInit();
private static NodeService NODE_SERVICE;
@BeforeClass public static void initSpringServices() throws Exception
{
NODE_SERVICE = (NodeService) APP_CONTEXT_RULE.getApplicationContext().getBean("nodeService");
}
}
| Constructor and Description |
|---|
ApplicationContextInit()
Construct a JUnit rule which will bring up a spring ApplicationContext based on the default Alfresco spring context.
|
ApplicationContextInit(java.lang.String[] configLocations)
Construct a JUnit rule which will bring up an ApplicationContext based on the specified spring contexts.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
after() |
protected void |
before() |
static ApplicationContextInit |
createStandardContextWithOverrides(java.lang.String[] additionalConfigLocations)
This factory method constructs a JUnit rule which will bring up an ApplicationContext consisting
of the default Alfresco context with any additionConfigLocations appended.
|
org.springframework.context.ApplicationContext |
getApplicationContext()
Gets the ApplicationContext as initialised by the rule.
|
java.util.List |
getConfigLocations()
Gets the configLocations as supplied to the code on construction.
|
public ApplicationContextInit()
public ApplicationContextInit(java.lang.String[] configLocations)
configLocations - locations of spring contextspublic static ApplicationContextInit createStandardContextWithOverrides(java.lang.String[] additionalConfigLocations)
additionalConfigLocations - addition config locations containing additional or overriding beans.protected void before()
before in class org.junit.rules.ExternalResourceprotected void after()
after in class org.junit.rules.ExternalResourcepublic java.util.List getConfigLocations()
public org.springframework.context.ApplicationContext getApplicationContext()
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.