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 2011/10/19 11:20:59 UTC

svn commit: r1186047 - in /camel/trunk/components: camel-apns/src/test/java/org/apache/camel/component/apns/ camel-atom/src/test/data/ camel-atom/src/test/java/org/apache/camel/component/atom/ camel-aws/src/test/java/org/apache/camel/component/aws/s3/ ...

Author: davsclaus
Date: Wed Oct 19 09:20:58 2011
New Revision: 1186047

URL: http://svn.apache.org/viewvc?rev=1186047&view=rev
Log:
CAMEL-4508: Added option sendEmptyMessageWhenIdle to scheduled poll consumer. Thanks to Rich Newcomb for the patch.

Added:
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-atom/src/test/data/empty-feed.atom
    camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java   (with props)
    camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java   (with props)

Added: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,95 @@
+/**
+ * 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.apns;
+
+import com.notnoop.apns.ApnsService;
+import com.notnoop.apns.utils.ApnsServerStub;
+import com.notnoop.apns.utils.FixedCertificates;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.apns.factory.ApnsServiceFactory;
+import org.apache.camel.component.apns.util.ApnsUtils;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class ApnsConsumerIdleMessageTest extends CamelTestSupport {
+    
+    ApnsServerStub server;
+
+    public ApnsConsumerIdleMessageTest() {
+        super();
+    }
+
+    @Before
+    public void startup() throws InterruptedException {
+        server = ApnsUtils.prepareAndStartServer(FixedCertificates.TEST_GATEWAY_PORT, FixedCertificates.TEST_FEEDBACK_PORT);
+    }
+
+    @After
+    public void stop() {
+        server.stop();
+    }
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        
+        Thread.sleep(1100);
+        // cycling the server after first polling cycle because it can not handle reconnects for fast-cycle polling
+        server.stop();
+        server.start();
+        Thread.sleep(1100);
+        server.stop();
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
+        ApnsService apnsService = apnsServiceFactory.getApnsService();
+
+        ApnsComponent apnsComponent = new ApnsComponent(apnsService);
+        camelContext.addComponent("apns", apnsComponent);
+
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("apns:consumer?initialDelay=1&delay=1&timeUnit=SECONDS&useFixedDelay=true"
+                      + "&sendEmptyMessageWhenIdle=true")
+                    .to("log:com.apache.camel.component.apns?showAll=true&multiline=true")
+                    .to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-atom/src/test/data/empty-feed.atom
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-atom/src/test/data/empty-feed.atom?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-atom/src/test/data/empty-feed.atom (added)
+++ camel/trunk/components/camel-atom/src/test/data/empty-feed.atom Wed Oct 19 09:20:58 2011
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?>
+<!--
+    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.
+-->
+<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'>
+  <id>tag:blogger.com,1999:blog-637417304187784899</id>
+  <updated>2007-12-01T12:33:31.529Z</updated>
+  <title type='text'>James Strachan's Blog</title>
+  <link rel='alternate' type='text/html' href='http://macstrac.blogspot.com/'/>
+  <link rel='next' type='application/atom+xml'
+        href='http://macstrac.blogspot.com/feeds/posts/default?start-index=26&amp;max-results=25'/>
+  <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml'
+        href='http://macstrac.blogspot.com/feeds/posts/default'/>
+  <link rel='self' type='application/atom+xml' href='http://macstrac.blogspot.com/feeds/posts/default'/>
+  <author>
+    <name>James Strachan</name>
+  </author>
+  <generator version='7.00' uri='http://www.blogger.com'>Blogger</generator>
+  <openSearch:totalResults>54</openSearch:totalResults>
+  <openSearch:startIndex>1</openSearch:startIndex>
+  <openSearch:itemsPerPage>25</openSearch:itemsPerPage>
+</feed>
\ No newline at end of file

Added: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,50 @@
+/**
+ * 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.atom;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class AtomPollingConsumerIdleMessageTest extends CamelTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("atom:file:src/test/data/empty-feed.atom?splitEntries=true&consumer.delay=50&consumer.initialDelay=0"
+                     + "&feedHeader=false&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,63 @@
+/**
+ * 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.aws.s3;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class S3ConsumerIdleMessageTest extends CamelTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        
+        AmazonS3ClientMock clientMock = new AmazonS3ClientMock();        
+        registry.bind("amazonS3Client", clientMock);
+        
+        return registry;
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&region=us-west-1&delay=50" 
+                        + "&maxMessagesPerPoll=5&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,63 @@
+/**
+ * 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.aws.sqs;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class SqsConsumerIdleMessageTest extends CamelTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        
+        AmazonSQSClientMock clientMock = new AmazonSQSClientMock();        
+        registry.bind("amazonSQSClient", clientMock);
+        
+        return registry;
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("aws-sqs://MyQueue?amazonSQSClient=#amazonSQSClient&delay=50&maxMessagesPerPoll=5"
+                        + "&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,60 @@
+/**
+ * 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.file.remote;
+
+import java.io.File;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class FtpPollingConsumerIdleMessageTest extends FtpServerTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    @Before
+    public void setup() throws Exception {
+        new File(FTP_ROOT_DIR + "/polling").mkdirs();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("ftp://admin@localhost:" + getPort() + "/polling?password=admin&delay=50"
+                        + "&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+
+
+}

Propchange: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -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.component.ibatis;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class IBatisConsumerIdleMessageTest extends IBatisTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("ibatis:selectAllAccounts?delay=50&consumer.useIterator=false&consumer.routeEmptyResultSet=false"
+                        + "&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");      
+            }
+        };
+    }
+    
+    @Override
+    protected boolean createTestData() {
+        // no test data so an empty resultset
+        return false;
+    }
+}

Propchange: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.jpa;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class JpaConsumerIdleMessageTest extends CamelTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("jpa://org.apache.camel.examples.MultiSteps?consumer.nativeQuery=select * from MultiSteps where step = 1"
+                        + "&delay=50&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -0,0 +1,50 @@
+/**
+ * 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.mail;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class MailConsumerIdleMessageTest extends CamelTestSupport {
+    
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("pop3://james@localhost?password=foo&delay=50&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java?rev=1186047&view=auto
==============================================================================
--- camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java (added)
+++ camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java Wed Oct 19 09:20:58 2011
@@ -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.component.mybatis;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * Test to verify that the polling consumer delivers an empty Exchange when the
+ * sendEmptyMessageWhenIdle property is set and a polling event yields no results.
+ */
+public class MyBatisConsumerIdleMessageTest extends MyBatisTestSupport {
+    
+    @Override
+    protected boolean createTestData() {
+        return false;
+    }
+     
+    @Test
+    public void testConsumeIdleMessages() throws Exception {
+        Thread.sleep(110);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+        assertMockEndpointsSatisfied();
+        assertTrue(mock.getExchanges().get(0).getIn().getBody() == null);
+        assertTrue(mock.getExchanges().get(1).getIn().getBody() == null);
+    }
+    
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("mybatis:selectAllAccounts?statementType=SelectList"
+                        + "&sendEmptyMessageWhenIdle=true")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date