You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/05/19 18:02:18 UTC
svn commit: r776372 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/component/file/
camel-core/src/test/java/org/apache/camel/processor/intercept/
components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/
Author: davsclaus
Date: Tue May 19 16:02:17 2009
New Revision: 776372
URL: http://svn.apache.org/viewvc?rev=776372&view=rev
Log:
CAMEL-1632: from endpoint was not set on exchange created by file/ftp consumer.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java (with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java (with props)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=776372&r1=776371&r2=776372&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java Tue May 19 16:02:17 2009
@@ -79,13 +79,13 @@
}
public GenericFileExchange<File> createExchange(GenericFile<File> file) {
- GenericFileExchange<File> exchange = new GenericFileExchange<File>(getCamelContext());
+ GenericFileExchange<File> exchange = new GenericFileExchange<File>(this);
exchange.setGenericFile(file);
return exchange;
}
public GenericFileExchange createExchange() {
- return new GenericFileExchange(getCamelContext());
+ return new GenericFileExchange(this);
}
public FileOperations getOperations() {
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java?rev=776372&r1=776371&r2=776372&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java Tue May 19 16:02:17 2009
@@ -20,10 +20,8 @@
import java.io.IOException;
import java.util.Date;
-import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
import org.apache.camel.PollingConsumerAware;
import org.apache.camel.RuntimeExchangeException;
import org.apache.camel.impl.DefaultExchange;
@@ -32,36 +30,15 @@
private GenericFile<T> file;
- public GenericFileExchange(CamelContext context) {
- super(context);
- }
-
- public GenericFileExchange(CamelContext context, ExchangePattern pattern) {
- super(context, pattern);
- }
-
- public GenericFileExchange(Exchange parent) {
- super(parent);
- }
-
public GenericFileExchange(Endpoint fromEndpoint) {
super(fromEndpoint);
}
- public GenericFileExchange(GenericFileEndpoint endpoint, ExchangePattern pattern, GenericFile<T> file) {
- super(endpoint, pattern);
- setGenericFile(file);
- }
-
public GenericFileExchange(DefaultExchange parent, GenericFile<T> file) {
super(parent);
setGenericFile(file);
}
- public GenericFileExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
- super(fromEndpoint, pattern);
- }
-
protected void populateHeaders(GenericFile<T> file) {
if (file != null) {
getIn().setHeader(Exchange.FILE_NAME_ONLY, file.getFileNameOnly());
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java?rev=776372&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java Tue May 19 16:02:17 2009
@@ -0,0 +1,57 @@
+/**
+ * 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.processor.intercept;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Based on an issue on the camel user forum.
+ *
+ * @version $Revision$
+ */
+public class FromFileInterceptSendToIssue extends ContextTestSupport {
+
+ public void testInterceptSendTo() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:foo");
+ mock.expectedMessageCount(1);
+ mock.expectedHeaderReceived(Exchange.INTERCEPTED_ENDPOINT, "direct:foo");
+
+ template.sendBodyAndHeader("file://target/intercept", "Hello World", Exchange.FILE_NAME, "input.txt");
+
+ assertMockEndpointsSatisfied();
+
+ Exchange exchange = mock.getReceivedExchanges().get(0);
+ assertEquals("direct:start", exchange.getFromEndpoint().getEndpointUri());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("direct:foo").to("mock:foo");
+
+ from("file://target/intercept")
+ .setHeader(Exchange.FILE_NAME, constant("hello.txt"))
+ .to("direct:foo");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/FromFileInterceptSendToIssue.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java?rev=776372&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java Tue May 19 16:02:17 2009
@@ -0,0 +1,57 @@
+/**
+ * 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.processor.intercept;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Based on an issue on the camel user forum.
+ *
+ * @version $Revision$
+ */
+public class InterceptSendToIssue extends ContextTestSupport {
+
+ public void testInterceptSendTo() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:foo");
+ mock.expectedMessageCount(1);
+ mock.expectedHeaderReceived(Exchange.INTERCEPTED_ENDPOINT, "direct:foo");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+
+ Exchange exchange = mock.getReceivedExchanges().get(0);
+ assertEquals("direct:start", exchange.getFromEndpoint().getEndpointUri());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("direct:foo").to("mock:foo");
+
+ from("direct:start")
+ .setHeader(Exchange.FILE_NAME, constant("hello.txt"))
+ .to("direct:foo");
+ }
+ };
+ }
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToIssue.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java?rev=776372&r1=776371&r2=776372&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java (original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java Tue May 19 16:02:17 2009
@@ -16,8 +16,6 @@
*/
package org.apache.camel.component.file.remote;
-import java.io.File;
-
import org.apache.camel.Processor;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
@@ -44,12 +42,15 @@
@Override
public GenericFileExchange createExchange() {
- return new RemoteFileExchange(this, getExchangePattern());
+ return new RemoteFileExchange(this);
}
@Override
+ @SuppressWarnings("unchecked")
public GenericFileExchange<T> createExchange(GenericFile<T> file) {
- return new RemoteFileExchange<T>(this, getExchangePattern(), (RemoteFile<T>) file);
+ RemoteFileExchange answer = new RemoteFileExchange<T>(this);
+ answer.setGenericFile(file);
+ return answer;
}
@Override
@@ -65,7 +66,8 @@
// we assume its a file if the name has a dot in it (eg foo.txt)
if (configuration.getDirectory().contains(".")) {
- throw new IllegalArgumentException("Only directory is supported. Endpoint must be configured with a valid directory: " + configuration.getDirectory());
+ throw new IllegalArgumentException("Only directory is supported. Endpoint must be configured with a valid directory: "
+ + configuration.getDirectory());
}
if (isDelete() && getMove() != null) {
Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java?rev=776372&r1=776371&r2=776372&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java (original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java Tue May 19 16:02:17 2009
@@ -16,44 +16,21 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileExchange;
import org.apache.camel.impl.DefaultExchange;
public class RemoteFileExchange<T> extends GenericFileExchange<T> {
- public RemoteFileExchange(CamelContext context, ExchangePattern pattern) {
- super(context, pattern);
- }
-
- public RemoteFileExchange(CamelContext context) {
- super(context);
- }
-
public RemoteFileExchange(DefaultExchange parent, RemoteFile<T> remoteFile) {
super(parent, remoteFile);
}
- public RemoteFileExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
- super(fromEndpoint, pattern);
- }
-
public RemoteFileExchange(Endpoint fromEndpoint) {
super(fromEndpoint);
}
- public RemoteFileExchange(Exchange parent) {
- super(parent);
- }
-
- public RemoteFileExchange(RemoteFileEndpoint<T> endpoint, ExchangePattern pattern, RemoteFile<T> genericFile) {
- super(endpoint, pattern, genericFile);
- }
-
@Override
protected void populateHeaders(GenericFile<T> remoteFile) {
super.populateHeaders(remoteFile);