commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r307282 - /jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
Date Sat, 08 Oct 2005 10:04:22 GMT
Author: scolebourne
Date: Sat Oct  8 03:04:20 2005
New Revision: 307282

URL: http://svn.apache.org/viewcvs?rev=307282&view=rev
Log:
Test unmodifiability of returned collections

Modified:
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java?rev=307282&r1=307281&r2=307282&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
Sat Oct  8 03:04:20 2005
@@ -18,6 +18,7 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -256,10 +257,7 @@
         
         assertEquals(expected.length, localeList.size());
         assertEquals(Arrays.asList(expected), localeList);
-        try {
-            localeList.add("Unmodifiable");
-            fail();
-        } catch (UnsupportedOperationException ex) {}
+        assertUnmodifiableCollection(localeList);
     }
 
     //-----------------------------------------------------------------------
@@ -344,6 +342,8 @@
         List list2 = LocaleUtils.availableLocaleList();
         assertNotNull(list);
         assertSame(list, list2);
+        assertUnmodifiableCollection(list);
+        
         Locale[] jdkLocaleArray = Locale.getAvailableLocales();
         List jdkLocaleList = Arrays.asList(jdkLocaleArray);
         assertEquals(jdkLocaleList, list);
@@ -358,6 +358,8 @@
         Set set2 = LocaleUtils.availableLocaleSet();
         assertNotNull(set);
         assertSame(set, set2);
+        assertUnmodifiableCollection(set);
+        
         Locale[] jdkLocaleArray = Locale.getAvailableLocales();
         List jdkLocaleList = Arrays.asList(jdkLocaleArray);
         Set jdkLocaleSet = new HashSet(jdkLocaleList);
@@ -413,10 +415,7 @@
                         + " for country: " + country);
             }
         }
-        try {
-            list.add("Unmodifiable");
-            fail();
-        } catch (UnsupportedOperationException ex) {}
+        assertUnmodifiableCollection(list);
     }
 
     /**
@@ -463,10 +462,7 @@
                         + " for country: " + language);
             }
         }
-        try {
-            list.add("Unmodifiable");
-            fail();
-        } catch (UnsupportedOperationException ex) {}
+        assertUnmodifiableCollection(list);
     }
 
     /**
@@ -477,6 +473,16 @@
         assertCountriesByLanguage("de", new String[]{"DE", "CH", "AT", "LU"});
         assertCountriesByLanguage("zz", new String[0]);
         assertCountriesByLanguage("it", new String[]{"IT", "CH"});
+    }
+
+    /**
+     * @param coll  the collection to check
+     */
+    private static void assertUnmodifiableCollection(Collection coll) {
+        try {
+            coll.add("Unmodifiable");
+            fail();
+        } catch (UnsupportedOperationException ex) {}
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message