Author: ningjiang
Date: Mon Aug 25 20:29:30 2008
New Revision: 688951
URL: http://svn.apache.org/viewvc?rev=688951&view=rev
Log:
CAMEL-848 Added a check point after configuring the the consumer properties
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java?rev=688951&r1=688950&r2=688951&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
Mon Aug 25 20:29:30 2008
@@ -23,6 +23,7 @@
import org.apache.camel.Consumer;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
+import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.util.IntrospectionSupport;
/**
@@ -60,6 +61,12 @@
if (consumerProperties != null) {
// TODO pass in type converter
IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(),
consumer, consumerProperties);
+ if (!this.isLenientProperties() && consumerProperties.size() > 0) {
+ throw new
ResolveEndpointFailedException(this.getEndpointUri(), "There are " +
consumerProperties.size()
+ + " parameters that couldn't be set on the endpoint
consumer."
+ + " Check the uri if the parameters are spelt correctly
and that they are properties of the endpoint."
+ + " Unknown consumer parameters=[" + consumerProperties +
"]");
+ }
}
}
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java?rev=688951&r1=688950&r2=688951&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
Mon Aug 25 20:29:30 2008
@@ -19,7 +19,10 @@
import java.io.File;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.impl.DefaultMessage;
/**
@@ -28,7 +31,11 @@
public class FileConfigureTest extends ContextTestSupport {
private static final String EXPECT_PATH = "target" + File.separator +
"foo" + File.separator + "bar";
private static final String EXPECT_FILE = "some" + File.separator +
"nested" + File.separator + "filename.txt";
-
+ private static final Processor DUMMY_PROCESSOR = new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ // Do nothing here
+ }
+ };
public void testUriConfigurations() throws Exception {
assertFileEndpoint("file://target/foo/bar", EXPECT_PATH);
assertFileEndpoint("file://target/foo/bar?delete=true", EXPECT_PATH);
@@ -38,11 +45,27 @@
assertFileEndpoint("file://target/foo/bar/?delete=true", EXPECT_PATH);
assertFileEndpoint("file:target/foo/bar/?delete=true", EXPECT_PATH);
assertFileEndpoint("file:target/foo/bar/", EXPECT_PATH);
- assertFileEndpoint("file:/target/foo/bar/", File.separator +
EXPECT_PATH);
+ assertFileEndpoint("file:/target/foo/bar/", File.separator +
EXPECT_PATH);
assertFileEndpoint("file:/", File.separator);
assertFileEndpoint("file:///", File.separator);
}
+ public void testConsumerConfigurations() throws Exception {
+ FileConsumer consumer =
createFileConsumer("file://target/foo/bar?consumer.recursive=true");
+ assertEquals("The recurisive should be true", consumer.isRecursive(),
true);
+ try {
+ consumer =
createFileConsumer("file://target/foo/bar?consumer.recursiv=true");
+ fail("Expect a configure exception here");
+ } catch (Exception ex) {
+ assertTrue("Get the wrong exception type here", ex instanceof
ResolveEndpointFailedException);
+ }
+ }
+
+ private FileConsumer createFileConsumer(String endpointUri) throws
Exception {
+ FileEndpoint endpoint = resolveMandatoryEndpoint(endpointUri,
FileEndpoint.class);
+ return (FileConsumer)endpoint.createConsumer(DUMMY_PROCESSOR);
+ }
+
private void assertFileEndpoint(String endpointUri, String expectedPath) {
FileEndpoint endpoint = resolveMandatoryEndpoint(endpointUri,
FileEndpoint.class);
assertNotNull("Could not find endpoint: " + endpointUri, endpoint);
@@ -50,10 +73,10 @@
File file = endpoint.getFile();
String path = file.getPath();
assertEquals("For uri: " + endpointUri + " the file is not equal",
expectedPath, path);
-
+
File consumedFile = new File(expectedPath +
(expectedPath.endsWith(File.separator) ? "" : File.separator) + EXPECT_FILE);
Message message = new DefaultMessage();
endpoint.configureMessage(consumedFile, message);
- assertEquals(EXPECT_FILE,
message.getHeader(FileComponent.HEADER_FILE_NAME));
+ assertEquals(EXPECT_FILE,
message.getHeader(FileComponent.HEADER_FILE_NAME));
}
}