Coverage Report - org.apache.camel.itest.jms.JmsIntegrationTest
 
Classes in this File Line Coverage Branch Coverage Complexity
JmsIntegrationTest
0% 
N/A 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.itest.jms;
 19  
 
 20  
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
 21  
 
 22  
 import javax.jms.ConnectionFactory;
 23  
 import javax.jms.Message;
 24  
 import javax.jms.MessageListener;
 25  
 
 26  
 import junit.framework.TestCase;
 27  
 
 28  
 import org.apache.activemq.ActiveMQConnectionFactory;
 29  
 import org.apache.camel.CamelContext;
 30  
 import org.apache.camel.Producer;
 31  
 import org.apache.camel.builder.RouteBuilder;
 32  
 import org.apache.camel.component.jms.JmsEndpoint;
 33  
 import org.apache.camel.component.jms.JmsExchange;
 34  
 import org.apache.camel.component.jms.JmsMessage;
 35  
 import org.apache.camel.component.pojo.PojoComponent;
 36  
 import org.apache.camel.impl.DefaultCamelContext;
 37  
 import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
 38  
 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
 39  
 
 40  
 /**
 41  
  * @version $Revision:520964 $
 42  
  */
 43  0
 public class JmsIntegrationTest extends TestCase {
 44  
         
 45  0
     protected CamelContext container = new DefaultCamelContext();
 46  
 
 47  
     public void testDummy() {
 48  0
     }
 49  
     
 50  
     /**
 51  
      * Commented out since this fails due to us not converting the JmsExchange to a PojoExchange
 52  
      * 
 53  
      * @throws Exception
 54  
      */
 55  
         public void xtestOneWayInJmsOutPojo() throws Exception {
 56  
                 
 57  0
                 final CountDownLatch receivedCountDown = new CountDownLatch(1);
 58  
                 
 59  
         // Configure the components
 60  0
         ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
 61  0
         container.addComponent("activemq", jmsComponentClientAcknowledge(connectionFactory));
 62  0
         PojoComponent component = new PojoComponent();
 63  0
         component.addService("listener", new MessageListener(){
 64  0
                         public void onMessage(Message msg) {
 65  0
                                 System.out.println("Received: "+msg);
 66  0
                                 receivedCountDown.countDown();                                
 67  0
                         }
 68  
                 });
 69  0
         container.addComponent("default", component);
 70  
 
 71  
         // lets add a jms -> pojo route
 72  0
         container.addRoutes(new RouteBuilder() {
 73  0
             public void configure() {
 74  0
                 from("jms:test").to("pojo:listener");
 75  0
             }
 76  
         });
 77  
         
 78  0
         container.start();
 79  
         
 80  
         // Send a message to the JMS endpoint
 81  0
         JmsEndpoint endpoint = (JmsEndpoint) container.getEndpoint("jms:test");        
 82  0
         Producer<JmsExchange> producer = endpoint.createProducer();
 83  0
         JmsExchange exchange = producer.createExchange();
 84  0
         JmsMessage in = exchange.getIn();
 85  0
         in.setBody("Hello");
 86  0
         in.setHeader("cheese", 123);
 87  0
         producer.process(exchange);
 88  
         
 89  
         // The Activated endpoint should send it to the pojo due to the configured route.
 90  0
         assertTrue("The message ware received by the Pojo", receivedCountDown.await(5, TimeUnit.SECONDS));
 91  
         
 92  
 
 93  0
         }
 94  
 
 95  
     @Override
 96  
     protected void tearDown() throws Exception {
 97  0
         container.stop();
 98  
 
 99  0
         super.tearDown();
 100  0
     }
 101  
 }