camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1435702 - in /camel/branches/camel-2.10.x: ./ camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
Date Sat, 19 Jan 2013 21:07:24 GMT
Author: bvahdat
Date: Sat Jan 19 21:07:23 2013
New Revision: 1435702

URL: http://svn.apache.org/viewvc?rev=1435702&view=rev
Log:
Merged revisions 1435700 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1435700 | bvahdat | 2013-01-19 22:01:43 +0100 (Sa, 19 Jan 2013) | 1 line
  
  Concatenated the two ObjectHelperTest classes into the one being inside the right package
(org.apache.camel.util).
........

Removed:
    camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/converter/ObjectHelperTest.java
Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1435700

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java?rev=1435702&r1=1435701&r2=1435702&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
Sat Jan 19 21:07:23 2013
@@ -23,6 +23,11 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 import junit.framework.TestCase;
 
@@ -30,6 +35,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.bean.MyStaticClass;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultMessage;
 
 /**
@@ -229,7 +235,7 @@ public class ObjectHelperTest extends Te
         it = ObjectHelper.createIterator(new int[] {}, null);
         assertFalse(it.hasNext());
 
-        it = ObjectHelper.createIterator(new long[] {13, Long.MAX_VALUE, 7, Long.MIN_VALUE},
null);
+        it = ObjectHelper.createIterator(new long[] {13L, Long.MAX_VALUE, 7L, Long.MIN_VALUE},
null);
         assertTrue(it.hasNext());
         assertEquals(Long.valueOf(13), it.next());
         assertTrue(it.hasNext());
@@ -304,6 +310,122 @@ public class ObjectHelperTest extends Te
         assertFalse(it.hasNext());
     }
 
+    public void testArrayAsIterator() throws Exception {
+        String[] data = {"a", "b"};
+
+        Iterator<?> iter = ObjectHelper.createIterator(data);
+        assertTrue("should have next", iter.hasNext());
+        Object a = iter.next();
+        assertEquals("a", "a", a);
+        assertTrue("should have next", iter.hasNext());
+        Object b = iter.next();
+        assertEquals("b", "b", b);
+        assertFalse("should not have a next", iter.hasNext());
+    }
+
+    public void testIsEmpty() {
+        assertTrue(ObjectHelper.isEmpty(null));
+        assertTrue(ObjectHelper.isEmpty(""));
+        assertTrue(ObjectHelper.isEmpty(" "));
+        assertFalse(ObjectHelper.isEmpty("A"));
+        assertFalse(ObjectHelper.isEmpty(" A"));
+        assertFalse(ObjectHelper.isEmpty(" A "));
+        assertFalse(ObjectHelper.isEmpty(new Object()));
+    }
+
+    public void testIsNotEmpty() {
+        assertFalse(ObjectHelper.isNotEmpty(null));
+        assertFalse(ObjectHelper.isNotEmpty(""));
+        assertFalse(ObjectHelper.isNotEmpty(" "));
+        assertTrue(ObjectHelper.isNotEmpty("A"));
+        assertTrue(ObjectHelper.isNotEmpty(" A"));
+        assertTrue(ObjectHelper.isNotEmpty(" A "));
+        assertTrue(ObjectHelper.isNotEmpty(new Object()));
+    }
+
+    public void testIteratorWithComma() {
+        Iterator<?> it = ObjectHelper.createIterator("Claus,Jonathan");
+        assertEquals("Claus", it.next());
+        assertEquals("Jonathan", it.next());
+        assertEquals(false, it.hasNext());
+    }
+
+    public void testIteratorWithOtherDelimiter() {
+        Iterator<?> it = ObjectHelper.createIterator("Claus#Jonathan", "#");
+        assertEquals("Claus", it.next());
+        assertEquals("Jonathan", it.next());
+        assertEquals(false, it.hasNext());
+    }
+
+    public void testIteratorEmpty() {
+        Iterator<?> it = ObjectHelper.createIterator("");
+        assertEquals(false, it.hasNext());
+
+        it = ObjectHelper.createIterator("    ");
+        assertEquals(false, it.hasNext());
+
+        it = ObjectHelper.createIterator(null);
+        assertEquals(false, it.hasNext());
+    }
+
+    public void testIteratorIdempotentNext() {
+        Iterator<?> it = ObjectHelper.createIterator("a");
+        assertTrue(it.hasNext());
+        assertTrue(it.hasNext());
+        it.next();
+        assertFalse(it.hasNext());
+    }
+
+    public void testIteratorIdempotentNextWithNodeList() {
+        NodeList nodeList = new NodeList() {
+
+            public Node item(int index) {
+                return null;
+            }
+
+            public int getLength() {
+                return 1;
+            }
+        };
+
+        Iterator<?> it = ObjectHelper.createIterator(nodeList);
+        assertTrue(it.hasNext());
+        assertTrue(it.hasNext());
+        it.next();
+        assertFalse(it.hasNext());
+    }
+
+    public void testGetCamelContextPropertiesWithPrefix() {
+        CamelContext context = new DefaultCamelContext();
+        Map<String, String> properties = context.getProperties();
+        properties.put("camel.object.helper.test1", "test1");
+        properties.put("camel.object.helper.test2", "test2");
+        properties.put("camel.object.test", "test");
+
+        Properties result = ObjectHelper.getCamelPropertiesWithPrefix("camel.object.helper.",
context);
+        assertEquals("Get a wrong size properties", 2, result.size());
+        assertEquals("It should contain the test1", "test1", result.get("test1"));
+        assertEquals("It should contain the test2", "test2", result.get("test2"));
+    }
+
+    public void testEvaluateAsPredicate() throws Exception {
+        assertEquals(false, ObjectHelper.evaluateValuePredicate(null));
+        assertEquals(true, ObjectHelper.evaluateValuePredicate(123));
+
+        assertEquals(true, ObjectHelper.evaluateValuePredicate("true"));
+        assertEquals(true, ObjectHelper.evaluateValuePredicate("TRUE"));
+        assertEquals(false, ObjectHelper.evaluateValuePredicate("false"));
+        assertEquals(false, ObjectHelper.evaluateValuePredicate("FALSE"));
+        assertEquals(true, ObjectHelper.evaluateValuePredicate("foobar"));
+        assertEquals(true, ObjectHelper.evaluateValuePredicate(""));
+        assertEquals(true, ObjectHelper.evaluateValuePredicate(" "));
+
+        List<String> list = new ArrayList<String>();
+        assertEquals(false, ObjectHelper.evaluateValuePredicate(list));
+        list.add("foo");
+        assertEquals(true, ObjectHelper.evaluateValuePredicate(list));
+    }
+
     public void testIsPrimitiveArrayType() {
         assertTrue(ObjectHelper.isPrimitiveArrayType(byte[].class));
         assertTrue(ObjectHelper.isPrimitiveArrayType(short[].class));



Mime
View raw message