Author: julien(a)jboss.com
Date: 2007-01-19 16:37:46 -0500 (Fri, 19 Jan 2007)
New Revision: 6051
Modified:
trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
Log:
CopyOnWriteRegistry javadoc update + test the non modifiability of the returned
collections
Modified: trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java 2007-01-19
21:32:07 UTC (rev 6050)
+++ trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java 2007-01-19
21:37:46 UTC (rev 6051)
@@ -29,6 +29,8 @@
import java.util.Collection;
/**
+ * Implementation of a registry that implements copy on write semantics.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -95,7 +97,7 @@
}
/**
- * Return the known keys.
+ * Return an unmodifiable set containing the keys.
*
* @return the keys
*/
@@ -105,7 +107,7 @@
}
/**
- * Return the registrations.
+ * Return an unmodifable collection containing the registrations.
*
* @return the registrations
*/
@@ -115,6 +117,7 @@
}
/**
+ * Return a registration or null if it does not exist.
*
* @param key the registration key
* @return the registeted object
Modified:
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2007-01-19
21:32:07 UTC (rev 6050)
+++
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2007-01-19
21:37:46 UTC (rev 6051)
@@ -158,4 +158,30 @@
assertEquals(Collections.EMPTY_SET, keys);
assertEquals(Collections.EMPTY_LIST, registrations);
}
+
+ public void testKeysAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getKeys().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+
+ public void testRegistrationsAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getRegistrations().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
}
Show replies by date