mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Rather than having a static ApplicationContext on the test, which causes problems when a test needs a different one, fetch it every time via an overridable method. Normally ApplicationContextHelper will cache it for us, but this does allow different tests to request different contexts without two different ones getting accidently started
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18852 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,8 +46,11 @@ import org.springframework.context.ApplicationContext;
|
|||||||
*/
|
*/
|
||||||
public abstract class BaseAlfrescoTestCase extends TestCase
|
public abstract class BaseAlfrescoTestCase extends TestCase
|
||||||
{
|
{
|
||||||
/** the context to keep between tests */
|
/**
|
||||||
public static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
* This context will be fetched each time, but almost always
|
||||||
|
* will have been cached by {@link ApplicationContextHelper}
|
||||||
|
*/
|
||||||
|
protected ApplicationContext ctx;
|
||||||
|
|
||||||
/** the service registry */
|
/** the service registry */
|
||||||
protected ServiceRegistry serviceRegistry;
|
protected ServiceRegistry serviceRegistry;
|
||||||
@@ -71,11 +74,22 @@ public abstract class BaseAlfrescoTestCase extends TestCase
|
|||||||
protected ActionService actionService;
|
protected ActionService actionService;
|
||||||
protected TransactionService transactionService;
|
protected TransactionService transactionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default will return the full context.
|
||||||
|
* Override this if your test needs a different one.
|
||||||
|
*/
|
||||||
|
protected void setUpContext()
|
||||||
|
{
|
||||||
|
// Fetch the default, full context
|
||||||
|
ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception
|
protected void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
setUpContext();
|
||||||
|
|
||||||
// get the service register
|
// get the service register
|
||||||
this.serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
this.serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
//Get a reference to the node service
|
//Get a reference to the node service
|
||||||
|
Reference in New Issue
Block a user