(no commit message)
[utils] / security / impl / src / test / java / org / wamblee / usermgt / InMemoryGroupSetTest.java
index a97adcca2bc41b86ba717b28d8bf1f8ca64313ea..9a52241f69f7c9cb7654eeb2d170b8d0c87d87ec 100644 (file)
  */ 
 package org.wamblee.usermgt;
 
-import junit.framework.TestCase;
-
-import java.sql.SQLException;
-
 import java.util.Set;
 
+import junit.framework.TestCase;
+
 /**
  * Tests the inmemory group set. Intended to be subclassed for other
  * implementations of group set.
@@ -56,7 +54,7 @@ public class InMemoryGroupSetTest extends TestCase {
      *            Group to check for existence.
      * 
      */
-    protected void checkGroupExists(String aGroup) throws SQLException {
+    protected void checkGroupExists(String aGroup) throws Exception {
         // Empty
     }
 
@@ -67,7 +65,7 @@ public class InMemoryGroupSetTest extends TestCase {
      *            Group to check for non-existence.
      * 
      */
-    protected void checkGroupNotExists(String aGroup) throws SQLException {
+    protected void checkGroupNotExists(String aGroup) throws Exception {
         // Empty
     }
 
@@ -78,7 +76,7 @@ public class InMemoryGroupSetTest extends TestCase {
      *            Expected number of groups.
      * 
      */
-    protected void checkGroupCount(int aSize) throws SQLException {
+    protected void checkGroupCount(int aSize) throws Exception {
         assertEquals(aSize, groups.size());
     }
 
@@ -87,7 +85,7 @@ public class InMemoryGroupSetTest extends TestCase {
      * and contains().
      * 
      */
-    public void testAdd() throws SQLException {
+    public void testAdd() throws Exception {
         Group group = new Group("group1");
         assertTrue(groups.add(group));
         checkGroupExists(group.getName());
@@ -106,7 +104,7 @@ public class InMemoryGroupSetTest extends TestCase {
      * Tries to find a non-existing group. Verifies that null is returned.
      * 
      */
-    public void testFindUnknownGroup() throws SQLException {
+    public void testFindUnknownGroup() throws Exception {
         Group group1 = new Group("group1");
         Group group2 = new Group("group2");
         groups.add(group1);
@@ -122,7 +120,7 @@ public class InMemoryGroupSetTest extends TestCase {
      * Adds duplicate group. Verifies that the existing group is left untouched.
      * 
      */
-    public void testAddDuplicateGroup() throws SQLException {
+    public void testAddDuplicateGroup() throws Exception {
         Group group1 = new Group("group1");
         groups.add(group1);
 
@@ -141,7 +139,7 @@ public class InMemoryGroupSetTest extends TestCase {
      * is true.
      * 
      */
-    public void testRemoveGroup() throws SQLException {
+    public void testRemoveGroup() throws Exception {
         Group group1 = new Group("group1");
         groups.add(group1);
         assertTrue(groups.contains(group1));
@@ -159,14 +157,12 @@ public class InMemoryGroupSetTest extends TestCase {
      * the return value is true.
      * 
      */
-    public void testRemoveNonExistingGroup() throws SQLException {
+    public void testRemoveNonExistingGroup() throws Exception {
         Group group1 = new Group("group1");
         groups.add(group1);
         checkGroupCount(1);
 
         Group nonExistingGroup = new Group("group2");
-        nonExistingGroup.setPrimaryKey(new Long(1000));
-        nonExistingGroup.setPersistedVersion(1000);
         assertFalse(groups.remove(nonExistingGroup));
         assertTrue(groups.contains(group1));
         assertEquals(1, groups.list().size());
@@ -178,7 +174,7 @@ public class InMemoryGroupSetTest extends TestCase {
      * all.
      * 
      */
-    public void testList() throws SQLException {
+    public void testList() throws Exception {
         Group group1 = new Group("group1");
         Group group2 = new Group("group2");
         Group group3 = new Group("group3");
@@ -197,4 +193,15 @@ public class InMemoryGroupSetTest extends TestCase {
 
         checkGroupCount(3);
     }
+    
+    public void testRenameGroupTwice() { 
+        Group group = new Group("x"); 
+        groups.add(group); 
+        groups.groupModified(group);
+        group.setName("y");
+        groups.groupModified(group);
+        Group g = groups.find("y");
+        assertNotNull(g);
+        groups.groupModified(group);
+    }
 }