camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r741515 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/processor/ main/java/org/apache/camel/util/ main/resources/META-INF/services/org/apache/camel/component/ test/java/org/apache/camel/util/
Date Fri, 06 Feb 2009 10:35:43 GMT
Author: davsclaus
Date: Fri Feb  6 10:35:42 2009
New Revision: 741515

URL: http://svn.apache.org/viewvc?rev=741515&view=rev
Log:
Polished code. Enabled the NewFileComponent by default, to let TeamCity have a go on unit
testing with it.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/file
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java?rev=741515&r1=741514&r2=741515&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java Fri Feb
 6 10:35:42 2009
@@ -77,6 +77,7 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     private Iterable<ProcessorExchangePair> createProcessorExchangePairsIterable(final
Exchange exchange, Object value) {
         final Iterator iterator = ObjectHelper.createIterator(value);
         return new Iterable() {
@@ -113,7 +114,7 @@
         } else {
             result = new ArrayList<ProcessorExchangePair>();
         }
-        Iterator<Object> iter = ObjectHelper.createIterator(value);
+        Iterator iter = ObjectHelper.createIterator(value);
         while (iter.hasNext()) {
             Object part = iter.next();
             Exchange newExchange = exchange.copy();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=741515&r1=741514&r2=741515&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Fri Feb 
6 10:35:42 2009
@@ -318,9 +318,27 @@
      * Creates an iterator over the value if the value is a collection, an
      * Object[] or a primitive type array; otherwise to simplify the caller's
      * code, we just create a singleton collection iterator over a single value
+     * <p/>
+     * Will default use comma for String separating String values.
+     *
+     * @param value  the value
+     * @return the iterator
      */
-    @SuppressWarnings("unchecked")
     public static Iterator createIterator(Object value) {
+        return createIterator(value, ",");
+    }
+
+    /**
+     * Creates an iterator over the value if the value is a collection, an
+     * Object[] or a primitive type array; otherwise to simplify the caller's
+     * code, we just create a singleton collection iterator over a single value
+     *
+     * @param value  the value
+     * @param  delimiter  delimiter for separating String values
+     * @return the iterator
+     */
+    @SuppressWarnings("unchecked")
+    public static Iterator createIterator(Object value, String delimiter) {
         if (value == null) {
             return Collections.EMPTY_LIST.iterator();
         } else if (value instanceof Iterator) {
@@ -352,8 +370,7 @@
             };
         } else if (value instanceof String) {
             Scanner scanner = new Scanner((String)value);
-            // use comma as delimiter for String values
-            scanner.useDelimiter(",");
+            scanner.useDelimiter(delimiter);
             return scanner;
         } else {
             return Collections.singletonList(value).iterator();

Modified: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/file
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/file?rev=741515&r1=741514&r2=741515&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/file
(original)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/file
Fri Feb  6 10:35:42 2009
@@ -15,5 +15,5 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.component.file.FileComponent
-strategy.factory.class=org.apache.camel.component.file.strategy.FileProcessStrategyFactory
\ No newline at end of file
+class=org.apache.camel.component.file.NewFileComponent
+strategy.factory.class=org.apache.camel.component.file.strategy.NewFileProcessStrategyFactory
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java?rev=741515&r1=741514&r2=741515&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java Fri Feb
 6 10:35:42 2009
@@ -29,6 +29,7 @@
  * @version $Revision$
  */
 public class ObjectHelperTest extends TestCase {
+
     public void testRemoveInitialCharacters() throws Exception {
         assertEquals(ObjectHelper.removeStartingCharacters("foo", '/'), "foo");
         assertEquals(ObjectHelper.removeStartingCharacters("/foo", '/'), "foo");
@@ -135,7 +136,15 @@
 
     public void testCreateIteratorWithStringAndCommaSeparator() {
         String s = "a,b,c";
-        Iterator it = ObjectHelper.createIterator(s);
+        Iterator it = ObjectHelper.createIterator(s, ",");
+        assertEquals("a", it.next());
+        assertEquals("b", it.next());
+        assertEquals("c", it.next());
+    }
+
+    public void testCreateIteratorWithStringAndSemiColonSeparator() {
+        String s = "a;b;c";
+        Iterator it = ObjectHelper.createIterator(s, ";");
         assertEquals("a", it.next());
         assertEquals("b", it.next());
         assertEquals("c", it.next());



Mime
View raw message