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:
@@ -43,29 +43,33 @@ eclipse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task resetDatabase << {
|
task resetDatabase << {
|
||||||
// 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' )
|
|
||||||
ant.property(resource: 'alfresco/domain/transaction.properties', classpath: configurations.compile.asPath )
|
|
||||||
ant.property(resource: 'alfresco/version.properties', classpath: configurations.compile.asPath )
|
|
||||||
ant.property(resource: 'alfresco/repository.properties', classpath: configurations.compile.asPath )
|
|
||||||
|
|
||||||
// Set default values if nothing was found (remember Ant props are 'first set wins')
|
if(System.properties.getProperty('DB_PROPERTIES') != null)
|
||||||
ant.property(name: "db.name", value: "alfresco")
|
{
|
||||||
ant.property(name: "db.url", value: "jdbc:postgresql:alfresco")
|
// Loading the properties in all possible locations
|
||||||
ant.property(name: "db.master.url", value: "jdbc:postgresql:template1")
|
ant.property(file: System.properties.getProperty('DB_PROPERTIES') )
|
||||||
ant.property(name: "db.username", value: "alfresco")
|
ant.property(file: System.properties.getProperty('user.home')+'/alfresco/extension/repository.properties' )
|
||||||
ant.property(name: "db.password", value: "alfresco")
|
ant.property(resource: 'alfresco/domain/transaction.properties', classpath: configurations.compile.asPath )
|
||||||
|
ant.property(resource: 'alfresco/version.properties', classpath: configurations.compile.asPath )
|
||||||
|
ant.property(resource: 'alfresco/repository.properties', classpath: configurations.compile.asPath )
|
||||||
|
|
||||||
println "Recreating database " + ant.getProperty("db.name") + " as user " + ant.getProperty("db.username")
|
// Set default values if nothing was found (remember Ant props are 'first set wins')
|
||||||
ant.sql(driver: 'org.postgresql.Driver',
|
ant.property(name: "db.name", value: "alfresco")
|
||||||
url: ant.getProperty("db.master.url"),
|
ant.property(name: "db.url", value: "jdbc:postgresql:alfresco")
|
||||||
userid: ant.getProperty("db.username"),
|
ant.property(name: "db.master.url", value: "jdbc:postgresql:template1")
|
||||||
password: ant.getProperty("db.password"),
|
ant.property(name: "db.username", value: "alfresco")
|
||||||
print: 'true',
|
ant.property(name: "db.password", value: "alfresco")
|
||||||
autocommit: 'true',
|
|
||||||
classpath: configurations.compile.asPath,
|
println "Recreating database " + ant.getProperty("db.name") + " as user " + ant.getProperty("db.username")
|
||||||
'drop database if exists ' + ant.getProperty("db.name") + '; create database ' + ant.getProperty("db.name") + ';')
|
ant.sql(driver: 'org.postgresql.Driver',
|
||||||
|
url: ant.getProperty("db.master.url"),
|
||||||
|
userid: ant.getProperty("db.username"),
|
||||||
|
password: ant.getProperty("db.password"),
|
||||||
|
print: 'true',
|
||||||
|
autocommit: 'true',
|
||||||
|
classpath: configurations.compile.asPath,
|
||||||
|
'drop database if exists ' + ant.getProperty("db.name") + '; create database ' + ant.getProperty("db.name") + ';')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
@@ -605,7 +605,7 @@
|
|||||||
<bean id="modelSecurityService"
|
<bean id="modelSecurityService"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityServiceImpl"
|
class="org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityServiceImpl"
|
||||||
init-method="init">
|
init-method="init">
|
||||||
<property name="enabled" value="false" />
|
<property name="enabled" value="true" />
|
||||||
<property name="policyComponent" ref="policyComponent" />
|
<property name="policyComponent" ref="policyComponent" />
|
||||||
<property name="nodeService" ref="NodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="namespaceService" ref="namespaceService" />
|
<property name="namespaceService" ref="namespaceService" />
|
||||||
|
@@ -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(RecordsManagementAdminServiceImplTest.class);
|
||||||
suite.addTestSuite(RecordsManagementAuditServiceImplTest.class);
|
suite.addTestSuite(RecordsManagementAuditServiceImplTest.class);
|
||||||
//suite.addTestSuite(RecordsManagementEventServiceImplTest.class);
|
//suite.addTestSuite(RecordsManagementEventServiceImplTest.class);
|
||||||
//suite.addTestSuite(RecordsManagementSecurityServiceImplTest.class);
|
|
||||||
suite.addTestSuite(RecordsManagementSearchServiceImplTest.class);
|
suite.addTestSuite(RecordsManagementSearchServiceImplTest.class);
|
||||||
suite.addTestSuite(VitalRecordServiceImplTest.class);
|
suite.addTestSuite(VitalRecordServiceImplTest.class);
|
||||||
suite.addTestSuite(DataSetServiceImplTest.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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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.DispositionSchedule;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
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.RecordsManagementModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
@@ -36,6 +37,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
private RecordsManagementActionService actionService;
|
private RecordsManagementActionService actionService;
|
||||||
|
private ModelSecurityService modelSecurityService;
|
||||||
|
|
||||||
/** test values */
|
/** test values */
|
||||||
public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority";
|
public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority";
|
||||||
@@ -51,6 +53,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
nodeService = (NodeService)applicationContext.getBean("NodeService");
|
nodeService = (NodeService)applicationContext.getBean("NodeService");
|
||||||
contentService = (ContentService)applicationContext.getBean("ContentService");
|
contentService = (ContentService)applicationContext.getBean("ContentService");
|
||||||
actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService");
|
actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService");
|
||||||
|
modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,16 +154,24 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
@Override
|
@Override
|
||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
// Declare record
|
modelSecurityService.setEnabled(false);
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
|
try
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_MEDIA_TYPE, "mediaTypeValue");
|
{
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_FORMAT, "formatValue");
|
// Declare record
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_RECEIVED, new Date());
|
nodeService.setProperty(record, RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
nodeService.setProperty(record, RecordsManagementModel.PROP_MEDIA_TYPE, "mediaTypeValue");
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_ORIGINATOR, "origValue");
|
nodeService.setProperty(record, RecordsManagementModel.PROP_FORMAT, "formatValue");
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_RECEIVED, new Date());
|
||||||
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
||||||
actionService.executeRecordsManagementAction(record, "declareRecord");
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user