You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/12/15 13:57:49 UTC

svn commit: r1422238 - /camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java

Author: davsclaus
Date: Sat Dec 15 12:57:48 2012
New Revision: 1422238

URL: http://svn.apache.org/viewvc?rev=1422238&view=rev
Log:
Added unit test

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

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java?rev=1422238&r1=1422237&r2=1422238&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java Sat Dec 15 12:57:48 2012
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
 
@@ -356,5 +357,23 @@ public class IntrospectionSupportTest ex
         assertEquals(false, IntrospectionSupport.isGetter(setupSomething));
         assertEquals(false, IntrospectionSupport.isSetter(setupSomething));
     }
+
+    public void testExtractProperties() throws Exception {
+        Map<String, Object> params = new LinkedHashMap<String, Object>();
+        params.put("foo.name", "Camel");
+        params.put("foo.age", 5);
+        params.put("bar", "yes");
+
+        // extract all "foo." properties
+        // and their keys should have the prefix removed
+        Map<String, Object> foo = IntrospectionSupport.extractProperties(params, "foo.");
+        assertEquals(2, foo.size());
+        assertEquals("Camel", foo.get("name"));
+        assertEquals(5, foo.get("age"));
+
+        // the extracted properties should be removed from original
+        assertEquals(1, params.size());
+        assertEquals("yes", params.get("bar"));
+    }
 }