Ensure that the test listeners are only loaded into the application context when the relevant test is executed.

This commit is contained in:
Roy Wetherall
2016-07-08 11:49:15 +10:00
parent e4d57f5f2d
commit 07b1985c1f
4 changed files with 61 additions and 39 deletions

View File

@@ -40,6 +40,17 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
*/
public class RM3314Test extends BaseRMTestCase
{
/** Application context */
protected String[] getConfigLocations()
{
return new String[]
{
"classpath:alfresco/application-context.xml",
"classpath:test-context.xml",
"classpath:test-rm3314-context.xml"
};
}
/** registry to record callback from test beans "test.rm3114.1" and "test.rm3114.2" */
public static Map<String, Boolean> callback = new HashMap<String, Boolean>(2);

View File

@@ -104,6 +104,10 @@ public class RM3314TestListener implements ApplicationListener<ContextRefreshedE
public Void doWork() throws Exception
{
try
{
NodeRef companyHome = repository.getCompanyHome();
if (fileFolderService.searchSimple(companyHome, name) == null)
{
// create node
NodeRef folder = fileFolderService.create(
@@ -124,6 +128,7 @@ public class RM3314TestListener implements ApplicationListener<ContextRefreshedE
nodeService.deleteNode(folder);
}
}
}
catch (BadSqlGrammarException e)
{
// ignore and carry on

View File

@@ -4,7 +4,7 @@
<beans>
<!-- test model -->
<bean id="org_alfresco_module_rm_rmTestdictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<bean id="org_alfresco_module_rm_rmTestdictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="org_alfresco_module_rm_dictionaryBootstrap">
<property name="models">
<list>
<value>test-model.xml</value>
@@ -246,25 +246,4 @@
<bean id="contentCleanser.test" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestContentCleanser"/>
<!-- Test listeners -->
<!-- Executed with '0' order. This is default order and as such the application event will be executed relative to the other
beans in the order in which they appear in the spring context -->
<bean id="test.rm3314.1" class="org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314TestListener">
<property name="order" value="0"/>
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="nodeService" ref="NodeService"/>
<property name="fileFolderService" ref="FileFolderService" />
<property name="repository" ref="repositoryHelper" />
</bean>
<!-- The default order has this bean executing its application event with the lowest precendence, ie after all the other
beans set to '0' precendence by default -->
<bean id="test.rm3314.2" class="org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314TestListener">
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="nodeService" ref="NodeService"/>
<property name="fileFolderService" ref="FileFolderService" />
<property name="repository" ref="repositoryHelper" />
</bean>
</beans>

View File

@@ -0,0 +1,27 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Test listeners -->
<!-- Executed with '0' order. This is default order and as such the application event will be executed relative to the other
beans in the order in which they appear in the spring context -->
<bean id="test.rm3314.1" class="org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314TestListener">
<property name="order" value="0"/>
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="nodeService" ref="NodeService"/>
<property name="fileFolderService" ref="FileFolderService" />
<property name="repository" ref="repositoryHelper" />
</bean>
<!-- The default order has this bean executing its application event with the lowest precendence, ie after all the other
beans set to '0' precendence by default -->
<bean id="test.rm3314.2" class="org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314.RM3314TestListener">
<property name="recordsManagementAdminService" ref="recordsManagementAdminService"/>
<property name="nodeService" ref="NodeService"/>
<property name="fileFolderService" ref="FileFolderService" />
<property name="repository" ref="repositoryHelper" />
</bean>
</beans>