svn commit: r802700 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/util/ camel-core/src/test/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/util/ components/camel-cxf/...

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

svn commit: r802700 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/util/ camel-core/src/test/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/util/ components/camel-cxf/...

davsclaus-2
Author: davsclaus
Date: Mon Aug 10 09:10:05 2009
New Revision: 802700

URL: http://svn.apache.org/viewvc?rev=802700&view=rev
Log:
CAMEL-1886: headers is now stored in a case insensitive map making working with headers easier from end user perspective as keys does not have to be 100% accurate.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerHeaderTest.java
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java?rev=802700&r1=802699&r2=802700&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java Mon Aug 10 09:10:05 2009
@@ -23,6 +23,7 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
+import org.apache.camel.util.CaseInsensitiveMap;
 import org.apache.camel.util.MessageHelper;
 
 /**
@@ -31,7 +32,7 @@
  * @version $Revision$
  */
 public class DefaultMessage extends MessageSupport {
-    private boolean fault;
+    private boolean fault;
     private Map<String, Object> headers;
     private Map<String, DataHandler> attachments;
 
@@ -53,13 +54,16 @@
     public void setFault(boolean fault) {
         this.fault = fault;
     }
-    
+
     public Object getHeader(String name) {
         return getHeaders().get(name);
     }
 
     public <T> T getHeader(String name, Class<T> type) {
         Object value = getHeader(name);
+        if (value == null) {
+            return null;
+        }
 
         // eager same instance type test to avoid the overhead of invoking the type converter
         // if already same type
@@ -71,7 +75,7 @@
         if (e != null) {
             return e.getContext().getTypeConverter().convertTo(type, e, value);
         } else {
-            return (T) value;
+            return type.cast(value);
         }
     }
 
@@ -83,11 +87,10 @@
     }
 
     public Object removeHeader(String name) {
-        if (headers != null) {
-            return headers.remove(name);
-        } else {
+        if (!hasHeaders()) {
             return null;
         }
+        return headers.remove(name);
     }
 
     public Map<String, Object> getHeaders() {
@@ -98,7 +101,12 @@
     }
 
     public void setHeaders(Map<String, Object> headers) {
-        this.headers = headers;
+        if (headers instanceof CaseInsensitiveMap) {
+            this.headers = headers;
+        } else {
+            // wrap it in a case insensitive map
+            this.headers = new CaseInsensitiveMap(headers);
+        }
     }
 
     public boolean hasHeaders() {
@@ -122,7 +130,7 @@
      *         the underlying inbound transport
      */
     protected Map<String, Object> createHeaders() {
-        Map<String, Object> map = new HashMap<String, Object>();
+        Map<String, Object> map = new CaseInsensitiveMap();
         populateInitialHeaders(map);
         return map;
     }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java?rev=802700&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java Mon Aug 10 09:10:05 2009
@@ -0,0 +1,136 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A map that uses case insensitive keys, but preserves the original keys in the keySet.
+ *
+ * @version $Revision$
+ */
+public class CaseInsensitiveMap extends HashMap<String, Object> {
+
+    // holds a map of lower case key -> original key
+    private Map<String, String> originalKeys;
+    // holds a snapshot view of current entry set
+    private Set<Map.Entry<String, Object>> entrySetView;
+
+    public CaseInsensitiveMap() {
+        super();
+        originalKeys = new HashMap<String, String>();
+    }
+
+    public CaseInsensitiveMap(Map<? extends String, ?> map) {
+        this();
+        putAll(map);
+    }
+
+    public CaseInsensitiveMap(int initialCapacity, float loadFactor) {
+        super(initialCapacity, loadFactor);
+        originalKeys = new HashMap<String, String>(initialCapacity);
+    }
+
+    public CaseInsensitiveMap(int initialCapacity) {
+        super(initialCapacity);
+        originalKeys = new HashMap<String, String>();
+    }
+
+    @Override
+    public Object get(Object key) {
+        String s = key.toString().toLowerCase();
+        Object answer = super.get(s);
+        if (answer == null) {
+            // fallback to lookup by original key
+            String originalKey = originalKeys.get(s);
+            answer = super.get(originalKey);
+        }
+        return answer;
+    }
+
+    @Override
+    public Object put(String key, Object value) {
+        // invalidate views as we mutate
+        entrySetView = null;
+        String s = key.toLowerCase();
+        originalKeys.put(s, key);
+        return super.put(s, value);
+    }
+
+    @Override
+    public void putAll(Map<? extends String, ?> map) {
+        for (Map.Entry<? extends String, ?> entry : map.entrySet()) {
+            put(entry.getKey(), entry.getValue());
+        }
+    }
+
+    @Override
+    public Object remove(Object key) {
+        // invalidate views as we mutate
+        entrySetView = null;
+        String s = key.toString().toLowerCase();
+        originalKeys.remove(s);
+        return super.remove(s);
+    }
+
+    @Override
+    public void clear() {
+        // invalidate views as we mutate
+        entrySetView = null;
+        originalKeys.clear();
+        super.clear();
+    }
+
+    @Override
+    public boolean containsKey(Object key) {
+        String s = key.toString().toLowerCase();
+        return super.containsKey(s);
+    }
+
+    @Override
+    public Set<Map.Entry<String, Object>> entrySet() {
+        if (entrySetView == null) {
+            // build the key set using the original keys so we retain their case
+            // when for example we copy values to another map
+            entrySetView = new HashSet<Map.Entry<String, Object>>(this.size());
+            for (final Map.Entry<String, Object> entry : super.entrySet()) {
+                Map.Entry<String, Object> view = new Map.Entry<String, Object>() {
+                    public String getKey() {
+                        String s = entry.getKey();
+                        // use the original key so we can preserve it
+                        return originalKeys.get(s);
+                    }
+
+                    public Object getValue() {
+                        return entry.getValue();
+                    }
+
+                    public Object setValue(Object o) {
+                        return entry.setValue(o);
+                    }
+                };
+                entrySetView.add(view);
+            }
+        }
+
+        return entrySetView;
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java?rev=802700&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java Mon Aug 10 09:10:05 2009
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl;
+
+import junit.framework.TestCase;
+import org.apache.camel.Message;
+
+/**
+ * @version $Revision$
+ */
+public class DefaultMessageHeaderTest extends TestCase {
+
+    public void testLookupCaseAgnostic() {
+        Message msg = new DefaultMessage();
+        assertNull(msg.getHeader("foo"));
+
+        msg.setHeader("foo", "cheese");
+
+        assertEquals("cheese", msg.getHeader("foo"));
+        assertEquals("cheese", msg.getHeader("Foo"));
+        assertEquals("cheese", msg.getHeader("FOO"));
+    }
+
+    public void testLookupCaseAgnosticAddHeader() {
+        Message msg = new DefaultMessage();
+        assertNull(msg.getHeader("foo"));
+
+        msg.setHeader("foo", "cheese");
+
+        assertEquals("cheese", msg.getHeader("foo"));
+        assertEquals("cheese", msg.getHeader("Foo"));
+        assertEquals("cheese", msg.getHeader("FOO"));
+        assertNull(msg.getHeader("unknown"));
+
+        msg.setHeader("bar", "beer");
+
+        assertEquals("beer", msg.getHeader("bar"));
+        assertEquals("beer", msg.getHeader("Bar"));
+        assertEquals("beer", msg.getHeader("BAR"));
+        assertNull(msg.getHeader("unknown"));
+    }
+
+    public void testLookupCaseAgnosticAddHeader2() {
+        Message msg = new DefaultMessage();
+        assertNull(msg.getHeader("foo"));
+
+        msg.setHeader("foo", "cheese");
+
+        assertEquals("cheese", msg.getHeader("FOO"));
+        assertEquals("cheese", msg.getHeader("foo"));
+        assertEquals("cheese", msg.getHeader("Foo"));
+        assertNull(msg.getHeader("unknown"));
+
+        msg.setHeader("bar", "beer");
+
+        assertEquals("beer", msg.getHeader("BAR"));
+        assertEquals("beer", msg.getHeader("bar"));
+        assertEquals("beer", msg.getHeader("Bar"));
+        assertNull(msg.getHeader("unknown"));
+    }
+
+    public void testLookupCaseAgnosticAddHeaderRemoveHeader() {
+        Message msg = new DefaultMessage();
+        assertNull(msg.getHeader("foo"));
+
+        msg.setHeader("foo", "cheese");
+
+        assertEquals("cheese", msg.getHeader("foo"));
+        assertEquals("cheese", msg.getHeader("Foo"));
+        assertEquals("cheese", msg.getHeader("FOO"));
+        assertNull(msg.getHeader("unknown"));
+
+        msg.setHeader("bar", "beer");
+
+        assertEquals("beer", msg.getHeader("bar"));
+        assertEquals("beer", msg.getHeader("Bar"));
+        assertEquals("beer", msg.getHeader("BAR"));
+        assertNull(msg.getHeader("unknown"));
+
+        msg.removeHeader("bar");
+        assertNull(msg.getHeader("bar"));
+        assertNull(msg.getHeader("unknown"));
+    }
+
+    public void testSetWithDifferentCase() {
+        Message msg = new DefaultMessage();
+        assertNull(msg.getHeader("foo"));
+
+        msg.setHeader("foo", "cheese");
+        msg.setHeader("Foo", "bar");
+
+        assertEquals("bar", msg.getHeader("FOO"));
+        assertEquals("bar", msg.getHeader("foo"));
+        assertEquals("bar", msg.getHeader("Foo"));
+    }
+
+    public void testRemoveWithDifferentCase() {
+        Message msg = new DefaultMessage();
+        assertNull(msg.getHeader("foo"));
+
+        msg.setHeader("foo", "cheese");
+        msg.setHeader("Foo", "bar");
+
+        assertEquals("bar", msg.getHeader("FOO"));
+        assertEquals("bar", msg.getHeader("foo"));
+        assertEquals("bar", msg.getHeader("Foo"));
+
+        msg.removeHeader("FOO");
+
+        assertEquals(null, msg.getHeader("foo"));
+        assertEquals(null, msg.getHeader("Foo"));
+        assertEquals(null, msg.getHeader("FOO"));
+
+        assertTrue(msg.getHeaders().isEmpty());
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultMessageHeaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 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=802700&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java Mon Aug 10 09:10:05 2009
@@ -0,0 +1,238 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.util;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Revision$
+ */
+public class CaseInsensitiveMapTest extends TestCase {
+
+    public void testLookupCaseAgnostic() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        map.put("foo", "cheese");
+
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cheese", map.get("Foo"));
+        assertEquals("cheese", map.get("FOO"));
+    }
+
+    public void testLookupCaseAgnosticAddHeader() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        map.put("foo", "cheese");
+
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cheese", map.get("Foo"));
+        assertEquals("cheese", map.get("FOO"));
+        assertNull(map.get("unknown"));
+
+        map.put("bar", "beer");
+
+        assertEquals("beer", map.get("bar"));
+        assertEquals("beer", map.get("Bar"));
+        assertEquals("beer", map.get("BAR"));
+        assertNull(map.get("unknown"));
+    }
+
+    public void testLookupCaseAgnosticAddHeader2() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        map.put("foo", "cheese");
+
+        assertEquals("cheese", map.get("FOO"));
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cheese", map.get("Foo"));
+        assertNull(map.get("unknown"));
+
+        map.put("bar", "beer");
+
+        assertEquals("beer", map.get("BAR"));
+        assertEquals("beer", map.get("bar"));
+        assertEquals("beer", map.get("Bar"));
+        assertNull(map.get("unknown"));
+    }
+
+    public void testLookupCaseAgnosticAddHeaderRemoveHeader() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        map.put("foo", "cheese");
+
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cheese", map.get("Foo"));
+        assertEquals("cheese", map.get("FOO"));
+        assertNull(map.get("unknown"));
+
+        map.put("bar", "beer");
+
+        assertEquals("beer", map.get("bar"));
+        assertEquals("beer", map.get("Bar"));
+        assertEquals("beer", map.get("BAR"));
+        assertNull(map.get("unknown"));
+
+        map.remove("bar");
+        assertNull(map.get("bar"));
+        assertNull(map.get("unknown"));
+    }
+
+    public void testSetWithDifferentCase() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        map.put("foo", "cheese");
+        map.put("Foo", "bar");
+
+        assertEquals("bar", map.get("FOO"));
+        assertEquals("bar", map.get("foo"));
+        assertEquals("bar", map.get("Foo"));
+    }
+
+    public void testRemoveWithDifferentCase() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        map.put("foo", "cheese");
+        map.put("Foo", "bar");
+
+        assertEquals("bar", map.get("FOO"));
+        assertEquals("bar", map.get("foo"));
+        assertEquals("bar", map.get("Foo"));
+
+        map.remove("FOO");
+
+        assertEquals(null, map.get("foo"));
+        assertEquals(null, map.get("Foo"));
+        assertEquals(null, map.get("FOO"));
+
+        assertTrue(map.isEmpty());
+    }
+
+    public void testPutAll() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        assertNull(map.get("foo"));
+
+        Map<String, Object> other = new HashMap<String, Object>();
+        other.put("Foo", "cheese");
+        other.put("bar", 123);
+
+        map.putAll(other);
+
+        assertEquals("cheese", map.get("FOO"));
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cheese", map.get("Foo"));
+
+        assertEquals(123, map.get("BAR"));
+        assertEquals(123, map.get("bar"));
+        assertEquals(123, map.get("BaR"));
+    }
+
+    public void testConstructFromOther() {
+        Map<String, Object> other = new HashMap<String, Object>();
+        other.put("Foo", "cheese");
+        other.put("bar", 123);
+
+        Map<String, Object> map = new CaseInsensitiveMap(other);
+
+        assertEquals("cheese", map.get("FOO"));
+        assertEquals("cheese", map.get("foo"));
+        assertEquals("cheese", map.get("Foo"));
+
+        assertEquals(123, map.get("BAR"));
+        assertEquals(123, map.get("bar"));
+        assertEquals(123, map.get("BaR"));
+    }
+
+    public void testKeySet() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        map.put("Foo", "cheese");
+        map.put("BAR", 123);
+        map.put("baZ", "beer");
+
+        Set keys = map.keySet();
+
+        // we should be able to lookup no matter what case
+        assertTrue(keys.contains("Foo"));
+        assertTrue(keys.contains("foo"));
+        assertTrue(keys.contains("FOO"));
+
+        assertTrue(keys.contains("BAR"));
+        assertTrue(keys.contains("bar"));
+        assertTrue(keys.contains("Bar"));
+
+        assertTrue(keys.contains("baZ"));
+        assertTrue(keys.contains("baz"));
+        assertTrue(keys.contains("Baz"));
+        assertTrue(keys.contains("BAZ"));
+    }
+
+    public void testRetainKeysCopyToAnotherMap() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        map.put("Foo", "cheese");
+        map.put("BAR", 123);
+        map.put("baZ", "beer");
+
+        Map<String, Object> other = new HashMap<String, Object>(map);
+
+        // we should retain the cases of the original keys
+        // when its copied to another map
+        assertTrue(other.containsKey("Foo"));
+        assertFalse(other.containsKey("foo"));
+        assertFalse(other.containsKey("FOO"));
+
+        assertTrue(other.containsKey("BAR"));
+        assertFalse(other.containsKey("bar"));
+        assertFalse(other.containsKey("Bar"));
+
+        assertTrue(other.containsKey("baZ"));
+        assertFalse(other.containsKey("baz"));
+        assertFalse(other.containsKey("Baz"));
+        assertFalse(other.containsKey("BAZ"));
+    }
+
+    public void testValues() {
+        Map<String, Object> map = new CaseInsensitiveMap();
+        map.put("Foo", "cheese");
+        map.put("BAR", "123");
+        map.put("baZ", "Beer");
+
+        Iterator it = map.values().iterator();
+
+        // should be String values
+        assertEquals("String", it.next().getClass().getSimpleName());
+        assertEquals("String", it.next().getClass().getSimpleName());
+        assertEquals("String", it.next().getClass().getSimpleName());
+
+        Collection values = map.values();
+        assertEquals(3, values.size());
+        assertTrue(values.contains("cheese"));
+        assertTrue(values.contains("123"));
+        assertTrue(values.contains("Beer"));
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java?rev=802700&r1=802699&r2=802700&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java Mon Aug 10 09:10:05 2009
@@ -66,7 +66,7 @@
         });
         assertNotNull("We should get the Content-Type here", MessageHelper.getContentType(exchange.getOut()));
         assertTrue("Get wrong content type", MessageHelper.getContentType(exchange.getOut()).startsWith("text/xml"));
