RM-3132 (Update license headers)

This commit is contained in:
Tuna Aksoy
2016-03-15 14:31:14 +00:00
parent 938c5ef372
commit 5c612f4632
14 changed files with 354 additions and 368 deletions

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -30,21 +30,20 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Integration test for RM-1887
*
*
* @author Roy Wetherall
* @since 2.3
*/
public class RM1887Test extends BaseRMTestCase
{
public class RM1887Test extends BaseRMTestCase
{
@Override
protected boolean isRecordTest()
{
return true;
}
/**
* Given that a record is unfiled
* And an unfiled folder has been created
@@ -54,38 +53,38 @@ public class RM1887Test extends BaseRMTestCase
public void testMoveUnfiledRecord() throws Exception
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
{
private NodeRef unfiledRecordFolder;
private NodeRef unfiledRecord;
public void given() throws Exception
{
// create unfiled folder
unfiledRecordFolder = fileFolderService.create(filePlanService.getUnfiledContainer(filePlan), "my test folder", TYPE_UNFILED_RECORD_FOLDER).getNodeRef();
// crate unfiled record
unfiledRecord = recordService.createRecordFromContent(filePlan, "test.txt", TYPE_CONTENT, null, null);
// check the record
assertTrue(recordService.isRecord(unfiledRecord));
assertFalse(recordService.isFiled(unfiledRecord));
}
public void when() throws Exception
{
{
// move the record into the unfiled folder
fileFolderService.move(unfiledRecord, unfiledRecordFolder, null);
}
}
public void then()
{
// check the record
assertTrue(recordService.isRecord(unfiledRecord));
assertFalse(recordService.isFiled(unfiledRecord));
}
});
});
}
}

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -41,111 +41,110 @@ import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.rule.RuleType;
/**
* System test for RM-2072: Concurrency exceptions and deadlocks on Records Management "File to" rule
*
*
* @author Roy Wetherall
* @since 2.2.1.1
*/
public class RM2072Test extends BaseRMTestCase
{
public class RM2072Test extends BaseRMTestCase
{
private static final int NUMBER_OF_BATCHES = 1;
private static final int NUMBER_IN_BATCH = 500;
private RuleService ruleService;
private RuleService ruleService;
private NodeRef ruleFolder;
@Override
protected void initServices()
{
super.initServices();
ruleService = (RuleService)applicationContext.getBean("RuleService");
}
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
@Override
protected boolean isRecordTest()
{
return true;
}
/**
* Given that I have auto declare configured
* Given that I have auto declare configured
* And that I have auto file configured to a path where only the record folder needs to be created
* When I add lots of documents in the same transaction
* Then the rules should fire
* And the documents should be filed in the new record folder
*/
*/
public void testAutoDeclareAutoFileCreateRecordFolderOnly() throws Exception
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
{
// create the folder
ruleFolder = fileFolderService.create(documentLibrary, "mytestfolder", ContentModel.TYPE_FOLDER).getNodeRef();
ruleFolder = fileFolderService.create(documentLibrary, "mytestfolder", ContentModel.TYPE_FOLDER).getNodeRef();
// create record category
NodeRef nodeRefA = filePlanService.createRecordCategory(filePlan, "A");
NodeRef nodeRefB = filePlanService.createRecordCategory(nodeRefA, "B");
filePlanService.createRecordCategory(nodeRefB, "C");
Action action = actionService.createAction(CreateRecordAction.NAME);
action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
Rule rule = new Rule();
rule.setRuleType(RuleType.INBOUND);
rule.setTitle("my rule");
rule.setAction(action);
rule.setExecuteAsynchronously(true);
ruleService.saveRule(ruleFolder, rule);
Action fileAction = actionService.createAction(FileToAction.NAME);
fileAction.setParameterValue(FileToAction.PARAM_PATH, "/A/B/C/{date.year.long}/{date.month.long}/{date.day.month}");
fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true);
Rule fileRule = new Rule();
fileRule.setRuleType(RuleType.INBOUND);
fileRule.setTitle("my rule");
fileRule.setAction(fileAction);
fileRule.setExecuteAsynchronously(true);
ruleService.saveRule(filePlanService.getUnfiledContainer(filePlan), fileRule);
return null;
}
@Override
public void test(Void result) throws Exception
public void test(Void result) throws Exception
{
assertFalse(ruleService.getRules(ruleFolder).isEmpty());
}
});
List<NodeRef> records = new ArrayList<NodeRef>(NUMBER_OF_BATCHES*NUMBER_IN_BATCH);
for (int i = 0; i < NUMBER_OF_BATCHES; i++)
for (int i = 0; i < NUMBER_OF_BATCHES; i++)
{
final int finali = i;
records.addAll(doTestInTransaction(new Test<List<NodeRef>>()
{
@Override
public List<NodeRef> run() throws Exception
{
{
List<NodeRef> records = new ArrayList<NodeRef>(NUMBER_IN_BATCH);
for (int j = 0; j < NUMBER_IN_BATCH; j++)
{
for (int j = 0; j < NUMBER_IN_BATCH; j++)
{
int count = (finali+1)*(j+1);
String name = "content" + count + ".txt";
System.out.println(name + " - creating");
NodeRef record = fileFolderService.create(ruleFolder, name, ContentModel.TYPE_CONTENT).getNodeRef();
records.add(record);
}
@@ -153,13 +152,13 @@ public class RM2072Test extends BaseRMTestCase
}
}));
}
try
{
while(!records.isEmpty())
{
Thread.sleep(1000);
final Iterator<NodeRef> temp = records.iterator();
doTestInTransaction(new Test<Void>()
{
@@ -176,7 +175,7 @@ public class RM2072Test extends BaseRMTestCase
temp.remove();
}
}
return null;
}
});

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -31,39 +31,38 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.module.org_alfresco_module_rm.test.util.TestService;
/**
* System test for RM-452
*
*
* See alfresco.extension.rm-method-security.properties
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RM452Test extends BaseRMTestCase
public class RM452Test extends BaseRMTestCase
{
private TestService testService;
@Override
protected void initServices()
{
super.initServices();
testService = (TestService)applicationContext.getBean("TestService");
}
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
@Override
protected boolean isRecordTest()
{
return true;
}
public void testRM452() throws Exception
{
doTestInTransaction(new Test<Void>()
@@ -75,27 +74,27 @@ public class RM452Test extends BaseRMTestCase
assertNotNull(recordOne);
assertFalse(filePlanService.isFilePlanComponent(folder));
assertTrue(filePlanService.isFilePlanComponent(recordOne));
// call methodOne with non-RM artifact .. expect success
testService.testMethodOne(folder);
// call methodTwo with non-RM artifact .. expect success
testService.testMethodTwo(folder);
// call methodOne with an RM artifact .. expect success
testService.testMethodOne(recordOne);
testService.testMethodOne(recordOne);
return null;
}
});
doTestInTransaction(new FailureTest
(
"Shouldn't be able to call testMethodTwo on TestService, because override RM security for method is not configred.",
"Shouldn't be able to call testMethodTwo on TestService, because override RM security for method is not configred.",
AlfrescoRuntimeException.class
)
{
@Override
public void run() throws Exception
{

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -33,7 +33,6 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.site.SiteRole;
/**
* Unit test for RM-804 .. site managers are able to delete file plans
*

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -32,33 +32,32 @@ import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.Period;
/**
* System test for RM-994
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RM994Test extends BaseRMTestCase
{
public class RM994Test extends BaseRMTestCase
{
@Override
protected void initServices()
{
super.initServices();
}
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
@Override
protected boolean isRecordTest()
{
return true;
}
public void testRM944() throws Exception
{
doTestInTransaction(new Test<Void>()
@@ -68,51 +67,51 @@ public class RM994Test extends BaseRMTestCase
{
checkVitalRecordNotSet(rmContainer);
checkVitalRecordNotSet(rmFolder);
checkVitalRecordNotSet(recordOne);
checkVitalRecordNotSet(recordOne);
assertNull(nodeService.getProperty(recordOne, PROP_REVIEW_AS_OF));
vitalRecordService.setVitalRecordDefintion(rmContainer, true, new Period("month|1"));
vitalRecordService.setVitalRecordDefintion(rmContainer, true, new Period("month|1"));
return null;
}
});
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
{
checkVitalRecordSet(rmContainer);
checkVitalRecordSet(rmFolder);
checkVitalRecordSet(recordOne);
checkVitalRecordSet(recordOne);
assertNotNull(nodeService.getProperty(recordOne, PROP_REVIEW_AS_OF));
recordService.createRecord(filePlan, dmDocument, true);
assertTrue(recordService.isRecord(dmDocument));
checkVitalRecordNotSet(dmDocument);
fileFolderService.move(dmDocument, rmFolder, null);
checkVitalRecordSet(dmDocument);
checkVitalRecordSet(dmDocument);
return null;
}
}, "admin");
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
checkVitalRecordSet(dmDocument);
{
checkVitalRecordSet(dmDocument);
return null;
}
});
}
private void checkVitalRecordSet(NodeRef nodeRef)
{
VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef);
@@ -121,14 +120,14 @@ public class RM994Test extends BaseRMTestCase
assertEquals("month", def.getReviewPeriod().getPeriodType());
assertEquals("1", def.getReviewPeriod().getExpression());
}
private void checkVitalRecordNotSet(NodeRef nodeRef)
{
VitalRecordDefinition recordDef = vitalRecordService.getVitalRecordDefinition(nodeRef);
if (recordDef != null)
{
assertFalse(recordDef.isEnabled());
assertEquals("none", recordDef.getReviewPeriod().getPeriodType());
assertEquals("none", recordDef.getReviewPeriod().getPeriodType());
assertNull(recordDef.getNextReviewDate());
}
}

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -38,15 +38,14 @@ import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
/**
* Test recorded version histories when interacting with cm:versionable aspect
* Test recorded version histories when interacting with cm:versionable aspect
* and the auto-version behvaiour.
*
*
* @author Roy Wetherall
* @since 2.3.1
*/
public class AutoVersionTest extends RecordableVersionsBaseTest
public class AutoVersionTest extends RecordableVersionsBaseTest
{
/**
* Given a versionable document
@@ -59,36 +58,36 @@ public class AutoVersionTest extends RecordableVersionsBaseTest
doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator)
{
private NodeRef myDocument;
public void given() throws Exception
{
// create a document
myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
// make versionable
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null);
}
public void when()
{
{
// specialise document
nodeService.setType(myDocument, TYPE_CUSTOM_TYPE);
}
}
public void then()
{
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef();
assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(frozenState));
assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument));
}
});
}
});
}
/**
* Given a versionable document with initial version turned off
* When I specialise the type of the document
@@ -99,32 +98,32 @@ public class AutoVersionTest extends RecordableVersionsBaseTest
doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator)
{
private NodeRef myDocument;
public void given() throws Exception
{
// create a document
myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
// make versionable
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_INITIAL_VERSION, false);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props);
}
public void when()
{
{
// specialise document
nodeService.setType(myDocument, TYPE_CUSTOM_TYPE);
}
}
public void then()
{
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNull(versionHistory);
}
});
}
});
}
/**
* Given a versionable document with initial version turned off
* And auto version on type change is set on
@@ -137,48 +136,48 @@ public class AutoVersionTest extends RecordableVersionsBaseTest
{
private ExtendedVersionableAspect extendedVersionableAspect;
private NodeRef myDocument;
public void given() throws Exception
{
// turn auto version on type change on
extendedVersionableAspect = (ExtendedVersionableAspect)applicationContext.getBean("rm.extendedVersionableAspect");
assertNotNull(extendedVersionableAspect);
extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// create a document
myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
// make versionable
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_INITIAL_VERSION, false);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props);
}
public void when()
{
{
// specialise document
nodeService.setType(myDocument, TYPE_CUSTOM_TYPE);
}
}
public void then()
{
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef();
assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(frozenState));
assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument));
}
public void after() throws Exception
{
// reset auto version on type to default off
extendedVersionableAspect.setAutoVersionOnTypeChange(false);
}
});
}
});
}
/**
* Given a versionable document with initial version turned on
* And auto version on type change is set on
@@ -191,51 +190,51 @@ public class AutoVersionTest extends RecordableVersionsBaseTest
{
private ExtendedVersionableAspect extendedVersionableAspect;
private NodeRef myDocument;
public void given() throws Exception
{
// turn auto version on type change on
extendedVersionableAspect = (ExtendedVersionableAspect)applicationContext.getBean("rm.extendedVersionableAspect");
assertNotNull(extendedVersionableAspect);
extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// create a document
myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
// make versionable
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_INITIAL_VERSION, true);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, props);
}
public void when()
{
{
// specialise document
nodeService.setType(myDocument, TYPE_CUSTOM_TYPE);
}
}
public void then()
{
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
NodeRef frozenState = versionHistory.getHeadVersion().getFrozenStateNodeRef();
assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(frozenState));
assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument));
frozenState = versionHistory.getVersion("1.0").getFrozenStateNodeRef();
assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(frozenState));
assertEquals(TYPE_CUSTOM_TYPE, nodeService.getType(myDocument));
}
public void after() throws Exception
{
// reset auto version on type to default off
extendedVersionableAspect.setAutoVersionOnTypeChange(false);
}
});
}
});
}
}

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -50,14 +50,13 @@ import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
/**
* Recordable version history integration tests.
*
*
* @author Roy Wetherall
* @since 2.3.1
*/
public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
{
/**
* Given that a document is created
@@ -65,78 +64,78 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
* When I delete the version record
* Then the version is deleted
* And the version history is not deleted
*
*
* @see https://issues.alfresco.com/jira/browse/RM-2562
*/
public void testDeleteFirstRecordedVersion()
public void testDeleteFirstRecordedVersion()
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
private NodeRef myDocument;
public void given() throws Exception
{
// create a document
myDocument = fileFolderService.create(dmFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
// make versionable
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL);
props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan);
nodeService.addAspect(myDocument, RecordableVersionModel.ASPECT_VERSIONABLE, props);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null);
}
public void when()
{
// check the initial version label
{
// check the initial version label
assertEquals("1.0", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL));
// check that the version history contains a single version that is recorded
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
assertEquals(1, versionHistory.getAllVersions().size());
// check the recorded version is not marked as destroyed
Version head = versionHistory.getHeadVersion();
assertNotNull(head);
assertFalse(recordableVersionService.isRecordedVersionDestroyed(head));
// check the version record
NodeRef record = recordableVersionService.getVersionRecord(head);
assertTrue(recordService.isRecord(record));
// record should not have a version history because it is immutable
assertFalse(nodeService.hasAspect(record, ContentModel.ASPECT_VERSIONABLE));
VersionHistory recordVersionHistory = versionService.getVersionHistory(record);
assertNull(recordVersionHistory);
// destroy record
nodeService.deleteNode(record);
}
}
public void then()
{
// document is still versionable
assertTrue(nodeService.hasAspect(myDocument, ContentModel.ASPECT_VERSIONABLE));
// check the initial version label
// check the initial version label
assertEquals("1.0", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL));
// still has a version history, but the version is marked as destroyed
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
assertEquals(1, versionHistory.getAllVersions().size());
// check the recorded version is marked as destroyed and the record version is not longer available
Version version = versionHistory.getHeadVersion();
assertNotNull(version);
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version));
assertNull(recordableVersionService.getVersionRecord(version));
}
});
}
});
}
/**
* Given that a document is created
* And the initial version is record
@@ -144,15 +143,15 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
* When a new version is created
* Then a new associated version record is created
* And the version is 1.1 (not 1.0 since this was deleted, but the version history maintained)
*
*
* @see https://issues.alfresco.com/jira/browse/RM-2562
*/
public void testDeleteFirstRecordedVersionAndCreateNewVersion()
public void testDeleteFirstRecordedVersionAndCreateNewVersion()
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
private NodeRef myDocument;
public void given() throws Exception
{
// create a document
@@ -161,67 +160,67 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
writer.setEncoding("UTF-8");
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.putContent(GUID.generate());
// make versionable
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
props.put(RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL);
props.put(RecordableVersionModel.PROP_FILE_PLAN, filePlan);
nodeService.addAspect(myDocument, RecordableVersionModel.ASPECT_VERSIONABLE, props);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null);
nodeService.addAspect(myDocument, ContentModel.ASPECT_VERSIONABLE, null);
}
public void when()
{
{
// get the created version record
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
Version head = versionHistory.getHeadVersion();
NodeRef record = recordableVersionService.getVersionRecord(head);
// destroy record
nodeService.deleteNode(record);
// update the content to create a new version (and version record)
ContentWriter writer = fileFolderService.getWriter(myDocument);
writer.putContent(GUID.generate());
}
}
public void then()
{
// document is still versionable
assertTrue(nodeService.hasAspect(myDocument, ContentModel.ASPECT_VERSIONABLE));
// check the version number has been incremented
assertEquals("1.1", nodeService.getProperty(myDocument, ContentModel.PROP_VERSION_LABEL));
// still has a version history, with 2 enties
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
// latest version is current
Version head = versionHistory.getHeadVersion();
assertFalse(recordableVersionService.isRecordedVersionDestroyed(head));
assertNotNull(recordableVersionService.getVersionRecord(head));
// first version is destroyed
Version destroyed = versionHistory.getPredecessor(head);
assertTrue(recordableVersionService.isRecordedVersionDestroyed(destroyed));
assertNull(recordableVersionService.getVersionRecord(destroyed));
// get the version record for the current version
NodeRef versionRecord = recordableVersionService.getVersionRecord(head);
assertNotNull(versionRecord);
assertTrue(nodeService.exists(versionRecord));
Set<Relationship> from = relationshipService.getRelationshipsFrom(versionRecord);
assertTrue(from.isEmpty());
Set<Relationship> to = relationshipService.getRelationshipsTo(versionRecord);
assertTrue(to.isEmpty());
}
});
}
});
}
/**
* Given a chain of version records (1.0, 1.1, 1.2) which are all related
* When I delete version record 1.0
@@ -230,26 +229,26 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
public void testDeleteOldestVersion()
{
final NodeRef myDocument = createDocumentWithRecordVersions();
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
private VersionHistory versionHistory;
public void given() throws Exception
{
// get version history
versionHistory = versionService.getVersionHistory(myDocument);
}
public void when()
{
{
Version version10 = versionHistory.getVersion("1.0");
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
// delete record version 1.0
nodeService.deleteNode(recordVersion10);
}
}
public void then()
{
// check the deleted version
@@ -258,33 +257,33 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version10));
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
assertNull(recordVersion10);
// verify 1.2 setup as expected
Version version12 = versionHistory.getHeadVersion();
assertEquals("1.2", version12.getVersionLabel());
NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12);
assertNotNull(recordVersion12);
assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
Set<Relationship> from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, from12.size());
// verify 1.1 setup as expected
Version version11 = versionHistory.getPredecessor(version12);
assertEquals("1.1", version11.getVersionLabel());
NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11);
assertNotNull(recordVersion11);
Set<Relationship> to11 = relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, to11.size());
assertEquals(recordVersion12, to11.iterator().next().getSource());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
}
});
});
}
/**
* Given a chain of version records (1.0, 1.1, 1.2) which are all related
* When I delete version record 1.1
@@ -293,26 +292,26 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
public void testDeleteMiddleVersion()
{
final NodeRef myDocument = createDocumentWithRecordVersions();
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
private VersionHistory versionHistory;
public void given() throws Exception
{
// get version history
versionHistory = versionService.getVersionHistory(myDocument);
}
public void when()
{
{
Version version11 = versionHistory.getVersion("1.1");
NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11);
// delete record version 1.1
nodeService.deleteNode(recordVersion11);
}
}
public void then()
{
// check the deleted version
@@ -321,34 +320,34 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11));
NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11);
assertNull(recordVersion11);
// verify 1.2 setup as expected
Version version12 = versionHistory.getHeadVersion();
assertEquals("1.2", version12.getVersionLabel());
NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12);
assertNotNull(recordVersion12);
assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
Set<Relationship> from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, from12.size());
// verify 1.0 setup as expected
Version version10 = versionHistory.getVersion("1.0");
assertEquals("1.0", version10.getVersionLabel());
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
assertNotNull(recordVersion10);
Set<Relationship> to10 = relationshipService.getRelationshipsTo(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, to10.size());
assertEquals(recordVersion12, to10.iterator().next().getSource());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
}
});
});
}
/**
* Given a chain of version records (1.0, 1.1, 1.2) which are all related
* When I delete version record 1.2
@@ -357,26 +356,26 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
public void testDeleteCurrentVersion()
{
final NodeRef myDocument = createDocumentWithRecordVersions();
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
private VersionHistory versionHistory;
public void given() throws Exception
{
// get version history
versionHistory = versionService.getVersionHistory(myDocument);
}
public void when()
{
{
Version version12 = versionHistory.getVersion("1.2");
NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12);
// delete record version 1.2
nodeService.deleteNode(recordVersion12);
}
}
public void then()
{
// check 1.2
@@ -384,33 +383,33 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
assertNotNull(version12);
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version12));
assertNull(recordableVersionService.getVersionRecord(version12));
// verify 1.1
// verify 1.1
Version version11 = versionHistory.getVersion("1.1");
assertNotNull(version11);
NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11);
assertNotNull(recordVersion11);
assertTrue(relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
Set<Relationship> from11 = relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, from11.size());
// verify 1.0
Version version10 = versionHistory.getVersion("1.0");
assertNotNull(version10);
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
assertNotNull(recordVersion10);
Set<Relationship> to10 = relationshipService.getRelationshipsTo(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, to10.size());
assertEquals(recordVersion11, to10.iterator().next().getSource());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
}
});
});
}
/**
* Given that a version record
* When the version record is destroyed whilst retaining the meta data
@@ -419,23 +418,23 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
public void testDestroyVersionRecordWithMetadata()
{
final NodeRef myDocument = createDocumentWithRecordVersions();
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
private VersionHistory versionHistory;
private NodeRef recordVersion11;
public void given() throws Exception
{
// create file plan structure
NodeRef myCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
utils.createBasicDispositionSchedule(myCategory, GUID.generate(), GUID.generate(), true, true);
NodeRef myRecordFolder = recordFolderService.createRecordFolder(myCategory, GUID.generate());
// get version history
versionHistory = versionService.getVersionHistory(myDocument);
// file and complete all the version records into my record folder
for (Version version : versionHistory.getAllVersions())
{
@@ -444,29 +443,29 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
utils.completeRecord(record);
}
}
public void when()
{
{
Version version11 = versionHistory.getVersion("1.1");
recordVersion11 = recordableVersionService.getVersionRecord(version11);
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
rmActionService.executeRecordsManagementAction(recordVersion11, CompleteEventAction.NAME, params);
rmActionService.executeRecordsManagementAction(recordVersion11, CompleteEventAction.NAME, params);
rmActionService.executeRecordsManagementAction(recordVersion11, CutOffAction.NAME);
rmActionService.executeRecordsManagementAction(recordVersion11, DestroyAction.NAME);
}
}
public void then()
{
// verify that the version history looks as expected
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
assertNotNull(versionHistory);
Collection<Version> versions = versionHistory.getAllVersions();
assertEquals(3, versions.size());
// verify 1.2 setup as expected
Version version12 = versionHistory.getHeadVersion();
assertEquals("1.2", version12.getVersionLabel());
@@ -474,26 +473,26 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12);
assertNotNull(recordVersion12);
assertFalse(recordService.isMetadataStub(recordVersion12));
assertTrue(relationshipService.getRelationshipsTo(recordVersion12, "versions").isEmpty());
Set<Relationship> from12 = relationshipService.getRelationshipsFrom(recordVersion12, "versions");
assertEquals(1, from12.size());
// verify 1.1 setup as expected
Version version11 = versionHistory.getPredecessor(version12);
assertEquals("1.1", version11.getVersionLabel());
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11));
assertNotNull(recordVersion11);
assertTrue(recordService.isMetadataStub(recordVersion11));
Set<Relationship> to11 = relationshipService.getRelationshipsTo(recordVersion11, "versions");
assertEquals(1, to11.size());
assertEquals(recordVersion12, to11.iterator().next().getSource());
Set<Relationship> from11 = relationshipService.getRelationshipsFrom(recordVersion11, "versions");
assertEquals(1, from11.size());
// verify 1.0 setup as expected
Version version10 = versionHistory.getPredecessor(version11);
assertEquals("1.0", version10.getVersionLabel());
@@ -501,14 +500,14 @@ public class DeleteRecordVersionTest extends RecordableVersionsBaseTest
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
assertNotNull(recordVersion10);
assertFalse(recordService.isMetadataStub(recordVersion10));
Set<Relationship> to10 = relationshipService.getRelationshipsTo(recordVersion10, "versions");
assertEquals(1, to10.size());
assertEquals(recordVersion11, to10.iterator().next().getSource());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, "versions").isEmpty());
}
});
});
}
}

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -38,7 +38,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
/**
* Records management service test.
*

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -40,7 +40,6 @@ import org.alfresco.util.GUID;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
public class AuditRestApiTest extends BaseRMWebScriptTestCase
{
/** URL for the REST APIs */

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -39,7 +39,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
/**
* Notification helper (system) test
*

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -34,7 +34,6 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.Group;
/**
* Utility test case to generate a report of the capabilities in the system.
*
@@ -53,7 +52,7 @@ public class GenerateCapabilityReport extends BaseRMTestCase
FileWriter writer = new FileWriter("c:\\mywork\\capabilityReport.csv");
BufferedWriter out = new BufferedWriter(writer);
try
{
{
Set<Capability> capabilities = capabilityService.getCapabilities(true);
for (Capability capability : capabilities)
{
@@ -63,7 +62,7 @@ public class GenerateCapabilityReport extends BaseRMTestCase
{
groupId = group.getId();
}
out.write(groupId);
out.write(",");
out.write(capability.getName());
@@ -76,7 +75,7 @@ public class GenerateCapabilityReport extends BaseRMTestCase
{
out.close();
}
return null;
}
});

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -41,10 +41,9 @@ import org.alfresco.util.EqualsHelper;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.extensions.webscripts.TestWebScriptServer;
/**
* Stand-alone Web Script Test Server
*
*
* @author davidc
*/
public class TestWebScriptRepoServer extends TestWebScriptServer
@@ -79,15 +78,15 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
"classpath:alfresco/web-scripts-application-context.xml",
"classpath:alfresco/web-scripts-application-context-test.xml"
};
/** A static reference to the application context being used */
private static ClassPathXmlApplicationContext ctx;
private static String appendedTestConfiguration;
private RetryingTransactionHelper retryingTransactionHelper;
private AuthenticationService authenticationService;
/**
* Sets helper that provides transaction callbacks
*/
@@ -95,7 +94,7 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
{
this.retryingTransactionHelper = retryingTransactionHelper;
}
/**
* @param authenticationService
*/
@@ -119,13 +118,13 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
{
return getTestServer(null);
}
/**
* Start up a context and get the server bean.
* <p>
* This method will close and restart the application context only if the configuration has
* changed.
*
*
* @param appendTestConfigLocation additional context file to include in the application context
* @return Test Server
*/
@@ -154,7 +153,7 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
// There is already a context with the required configuration
}
}
// Check if we need to start/restart the context
if (TestWebScriptRepoServer.ctx == null)
{
@@ -173,15 +172,15 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
TestWebScriptRepoServer.ctx = new ClassPathXmlApplicationContext(configLocations);
TestWebScriptRepoServer.appendedTestConfiguration = appendTestConfigLocation;
}
// Get the bean
TestWebScriptServer testServer = (org.alfresco.repo.web.scripts.TestWebScriptRepoServer)TestWebScriptRepoServer.ctx.getBean("webscripts.test");
return testServer;
}
/**
* Interpret a single command using the BufferedReader passed in for any data needed.
*
*
* @param line The unparsed command
* @return The textual output of the command.
*/
@@ -215,7 +214,7 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
{
executeCommand("user " + getDefaultUserName());
}
// execute command in context of currently selected user
return AuthenticationUtil.runAs(new RunAsWork<String>()
{

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -65,7 +65,6 @@ import org.mockito.Spy;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* Hold service implementation unit test
*

View File

@@ -5,21 +5,21 @@
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
*
*
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
*
* 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/>.
* #L%
@@ -40,10 +40,9 @@ import org.mockito.Mock;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
/**
* Dictionary bootstrap post processor unit test.
*
*
* @author Roy Wetherall
* @since 2.2
*/
@@ -52,31 +51,31 @@ public class DictionaryBootstrapPostProcessorUnitTest extends BaseUnitTest
/** bean id's */
private static final String BEAN_SITESERVICE_BOOTSTRAP = "siteService_dictionaryBootstrap";
private static final String BEAN_RM_DICTIONARY_BOOTSTRAP = "org_alfresco_module_rm_dictionaryBootstrap";
@Mock private ConfigurableListableBeanFactory mockedBeanFactory;
@Mock private BeanDefinition mockedBeanDefinition;
@InjectMocks private DictionaryBootstrapPostProcessor postProcessor;
/**
/**
* given the bean factory does not contain the site service bootstrap bean then ensure that it is
* not added as a dependency
*/
@Test
public void noSiteServiceBootstrapBeanAvailable()
{
// === given ====
// === given ====
doReturn(false).when(mockedBeanFactory).containsBean(BEAN_SITESERVICE_BOOTSTRAP);
// === when ===
postProcessor.postProcessBeanFactory(mockedBeanFactory);
// === then ===
verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP);
verifyNoMoreInteractions(mockedBeanFactory);
verifyZeroInteractions(mockedBeanDefinition);
}
/**
* given that the site service bootstrap bean is contained within the bean factory, ensure that
* it is added as a dependency
@@ -84,22 +83,22 @@ public class DictionaryBootstrapPostProcessorUnitTest extends BaseUnitTest
@Test
public void siteServiceBootstrapBeanAvailable()
{
// === given ====
// === given ====
doReturn(true).when(mockedBeanFactory).containsBean(BEAN_SITESERVICE_BOOTSTRAP);
doReturn(true).when(mockedBeanFactory).containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP);
doReturn(mockedBeanDefinition).when(mockedBeanFactory).getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP);
// === when ===
postProcessor.postProcessBeanFactory(mockedBeanFactory);
// === then ===
verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP);
verify(mockedBeanFactory, times(1)).containsBean(BEAN_RM_DICTIONARY_BOOTSTRAP);
verify(mockedBeanFactory, times(1)).getBeanDefinition(BEAN_RM_DICTIONARY_BOOTSTRAP);
verify(mockedBeanDefinition, times(1)).setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP});
verify(mockedBeanDefinition, times(1)).setDependsOn(new String[]{BEAN_SITESERVICE_BOOTSTRAP});
verifyNoMoreInteractions(mockedBeanFactory, mockedBeanDefinition);
}
}