You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2008/03/27 17:00:23 UTC

svn commit: r641864 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/util/ObjectHelper.java test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java

Author: jstrachan
Date: Thu Mar 27 09:00:19 2008
New Revision: 641864

URL: http://svn.apache.org/viewvc?rev=641864&view=rev
Log:
applied patch for https://issues.apache.org/activemq/browse/CAMEL-401 with thanks!

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java   (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=641864&r1=641863&r2=641864&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Thu Mar 27 09:00:19 2008
@@ -182,6 +182,7 @@
         return answer;
     }
 
+
     /**
      * Returns true if the collection contains the specified value
      */
@@ -189,6 +190,10 @@
         if (collectionOrArray instanceof Collection) {
             Collection collection = (Collection)collectionOrArray;
             return collection.contains(value);
+        } else if (collectionOrArray instanceof String && value instanceof String) {
+            String str = (String) collectionOrArray;
+            String subStr = (String) value;
+            return str.contains(subStr);
         } else {
             Iterator iter = ObjectConverter.iterator(collectionOrArray);
             while (iter.hasNext()) {

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java?rev=641864&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java Thu Mar 27 09:00:19 2008
@@ -0,0 +1,39 @@
+/**
+ * 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.component.file;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * verify file name header is visible
+ */
+public class FileFilterOnNameRouteTest extends FileRouteTest {
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                
+                // more natural
+                from(uri).filter(header(FileComponent.HEADER_FILE_NAME).contains("-")).to("mock:result");
+                
+                // than
+                //from(uri).filter(header(FileComponent.HEADER_FILE_NAME).matchesRegex(".*-.*")).to("mock:result");
+            }
+        };
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileFilterOnNameRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native