diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java
index 7527ba3bf3..4cb6eb48d4 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationLevelComparator.java
@@ -21,7 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.classification;
import java.util.Comparator;
/**
- * A class to compare classification levels.
+ * A class to compare classification levels. More secure classification levels are "higher" than less secure levels.
*
* @author tpage
* @since 3.0
@@ -35,11 +35,15 @@ public class ClassificationLevelComparator implements Comparator.
+ */
+package org.alfresco.module.org_alfresco_module_rm.test.integration.classification;
+
+import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel;
+import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
+import org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevel;
+import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+
+/**
+ * Application context tests for the security clearance service.
+ *
+ * @author tpage
+ */
+public class SecurityClearanceTest extends BaseRMTestCase
+{
+ @Override
+ protected boolean isUserTest()
+ {
+ return true;
+ };
+
+ /**
+ * Given I am admin
+ * When I try to give a user maximum clearance
+ * Then I am successful.
+ */
+ public void testGiveClearance() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest()
+ {
+ private SecurityClearance securityClearance;
+
+ public void when() throws Exception
+ {
+ securityClearance = securityClearanceService.setUserSecurityClearance(userName, "level1");
+ }
+
+ public void then() throws Exception
+ {
+ ClearanceLevel clearanceLevel = securityClearance.getClearanceLevel();
+ ClassificationLevel highestClassificationLevel = clearanceLevel.getHighestClassificationLevel();
+ assertEquals("level1", highestClassificationLevel.getId());
+ }
+ });
+ }
+
+ /**
+ * Given I am a user with level2 access
+ * And I try to give another user level1 access
+ * Then an exception is thrown.
+ */
+ public void testCantGiveClearance() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest(LevelIdNotFound.class)
+ {
+ public void given() throws Exception
+ {
+ securityClearanceService.setUserSecurityClearance(userName, "level2");
+ }
+
+ public void when() throws Exception
+ {
+ doTestInTransaction(new Test()
+ {
+ @Override
+ public Void run()
+ {
+ securityClearanceService.setUserSecurityClearance(rmUserName, "level1");
+ return null;
+ }
+ }, userName);
+ }
+ });
+ }
+}