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 2010/07/06 18:13:32 UTC
svn commit: r960930 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/component/file/
test/java/org/apache/camel/component/file/
test/java/org/apache/camel/management/
Author: davsclaus
Date: Tue Jul 6 16:13:31 2010
New Revision: 960930
URL: http://svn.apache.org/viewvc?rev=960930&view=rev
Log:
Fixed tests and CS.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendAndResumeTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSuspendedServiceTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java?rev=960930&r1=960929&r2=960930&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java Tue Jul 6 16:13:31 2010
@@ -192,11 +192,13 @@ public abstract class GenericFileConsume
* @return <tt>true</tt> to continue, <tt>false</tt> to stop due hitting maxMessagesPerPoll limit
*/
public boolean canPollMoreFiles(List fileList) {
- if (maxMessagesPerPoll > 0 && fileList.size() >= maxMessagesPerPoll) {
- return false;
- } else {
+ if (maxMessagesPerPoll <= 0) {
+ // no limitation
return true;
}
+
+ // then only poll if we haven't reached the max limit
+ return fileList.size() < maxMessagesPerPoll;
}
/**
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java?rev=960930&r1=960929&r2=960930&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMaxMessagesPerPollTest.java Tue Jul 6 16:13:31 2010
@@ -26,7 +26,7 @@ import org.apache.camel.component.mock.M
*/
public class FileConsumeMaxMessagesPerPollTest extends ContextTestSupport {
- private String fileUrl = "file://target/poll/?initialDelay=2000&delay=5000&sortBy=file:name&maxMessagesPerPoll=2";
+ private String fileUrl = "file://target/poll/?initialDelay=2000&delay=5000&maxMessagesPerPoll=2";
@Override
protected void setUp() throws Exception {
@@ -39,14 +39,14 @@ public class FileConsumeMaxMessagesPerPo
public void testMaxMessagesPerPoll() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Bye World", "Godday World");
+ mock.expectedMessageCount(2);
mock.setResultWaitTime(3000);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
assertMockEndpointsSatisfied();
mock.reset();
- mock.expectedBodiesReceived("Hello World");
+ mock.expectedMessageCount(1);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);
assertMockEndpointsSatisfied();
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendAndResumeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendAndResumeTest.java?rev=960930&r1=960929&r2=960930&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendAndResumeTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendAndResumeTest.java Tue Jul 6 16:13:31 2010
@@ -47,8 +47,9 @@ public class FileConsumerSuspendAndResum
Thread.sleep(1000);
// the route is suspended by the policy so we should only receive one
- File file = new File("target/suspended/hello.txt").getAbsoluteFile();
- assertEquals("The file should exists", true, file.exists());
+ String[] files = new File("target/suspended/").getAbsoluteFile().list();
+ assertNotNull(files);
+ assertEquals("The file should exists", 1, files.length);
// reset mock
mock.reset();
@@ -61,8 +62,10 @@ public class FileConsumerSuspendAndResum
Thread.sleep(500);
- // and the file is now moved
- assertEquals("The file should not exists", false, file.exists());
+ // and the file is now deleted
+ files = new File("target/suspended/").getAbsoluteFile().list();
+ assertNotNull(files);
+ assertEquals("The file should exists", 0, files.length);
}
@Override
@@ -70,7 +73,7 @@ public class FileConsumerSuspendAndResum
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("file://target/suspended?maxMessagesPerPoll=1&sortBy=file:name")
+ from("file://target/suspended?maxMessagesPerPoll=1&delete=true")
.routePolicy(myPolicy).id("myRoute")
.convertBodyTo(String.class).to("mock:result");
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendTest.java?rev=960930&r1=960929&r2=960930&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSuspendTest.java Tue Jul 6 16:13:31 2010
@@ -44,8 +44,9 @@ public class FileConsumerSuspendTest ext
Thread.sleep(1000);
// the route is suspended by the policy so we should only receive one
- File file = new File("target/suspended/hello.txt").getAbsoluteFile();
- assertEquals("The file should exists", true, file.exists());
+ String[] files = new File("target/suspended/").getAbsoluteFile().list();
+ assertNotNull(files);
+ assertEquals("The file should exists", 1, files.length);
}
@Override
@@ -54,7 +55,7 @@ public class FileConsumerSuspendTest ext
@Override
public void configure() throws Exception {
MyPolicy myPolicy = new MyPolicy();
- from("file://target/suspended?maxMessagesPerPoll=1&sortBy=file:name")
+ from("file://target/suspended?maxMessagesPerPoll=1&delete=true")
.routePolicy(myPolicy).id("myRoute")
.convertBodyTo(String.class).to("mock:result");
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSuspendedServiceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSuspendedServiceTest.java?rev=960930&r1=960929&r2=960930&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSuspendedServiceTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSuspendedServiceTest.java Tue Jul 6 16:13:31 2010
@@ -71,8 +71,9 @@ public class ManagedSuspendedServiceTest
assertEquals(true, suspended.booleanValue());
// the route is suspended by the policy so we should only receive one
- File file = new File("target/suspended/hello.txt").getAbsoluteFile();
- assertEquals("The file should exists", true, file.exists());
+ String[] files = new File("target/suspended/").getAbsoluteFile().list();
+ assertNotNull(files);
+ assertEquals("The file should exists", 1, files.length);
// reset mock
mock.reset();
@@ -88,8 +89,10 @@ public class ManagedSuspendedServiceTest
Thread.sleep(500);
- // and the file is now moved
- assertEquals("The file should not exists", false, file.exists());
+ // and the file is now deleted
+ files = new File("target/suspended/").getAbsoluteFile().list();
+ assertNotNull(files);
+ assertEquals("The file should exists", 0, files.length);
}
@Override
@@ -99,7 +102,7 @@ public class ManagedSuspendedServiceTest
public void configure() throws Exception {
MyPolicy myPolicy = new MyPolicy();
- from("file://target/suspended?maxMessagesPerPoll=1&sortBy=file:name")
+ from("file://target/suspended?maxMessagesPerPoll=1&delete=true")
.routePolicy(myPolicy).id("myRoute")
.to("mock:result");
}