mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Integration test for automatic disposition job
* specifically to ensure that automatic cut off is happening, since this is an area of functionality that easily regresses * test job context to override CRON frequencies for tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@74313 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,6 +22,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.integration.disposition.D
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite;
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite;
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite;
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.job.JobTestSuite;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.record.RecordTestSuite;
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.record.RecordTestSuite;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.RecordFolderTestSuite;
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.RecordFolderTestSuite;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.report.ReportTestSuite;
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.report.ReportTestSuite;
|
||||||
@@ -45,7 +46,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||||||
ReportTestSuite.class,
|
ReportTestSuite.class,
|
||||||
DispositionTestSuite.class,
|
DispositionTestSuite.class,
|
||||||
RecordTestSuite.class,
|
RecordTestSuite.class,
|
||||||
RecordFolderTestSuite.class
|
RecordFolderTestSuite.class,
|
||||||
|
JobTestSuite.class
|
||||||
})
|
})
|
||||||
public class IntegrationTestSuite
|
public class IntegrationTestSuite
|
||||||
{
|
{
|
||||||
|
@@ -72,7 +72,7 @@ public class CompleteEventsTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// file record
|
// file record
|
||||||
record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
utils.declareRecord(record);
|
utils.completeRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
@@ -128,7 +128,7 @@ public class CompleteEventsTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// file record
|
// file record
|
||||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
utils.declareRecord(record);
|
utils.completeRecord(record);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ public class CompleteEventsTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// file record
|
// file record
|
||||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
utils.declareRecord(record);
|
utils.completeRecord(record);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void when()
|
public void when()
|
||||||
@@ -267,7 +267,7 @@ public class CompleteEventsTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// file record
|
// file record
|
||||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
utils.declareRecord(record);
|
utils.completeRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
@@ -338,7 +338,7 @@ public class CompleteEventsTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// file record
|
// file record
|
||||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
utils.declareRecord(record);
|
utils.completeRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
@@ -409,7 +409,7 @@ public class CompleteEventsTest extends BaseRMTestCase
|
|||||||
// file record
|
// file record
|
||||||
String recordName = GUID.generate();
|
String recordName = GUID.generate();
|
||||||
record = utils.createRecord(recordFolder, recordName, "title");
|
record = utils.createRecord(recordFolder, recordName, "title");
|
||||||
utils.declareRecord(record);
|
utils.completeRecord(record);
|
||||||
|
|
||||||
// link record to second record folder
|
// link record to second record folder
|
||||||
nodeService.addChild(recordFolder2, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, recordName));
|
nodeService.addChild(recordFolder2, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, recordName));
|
||||||
|
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.job;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.springframework.extensions.webscripts.GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test automatic disposition via scheduled job.
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
public class AutomaticDispositionTest extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
/** additional job context to override job frequency */
|
||||||
|
protected String[] getConfigLocations()
|
||||||
|
{
|
||||||
|
return new String[]
|
||||||
|
{
|
||||||
|
"classpath:alfresco/application-context.xml",
|
||||||
|
"classpath:test-context.xml",
|
||||||
|
"classpath:test-job-context.xml"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given there is a complete record eligible for cut off, when the correct frequency of time passes, then
|
||||||
|
* the record will be automatically cut off
|
||||||
|
*/
|
||||||
|
public void testAutomaticCutOff()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
NodeRef sourceCategory;
|
||||||
|
NodeRef sourceRecordFolder;
|
||||||
|
NodeRef record;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create test data
|
||||||
|
sourceCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
DispositionSchedule dis = utils.createBasicDispositionSchedule(sourceCategory, GUID.generate(), GUID.generate(), true, false);
|
||||||
|
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||||
|
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||||
|
adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
|
||||||
|
adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||||
|
dispositionService.addDispositionActionDefinition(dis, adParams);
|
||||||
|
sourceRecordFolder = recordFolderService.createRecordFolder(sourceCategory, GUID.generate());
|
||||||
|
|
||||||
|
// create and complete record
|
||||||
|
record = utils.createRecord(sourceRecordFolder, GUID.generate());
|
||||||
|
utils.completeRecord(record);
|
||||||
|
|
||||||
|
// check the disposition action details
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertNotNull(CutOffAction.NAME, dispositionAction.getName());
|
||||||
|
assertTrue(dispositionService.isNextDispositionActionEligible(record));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when() throws Exception
|
||||||
|
{
|
||||||
|
// sleep .. allowing the job time to execute
|
||||||
|
Thread.sleep(30000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
// record should now be cut off
|
||||||
|
assertTrue(dispositionService.isDisposableItemCutoff(record));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO automatic retain
|
||||||
|
|
||||||
|
// TODO automatic destroy
|
||||||
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.job;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Suite;
|
||||||
|
import org.junit.runners.Suite.SuiteClasses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job integration test suite
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
@RunWith(Suite.class)
|
||||||
|
@SuiteClasses(
|
||||||
|
{
|
||||||
|
AutomaticDispositionTest.class
|
||||||
|
})
|
||||||
|
public class JobTestSuite
|
||||||
|
{
|
||||||
|
}
|
@@ -64,7 +64,7 @@ public class CompositeCapabilityTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||||
|
|
||||||
utils.declareRecord(declaredRecord);
|
utils.completeRecord(declaredRecord);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -106,9 +106,9 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||||
|
|
||||||
utils.declareRecord(declaredRecord);
|
utils.completeRecord(declaredRecord);
|
||||||
utils.declareRecord(frozenRecord);
|
utils.completeRecord(frozenRecord);
|
||||||
utils.declareRecord(frozenRecord2);
|
utils.completeRecord(frozenRecord2);
|
||||||
|
|
||||||
hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description");
|
hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description");
|
||||||
|
|
||||||
|
@@ -563,8 +563,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
public QName execute() throws Throwable
|
public QName execute() throws Throwable
|
||||||
{
|
{
|
||||||
utils.declareRecord(testRecord1);
|
utils.completeRecord(testRecord1);
|
||||||
utils.declareRecord(testRecord2);
|
utils.completeRecord(testRecord2);
|
||||||
|
|
||||||
Map <String, Serializable> params = new HashMap<String, Serializable>();
|
Map <String, Serializable> params = new HashMap<String, Serializable>();
|
||||||
params.put("referenceType", refType.toString());
|
params.put("referenceType", refType.toString());
|
||||||
@@ -755,8 +755,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
utils.declareRecord(testRecord1);
|
utils.completeRecord(testRecord1);
|
||||||
utils.declareRecord(testRecord2);
|
utils.completeRecord(testRecord2);
|
||||||
|
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
RecordsManagementPolicies.BEFORE_CREATE_REFERENCE,
|
RecordsManagementPolicies.BEFORE_CREATE_REFERENCE,
|
||||||
|
@@ -89,11 +89,15 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
implements RecordsManagementModel, ContentModel, RMPermissionModel
|
implements RecordsManagementModel, ContentModel, RMPermissionModel
|
||||||
{
|
{
|
||||||
/** Application context */
|
/** Application context */
|
||||||
protected static final String[] CONFIG_LOCATIONS = new String[]
|
protected String[] getConfigLocations()
|
||||||
{
|
{
|
||||||
"classpath:alfresco/application-context.xml",
|
return new String[]
|
||||||
"classpath:test-context.xml"
|
{
|
||||||
};
|
"classpath:alfresco/application-context.xml",
|
||||||
|
"classpath:test-context.xml",
|
||||||
|
"classpath:test-job-context.xml"
|
||||||
|
};
|
||||||
|
}
|
||||||
protected ApplicationContext applicationContext;
|
protected ApplicationContext applicationContext;
|
||||||
|
|
||||||
/** test model constants */
|
/** test model constants */
|
||||||
@@ -310,7 +314,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
protected void setUp() throws Exception
|
protected void setUp() throws Exception
|
||||||
{
|
{
|
||||||
// Get the application context
|
// Get the application context
|
||||||
applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
|
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
||||||
utils = new CommonRMTestUtils(applicationContext);
|
utils = new CommonRMTestUtils(applicationContext);
|
||||||
|
|
||||||
// Initialise the service beans
|
// Initialise the service beans
|
||||||
@@ -484,8 +488,8 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
if (isRecordTest())
|
if (isRecordTest())
|
||||||
{
|
{
|
||||||
// declare a record
|
// declare a record
|
||||||
utils.declareRecord(recordDeclaredOne);
|
utils.completeRecord(recordDeclaredOne);
|
||||||
utils.declareRecord(recordDeclaredTwo);
|
utils.completeRecord(recordDeclaredTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unfiled container
|
// unfiled container
|
||||||
|
@@ -227,7 +227,10 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
return recordOne;
|
return recordOne;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void declareRecord(final NodeRef record)
|
/**
|
||||||
|
* Helper method to complete record.
|
||||||
|
*/
|
||||||
|
public void completeRecord(final NodeRef record)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
|
18
rm-server/test/resources/test-job-context.xml
Normal file
18
rm-server/test/resources/test-job-context.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<bean id="scheduledDispositionLifecyceleJobTrigger" class="org.alfresco.util.CronTriggerBean">
|
||||||
|
<property name="jobDetail">
|
||||||
|
<ref bean="scheduledDispositionLifecyceleJobDetail" />
|
||||||
|
</property>
|
||||||
|
<property name="scheduler">
|
||||||
|
<ref bean="schedulerFactory" />
|
||||||
|
</property>
|
||||||
|
<property name="cronExpression">
|
||||||
|
<value>0/30 * * * * ?</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
Reference in New Issue
Block a user