camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r553477 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/component/mock/ camel-core/src/main/java/org/apache/camel/component/queue/ camel-core/src/main/java/org/apache/...
Date Thu, 05 Jul 2007 12:39:25 GMT
Author: jstrachan
Date: Thu Jul  5 05:39:23 2007
New Revision: 553477

URL: http://svn.apache.org/viewvc?view=rev&rev=553477
Log:
added better assertions on the Mock endpoint to support CAMEL-66

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java
  (contents, props changed)
      - copied, changed from r553312, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointConsumer.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
Removed:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointConsumer.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
    activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
    activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
    activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
Thu Jul  5 05:39:23 2007
@@ -187,7 +187,7 @@
 
             @Override
             public String toString() {
-                return "convertTo(" + expression + ", " + type + ")";
+                return "" + expression + ".convertTo(" + type.getName() + ".class)";
             }
         };
     }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Thu Jul  5 05:39:23 2007
@@ -36,6 +36,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -50,9 +51,9 @@
     private int expectedCount = -1;
     private int counter = 0;
     private Map<Integer, Processor> processors = new HashMap<Integer, Processor>();
-    private List<Exchange> receivedExchanges = new ArrayList<Exchange>();
-    private List<Throwable> failures = new ArrayList<Throwable>();
-    private List<Runnable> tests = new ArrayList<Runnable>();
+    private List<Exchange> receivedExchanges = new CopyOnWriteArrayList<Exchange>();
+    private List<Throwable> failures = new CopyOnWriteArrayList<Throwable>();
+    private List<Runnable> tests = new CopyOnWriteArrayList<Runnable>();
     private CountDownLatch latch;
     private long sleepForEmptyTest = 2000L;
     private long defaulResultWaitMillis = 10000L;
@@ -140,17 +141,14 @@
                     }
                 }
                 else {
-                    if (latch == null) {
-                        fail("Should have a latch!");
-                    }
-
-                    // now lets wait for the results
-                    log.debug("Waiting on the latch for: " + defaulResultWaitMillis + " millis");
-                    latch.await(defaulResultWaitMillis, TimeUnit.MILLISECONDS);
+                    waitForCompleteLatch();
                 }
             }
             assertEquals("Received message count", expectedCount, getReceivedCounter());
         }
+        else if (expectedMinimumCount > 0 && getReceivedCounter() < expectedMinimumCount)
{
+            waitForCompleteLatch();
+        }
 
         if (expectedMinimumCount >= 0) {
             int receivedCounter = getReceivedCounter();
@@ -169,6 +167,20 @@
         }
     }
 
