mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
RM: Unit test fixing up
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@44898 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.jscript.RMJScriptTest;
|
||||
|
||||
|
||||
/**
|
||||
* RM JScript test suite
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class JScriptTestSuite extends TestSuite
|
||||
{
|
||||
/**
|
||||
* Creates the test suite
|
||||
*
|
||||
* @return the test suite
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTestSuite(RMJScriptTest.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
@@ -59,7 +59,6 @@ public class ServicesTestSuite extends TestSuite
|
||||
suite.addTestSuite(RecordsManagementAdminServiceImplTest.class);
|
||||
suite.addTestSuite(RecordsManagementAuditServiceImplTest.class);
|
||||
//suite.addTestSuite(RecordsManagementEventServiceImplTest.class);
|
||||
//suite.addTestSuite(RecordsManagementSecurityServiceImplTest.class);
|
||||
suite.addTestSuite(RecordsManagementSearchServiceImplTest.class);
|
||||
suite.addTestSuite(VitalRecordServiceImplTest.class);
|
||||
suite.addTestSuite(DataSetServiceImplTest.class);
|
||||
|
@@ -1,18 +0,0 @@
|
||||
function main()
|
||||
{
|
||||
test.assertNotNull(filePlan);
|
||||
test.assertNotNull(record);
|
||||
|
||||
var rmNode = rmService.getRecordsManagementNode(record);
|
||||
test.assertNotNull(rmNode);
|
||||
|
||||
var capabilities = rmNode.capabilities;
|
||||
var countCheck = capabilities.length != 0;
|
||||
test.assertTrue(countCheck);
|
||||
|
||||
var capability = capabilities[0];
|
||||
test.assertNotNull(capability);
|
||||
test.assertNotNull(capability.name);
|
||||
}
|
||||
|
||||
main();
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.jscript;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.jscript.ClasspathScriptLocation;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.ScriptLocation;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RMJScriptTest extends BaseRMTestCase
|
||||
{
|
||||
private static String SCRIPT_PATH = "org/alfresco/module/org_alfresco_module_rm/test/jscript/";
|
||||
private static String CAPABILITIES_TEST = "CapabilitiesTest.js";
|
||||
|
||||
private ScriptService scriptService;
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
this.scriptService = (ScriptService)this.applicationContext.getBean("ScriptService");
|
||||
}
|
||||
|
||||
private NodeRef record;
|
||||
public void testCapabilities() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
record = utils.createRecord(rmFolder, "testRecord.txt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
utils.declareRecord(record);
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
|
||||
// Create a model to pass to the unit test scripts
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
model.put("filePlan", filePlan);
|
||||
model.put("record", record);
|
||||
|
||||
executeScript(CAPABILITIES_TEST, model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void executeScript(String script, Map<String, Object> model)
|
||||
{
|
||||
// Execute the unit test script
|
||||
ScriptLocation location = new ClasspathScriptLocation(SCRIPT_PATH + script);
|
||||
this.scriptService.executeScript(location, model);
|
||||
}
|
||||
}
|
@@ -290,7 +290,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
initServices();
|
||||
|
||||
// Setup test data
|
||||
setupTestData();
|
||||
setupTestData();
|
||||
|
||||
// Create multi hierarchy data
|
||||
if (isMultiHierarchyTest() == true)
|
||||
|
@@ -16,6 +16,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.impl.FreezeAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
@@ -36,6 +37,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
private NodeService nodeService;
|
||||
private ContentService contentService;
|
||||
private RecordsManagementActionService actionService;
|
||||
private ModelSecurityService modelSecurityService;
|
||||
|
||||
/** test values */
|
||||
public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority";
|
||||
@@ -51,6 +53,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
nodeService = (NodeService)applicationContext.getBean("NodeService");
|
||||
contentService = (ContentService)applicationContext.getBean("ContentService");
|
||||
actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService");
|
||||
modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,16 +154,24 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Declare record
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_MEDIA_TYPE, "mediaTypeValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_FORMAT, "formatValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_RECEIVED, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_ORIGINATOR, "origValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
||||
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
||||
actionService.executeRecordsManagementAction(record, "declareRecord");
|
||||
modelSecurityService.setEnabled(false);
|
||||
try
|
||||
{
|
||||
// Declare record
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_MEDIA_TYPE, "mediaTypeValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_FORMAT, "formatValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_RECEIVED, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_ORIGINATOR, "origValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
||||
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
||||
actionService.executeRecordsManagementAction(record, "declareRecord");
|
||||
}
|
||||
finally
|
||||
{
|
||||
modelSecurityService.setEnabled(true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user