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:
Roy Wetherall
2012-12-21 04:09:10 +00:00
parent 5a465649cd
commit 2311e18d0a
8 changed files with 48 additions and 186 deletions

View File

@@ -43,6 +43,9 @@ eclipse {
}
task resetDatabase << {
if(System.properties.getProperty('DB_PROPERTIES') != null)
{
// Loading the properties in all possible locations
ant.property(file: System.properties.getProperty('DB_PROPERTIES') )
ant.property(file: System.properties.getProperty('user.home')+'/alfresco/extension/repository.properties' )
@@ -66,6 +69,7 @@ task resetDatabase << {
autocommit: 'true',
classpath: configurations.compile.asPath,
'drop database if exists ' + ant.getProperty("db.name") + '; create database ' + ant.getProperty("db.name") + ';')
}
}
test {

View File

@@ -605,7 +605,7 @@
<bean id="modelSecurityService"
class="org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityServiceImpl"
init-method="init">
<property name="enabled" value="false" />
<property name="enabled" value="true" />
<property name="policyComponent" ref="policyComponent" />
<property name="nodeService" ref="NodeService" />
<property name="namespaceService" ref="namespaceService" />

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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();

View File

@@ -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);
}
}

View File

@@ -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");
}
/**
@@ -150,6 +153,9 @@ public class CommonRMTestUtils implements RecordsManagementModel
{
@Override
public Void doWork() throws Exception
{
modelSecurityService.setEnabled(false);
try
{
// Declare record
nodeService.setProperty(record, RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
@@ -161,6 +167,11 @@ public class CommonRMTestUtils implements RecordsManagementModel
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;
}