mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added a convenience method to the ApplicationContextInit @Rule to allow for easier spring overriding in test code.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@34805 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.alfresco.util.test.junitrules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -79,6 +80,34 @@ public class ApplicationContextInit extends ExternalResource
|
||||
this.configLocations = configLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* This factory method constructs a JUnit rule which will bring up an ApplicationContext consisting
|
||||
* of the default Alfresco context with any additionConfigLocations appended. It is a convenient way to specify
|
||||
* override contexts in test code.
|
||||
*
|
||||
* @param additionalConfigLocations addition config locations containing additional or overriding beans.
|
||||
*/
|
||||
public static ApplicationContextInit createStandardContextWithOverrides(String... additionalConfigLocations)
|
||||
{
|
||||
List<String> contexts = new ArrayList<String>();
|
||||
|
||||
// The defaults (currently only one)
|
||||
for (String defaultConfigLocation: ApplicationContextHelper.CONFIG_LOCATIONS)
|
||||
{
|
||||
contexts.add(defaultConfigLocation);
|
||||
}
|
||||
|
||||
// any user supplied extras
|
||||
for (String additionalContext : additionalConfigLocations)
|
||||
{
|
||||
contexts.add(additionalContext);
|
||||
}
|
||||
|
||||
String[] contextsAsArray = contexts.toArray(new String[0]);
|
||||
|
||||
return new ApplicationContextInit(contextsAsArray);
|
||||
}
|
||||
|
||||
@Override protected void before() throws Throwable
|
||||
{
|
||||
// Were any context locations specified in the constructor?
|
||||
|
Reference in New Issue
Block a user