Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2AFBA9322 for ; Mon, 25 Feb 2013 21:02:25 +0000 (UTC) Received: (qmail 21065 invoked by uid 500); 25 Feb 2013 21:02:24 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 21030 invoked by uid 500); 25 Feb 2013 21:02:24 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 21022 invoked by uid 99); 25 Feb 2013 21:02:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 21:02:24 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: 216.139.236.26 is neither permitted nor denied by domain of shyenuganti@gmail.com) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Feb 2013 21:02:18 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1UA5BN-0007ql-Gi for users@camel.apache.org; Mon, 25 Feb 2013 13:01:57 -0800 Date: Mon, 25 Feb 2013 13:01:57 -0800 (PST) From: shyenuganti To: users@camel.apache.org Message-ID: <1361826117511-5728122.post@n5.nabble.com> Subject: My First Camel Route. Need help unit testing and refactoring. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Here is a sample route written in Camel for our application. This is our first ever route in camel. This route reads Event Table in Oracle and AS400 systems, extracts an XML message from the record and send the message to JMS queue. All the JDBC and JMS endpoints are based on JNDI Lookup. This is working fine. Now I am a bit confused on how to write unit/integration tests for this route. Can anyone help me with a sample unit test methods for this route? Do we have to use "mocks" for testing? Cant we replace the components with mocks on the fly ? Should we have multiple application context files in test/resources thaat mocks the JPA and jms endpoints for testing ? Any comments on the route structure or any refactoring/best practice ideas are welcome. Please assist. public class EventListenerRoute extends RouteBuilder implements InitializingBean, DisposableBean{ public void configure() throws Exception { from("as400Jpa://org.model.EventQueue?consumeDelete=false&consumer.delay=5000") .id("AS400ReaderEndpoint") .convertBodyTo(org.model.EventQueue.class) .to("direct:eventMessageList"); from("oracleJpa://org.model.EventQueue?consumeDelete=false&consumer.delay=5000") .id("OracleReaderEndpoint") .convertBodyTo(org.model.EventQueue.class) .to("direct:eventMessageList"); from("direct:eventMessageList").id("PseudoEventQueue") .log("Sending Message to Queue: jbossEventQueue") .to("jms:queue/jbossEventQueue?messageConverter=#myMessageConverter") .log("Sent message to jbossEventQueue"); } -- View this message in context: http://camel.465427.n5.nabble.com/My-First-Camel-Route-Need-help-unit-testing-and-refactoring-tp5728122.html Sent from the Camel - Users mailing list archive at Nabble.com.