From portal-commits at lists.jboss.org Fri Jan 19 16:37:47 2007 Content-Type: multipart/mixed; boundary="===============1702162905818219168==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6051 - in trunk/common/src/main/org/jboss/portal: test/common and 1 other directory. Date: Fri, 19 Jan 2007 16:37:47 -0500 Message-ID: --===============1702162905818219168== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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.j= ava trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTe= stCase.java Log: CopyOnWriteRegistry javadoc update + test the non modifiability of the retu= rned collections Modified: trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteReg= istry.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 Julien Viet * @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/CopyOnWriteReg= istryTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryT= estCase.java 2007-01-19 21:32:07 UTC (rev 6050) +++ trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryT= estCase.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) + { + } + } } --===============1702162905818219168==--