+
+    /**
+     * Validates that the assertions fail on this endpoint
+     */
+    public void assertIsNotSatisfied() throws InterruptedException {
+        try {
+            assertIsSatisfied();
+            fail("Expected assertion failure!");
+        }
+        catch (AssertionError e) {
+            log.info("Caught expected failure: " + e);
+        }
+    }
+
     /**
      * Specifies the expected number of message exchanges that should be received by this
endpoint
      *
@@ -247,27 +259,95 @@
         });
     }
 
+
+    /**
+     * Adds an expectation that messages received should have descending values of the given
expression
+     * such as a user generated counter value
+     *
+     * @param expression
+     */
+    public void expectsDescending(final Expression<Exchange> expression) {
+        expects(new Runnable() {
+            public void run() {
+                assertMessagesDescending(expression);
+            }
+        });
+    }
+
+    /**
+     * Adds an expectation that no duplicate messages should be received using the
+     * expression to determine the message ID
+     *
+     * @param expression the expression used to create a unique message ID for
+     * message comparison (which could just be the message payload if the payload
+     * can be tested for uniqueness using {@link Object#equals(Object)}
+     * and {@link Object#hashCode()}
+     */
+    public void expectsNoDuplicates(final Expression<Exchange> expression) {
+        expects(new Runnable() {
+            public void run() {
+                assertNoDuplicates(expression);
+            }
+        });
+    }
+
     /**
      * Asserts that the messages have ascending values of the given expression
      */
     public void assertMessagesAscending(Expression<Exchange> expression) {
+        assertMessagesSorted(expression, true);
+    }
+
+
+    /**
+     * Asserts that the messages have descending values of the given expression
+     */
+    public void assertMessagesDescending(Expression<Exchange> expression) {
+        assertMessagesSorted(expression, false);
+    }
+
+    protected void assertMessagesSorted(Expression<Exchange> expression, boolean ascending)
{
+        String type = (ascending) ? "ascending" : "descending";
         ExpressionComparator comparator = new ExpressionComparator(expression);
         List<Exchange> list = getReceivedExchanges();
-        for (int i = 1; i < expectedBodyValues.size(); i++) {
+        for (int i = 1; i < list.size(); i++) {
             int j = i - 1;
             Exchange e1 = list.get(j);
             Exchange e2 = list.get(i);
             int result = comparator.compare(e1, e2);
             if (result == 0) {
-                Object value = expression.evaluate(e1);
-                fail("Messages not ascending. Messages" + j + " and " + i + " are equal with
value: " + value
-                        + " for expression: " + expression + " when they were expected to
be ascending. Exchanges: " + e1 + " and " + e2);
-            }
-            else if (result > 0) {
-                Object value = expression.evaluate(e1);
-                fail("Messages not ascending. Message " + j + " has value: " + expression.evaluate(e1)
-                        + " and message" + i + " has value: " + expression.evaluate(e2)
-                        + " for expression: " + expression + " when they were expected to
be ascending. Exchanges: " + e1 + " and " + e2);
+                fail("Messages not " + type + ". Messages" + j + " and " + i
+                        + " are equal with value: " + expression.evaluate(e1)
+                        + " for expression: " + expression + ". Exchanges: " + e1 + " and
" + e2);
+            }
+            else {
+                if (!ascending) {
+                    result = result * -1;
+                }
+                if (result > 0) {
+                    fail("Messages not " + type + ". Message " + j
+                            + " has value: " + expression.evaluate(e1)
+                            + " and message " + i + " has value: " + expression.evaluate(e2)
+                            + " for expression: " + expression + ". Exchanges: " + e1 + "
and " + e2);
+                }
+            }
+        }
+    }
+
+    public void assertNoDuplicates(Expression<Exchange> expression) {
+        Map<Object,Exchange> map = new HashMap<Object, Exchange>();
+        List<Exchange> list = getReceivedExchanges();
+        for (int i = 0; i < list.size(); i++) {
+            Exchange e2 = list.get(i);
+            Object key = expression.evaluate(e2);
+            Exchange e1 = map.get(key);
+            if (e1 != null) {
+                fail("Duplicate message found on message " + i
+                        + " has value: " + key
+                        + " for expression: " + expression + ". Exchanges: " + e1 + " and
" + e2);
+            }
+            else {
+                map.put(key, e2);
             }
         }
     }
@@ -403,6 +483,16 @@
         }
     }
 
+    protected void waitForCompleteLatch() throws InterruptedException {
+        if (latch == null) {
+            fail("Should have a latch!");
+        }
+
+        // now lets wait for the results
+        log.debug("Waiting on the latch for: " + defaulResultWaitMillis + " millis");
+        latch.await(defaulResultWaitMillis, TimeUnit.MILLISECONDS);
+    }
+
     protected void assertEquals(String message, Object expectedValue, Object actualValue)
{
         if (!ObjectHelper.equals(expectedValue, actualValue)) {
             fail(message + ". Expected: <" + expectedValue + "> but was: <" + actualValue
+ ">");
@@ -439,4 +529,5 @@
     public boolean isSingleton() {
         return true;
     }
+
 }

Copied: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java
(from r553312, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointConsumer.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java?view=diff&rev=553477&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointConsumer.java&r1=553312&p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpointConsumer.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java
Thu Jul  5 05:39:23 2007
@@ -30,22 +30,21 @@
 /**
  * @version $Revision$
  */
-public class QueueEndpointConsumer<E extends Exchange> extends ServiceSupport implements
Consumer<E>, Runnable {
-    private static final Log log = LogFactory.getLog(QueueEndpointConsumer.class);
-    private static int counter;
+public class QueueConsumer<E extends Exchange> extends ServiceSupport implements Consumer<E>,
Runnable {
+    private static final Log log = LogFactory.getLog(QueueConsumer.class);
 
     private QueueEndpoint<E> endpoint;
     private Processor processor;
     private Thread thread;
 
-    public QueueEndpointConsumer(QueueEndpoint<E> endpoint, Processor processor) {
+    public QueueConsumer(QueueEndpoint<E> endpoint, Processor processor) {
         this.endpoint = endpoint;
         this.processor = processor;
     }
 
     @Override
     public String toString() {
-        return "QueueEndpointConsumer: " + endpoint.getEndpointUri();
+        return "QueueConsumer: " + endpoint.getEndpointUri();
     }
 
     public void run() {
@@ -73,7 +72,7 @@
     }
 
     protected void doStart() throws Exception {
-        thread = new Thread(this, endpoint.getEndpointUri() + " thread:" + nextCounter());
+        thread = new Thread(this, getThreadName(endpoint.getEndpointUri()));
         thread.setDaemon(true);
         thread.start();
     }
@@ -82,7 +81,4 @@
         thread.join();
     }
 
-    protected static synchronized int nextCounter() {
-        return ++counter;
-    }
 }

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpoint.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/queue/QueueEndpoint.java
Thu Jul  5 05:39:23 2007
@@ -55,7 +55,7 @@
     }
 
     public Consumer<E> createConsumer(Processor processor) throws Exception {
-        return new QueueEndpointConsumer<E>(this, processor);
+        return new QueueConsumer<E>(this, processor);
     }
 
     public E createExchange() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
Thu Jul  5 05:39:23 2007
@@ -47,7 +47,6 @@
         this.camelContext = context;
     }
 
-
     public Endpoint<E> createEndpoint(String uri) throws Exception {
         ObjectHelper.notNull(getCamelContext(), "camelContext");        
         URI u = new URI(uri);
@@ -105,7 +104,7 @@
 
             public synchronized Thread newThread(Runnable runnable) {
                 Thread thread = new Thread(runnable);
-                thread.setName("Thread" + (++counter) + " " + DefaultComponent.this.toString());
+                thread.setName("Thread: " + (++counter) + " " + DefaultComponent.this.toString());
                 return thread;
             }
         });

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
Thu Jul  5 05:39:23 2007
@@ -31,6 +31,7 @@
     private AtomicBoolean started = new AtomicBoolean(false);
     private AtomicBoolean stopping = new AtomicBoolean(false);
     private AtomicBoolean stopped = new AtomicBoolean(false);
+    private static int threadCounter;
 
     public void start() throws Exception {
         if (started.compareAndSet(false, true)) {
@@ -78,4 +79,14 @@
     
     protected abstract void doStop() throws Exception;
 
+    /**
+     * Creates a new thread name with the given prefix
+     */
+    protected String getThreadName(String prefix) {
+        return prefix + " thread:" + nextThreadCounter();
+    }
+
+    protected static synchronized int nextThreadCounter() {
+        return ++threadCounter;
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java Thu Jul
 5 05:39:23 2007
@@ -18,19 +18,83 @@
 package org.apache.camel;
 
 import junit.framework.TestCase;
+import org.apache.camel.builder.Builder;
+import org.apache.camel.builder.ValueBuilder;
+import org.apache.camel.impl.DefaultExchange;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.camel.impl.DefaultExchange;
 
 /**
  * A bunch of useful testing methods
- * 
+ *
  * @version $Revision$
  */
 public abstract class TestSupport extends TestCase {
 
     protected transient Log log = LogFactory.getLog(getClass());
 
+    // Builder methods for expressions used when testing
+    //-------------------------------------------------------------------------
+
+    /**
+     * Returns a value builder for the given header
+     */
+
+    public ValueBuilder header(String name) {
+        return Builder.header(name);
+    }
+
+    /**
+     * Returns a predicate and value builder for the inbound body on an exchange
+     */
+
+    public ValueBuilder body() {
+        return Builder.body();
+    }
+
+    /**
+     * Returns a predicate and value builder for the inbound message body as a specific type
+     */
+
+    public <T> ValueBuilder bodyAs(Class<T> type) {
+        return Builder.bodyAs(type);
+    }
+
+    /**
+     * Returns a predicate and value builder for the outbound body on an exchange
+     */
+
+    public ValueBuilder outBody() {
+        return Builder.outBody();
+    }
+
+    /**
+     * Returns a predicate and value builder for the outbound message body as a specific
type
+     */
+
+    public <T> ValueBuilder outBody(Class<T> type) {
+        return Builder.outBody(type);
+    }
+
+    /**
+     * Returns a value builder for the given system property
+     */
+
+    public ValueBuilder systemProperty(String name) {
+        return Builder.systemProperty(name);
+    }
+
+    /**
+     * Returns a value builder for the given system property
+     */
+
+    public ValueBuilder systemProperty(String name, String defaultValue) {
+        return Builder.systemProperty(name, defaultValue);
+    }
+
+    // Assertions
+    //-----------------------------------------------------------------------
+
     protected <T> T assertIsInstanceOf(Class<T> expectedType, Object value) {
         assertNotNull("Expected an instance of type: " + expectedType.getName() + " but was
null", value);
         assertTrue("object should be a " + expectedType.getName() + " but was: " + value
+ " with type: " + value.getClass().getName(),
@@ -143,4 +207,5 @@
         message.setBody(body);
         return exchange;
     }
+
 }

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java?view=auto&rev=553477
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
(added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
Thu Jul  5 05:39:23 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.mock;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision: $
+ */
+public class MockEndpointTest extends ContextTestSupport {
+
+    public void testAscendingMessagesPass() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectsAscending(header("counter").convertTo(Number.class));
+
+        sendMessages(11, 12, 13, 14, 15);
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    public void testAscendingMessagesFail() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectsAscending(header("counter").convertTo(Number.class));
+
+        sendMessages(11, 12, 13, 15, 14);
+
+        resultEndpoint.assertIsNotSatisfied();
+    }
+
+    public void testDescendingMessagesPass() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectsDescending(header("counter").convertTo(Number.class));
+
+        sendMessages(15, 14, 13, 12, 11);
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    public void testDescendingMessagesFail() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectsDescending(header("counter").convertTo(Number.class));
+
+        sendMessages(15, 14, 13, 11, 12);
+
+        resultEndpoint.assertIsNotSatisfied();
+    }
+
+    public void testNoDuplicateMessagesPass() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectsNoDuplicates(header("counter"));
+
+        sendMessages(11, 12, 13, 14, 15);
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    public void testDuplicateMessagesFail() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectsNoDuplicates(header("counter"));
+
+        sendMessages(11, 12, 13, 14, 12);
+
+        resultEndpoint.assertIsNotSatisfied();
+    }
+
+    protected void sendMessages(int... counters) {
+        for (int counter : counters) {
+            template.sendBody("direct:a", "<message>" + counter + "</message>",
+                    "counter", counter);
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:a").to("mock:result");
+            }
+        };
+    }
+
+}

Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
(original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
Thu Jul  5 05:39:23 2007
@@ -43,13 +43,14 @@
 
     protected FTPClient createFtpClient() throws IOException {
         final FTPClient client = new FTPClient();
-        String host = getConfiguration().getHost();
-        int port = getConfiguration().getPort();
+        RemoteFileConfiguration config = getConfiguration();
+        String host = config.getHost();
+        int port = config.getPort();
         log.debug("Connecting to host: " + host + " port: " + port);
 
         client.connect(host, port);
-        client.login(getConfiguration().getUsername(), getConfiguration().getPassword());
-        client.setFileType(getConfiguration().isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
+        client.login(config.getUsername(), config.getPassword());
+        client.setFileType(config.isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
         return client;
     }
 }

Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
(original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
Thu Jul  5 05:39:23 2007
@@ -41,6 +41,10 @@
         this.configuration = new RemoteFileConfiguration();
     }
 
+    public String toString() {
+        return "RemoteFileComponent";
+    }
+
     public static RemoteFileComponent remoteFileComponent() {
         return new RemoteFileComponent();
     }

Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java?view=diff&rev=553477&r1=553476&r2=553477
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
(original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
Thu Jul  5 05:39:23 2007
@@ -47,6 +47,10 @@
         }
     }
 
+    public String toString() {
+        return protocol + ":\\" + username + "@" +  host + ":" + port + "/" + directory;
+    }
+    
     public void configure(URI uri) {
         setProtocol(uri.getScheme());
         setDefaultPort();
@@ -131,7 +135,7 @@
         this.directory = directory;
     }
 
-    public String toString() {
+    public String dump() {
         return "RemoteFileConfiguration{" +
                 "protocol='" + protocol + '\'' +
                 ", username='" + username + '\'' +



Mime
View raw message