svn commit: r802779 - /camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r802779 - /camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java

davsclaus-2
Author: davsclaus
Date: Mon Aug 10 13:10:15 2009
New Revision: 802779

URL: http://svn.apache.org/viewvc?rev=802779&view=rev
Log:
Added more unit tests on case insensitive map based on user forum discussion

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java?rev=802779&r1=802778&r2=802779&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java Mon Aug 10 13:10:15 2009
@@ -235,4 +235,58 @@
         assertTrue(values.contains("Beer"));
     }
 
+    public void testRomeks() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        map.put("foo", "cheese");
+
+        assertEquals(1, map.size());
+        assertEquals("cheese", map.get("fOo"));
+        assertEquals(true, map.containsKey("foo"));
+        assertEquals(true, map.containsKey("FOO"));
+
+        assertEquals(true, map.keySet().contains("FOO"));
+
+        map.put("FOO", "cake");
+        assertEquals(1, map.size());
+        assertEquals(true, map.containsKey("foo"));
+        assertEquals(true, map.containsKey("FOO"));
+
+        assertEquals("cake", map.get("fOo"));
+    }
+
+    public void testRomeksUsingRegularHashMap() {
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("foo", "cheese");
+
+        assertEquals(1, map.size());
+        assertEquals(null, map.get("fOo"));
+        assertEquals(true, map.containsKey("foo"));
+        assertEquals(false, map.containsKey("FOO"));
+
+        assertEquals(false, map.keySet().contains("FOO"));
+
+        map.put("FOO", "cake");
+        assertEquals(2, map.size());
+        assertEquals(true, map.containsKey("foo"));
+        assertEquals(true, map.containsKey("FOO"));
+
+        assertEquals(null, map.get("fOo"));
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cake", map.get("FOO"));
+    }
+
+    public void testRomeksTransferedToHashMapAfterwards() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        map.put("Foo", "cheese");
+        map.put("FOO", "cake");
+        assertEquals(1, map.size());
+        assertEquals(true, map.containsKey("foo"));
+        assertEquals(true, map.containsKey("FOO"));
+
+        Map<String, Object> other = new HashMap<String, Object>(map);
+        assertEquals(false, other.containsKey("foo"));
+        assertEquals(true, other.containsKey("FOO"));
+        assertEquals(1, other.size());
+    }
+
 }
\ No newline at end of file