-        assertNull("We should not get the content-type here", exchange.getOut().getHeader("content-type"));        
+        assertNotNull("We should get the content-type here", exchange.getOut().getHeader("content-type"));
         String response = exchange.getOut().getBody(String.class);
         assertNotNull("Response should not be null", response);
         assertTrue("We should get right return result", response.indexOf("echo hello world") > 0);

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerHeaderTest.java?rev=802700&r1=802699&r2=802700&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerHeaderTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerHeaderTest.java Mon Aug 10 09:10:05 2009
@@ -114,8 +114,7 @@
         assertNull(outMessage.getHeader("failed-header-using-http-api"));
         
         // make sure response code has been set in out header
-        assertEquals(200, outMessage.getHeader(Exchange.HTTP_RESPONSE_CODE));
-        
+        assertEquals(Integer.valueOf(200), outMessage.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class));
     }
     
     public static class HttpProcessor implements Processor {

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java?rev=802700&r1=802699&r2=802700&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java Mon Aug 10 09:10:05 2009
@@ -432,11 +432,10 @@
             String[] value = mailMessage.getHeader(header.getName());
             if (headerFilterStrategy != null
                     && !headerFilterStrategy.applyFilterToExternalHeaders(header.getName(), value, exchange)) {
-                // toLowerCase() for doing case insensitive search
                 if (value.length == 1) {
-                    CollectionHelper.appendValue(answer, header.getName().toLowerCase(), value[0]);
+                    CollectionHelper.appendValue(answer, header.getName(), value[0]);
                 } else {
-                    CollectionHelper.appendValue(answer, header.getName().toLowerCase(), value);
+                    CollectionHelper.appendValue(answer, header.getName(), value);
                 }
             }
         }

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java?rev=802700&r1=802699&r2=802700&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java Mon Aug 10 09:10:05 2009
@@ -25,7 +25,6 @@
 import javax.mail.Multipart;
 import javax.mail.Part;
 
-import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.util.CollectionHelper;
@@ -76,17 +75,6 @@
     }
 
     @Override
-    public Object getHeader(String name) {
-        Object answer = super.getHeader(name);
-        
-        // mimic case insensitive search of mail message getHeader
-        if (answer == null) {
-            answer = super.getHeader(name.toLowerCase());
-        }
-        return answer;
-    }
-  
-    @Override
     public MailMessage newInstance() {
         return new MailMessage();
     }