Repository: camel
Updated Branches:
  refs/heads/master 3cdd10598 -> a13b34925


Fixed test to be more reliable


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a13b3492
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a13b3492
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a13b3492

Branch: refs/heads/master
Commit: a13b34925672b609b88611de9a1358adc4e21fb9
Parents: 3cdd105
Author: Claus Ibsen <davscl...@apache.org>
Authored: Fri Sep 30 13:45:57 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Sep 30 13:46:10 2016 +0200

----------------------------------------------------------------------
 .../jms/JmsDestinationResolverTest.java         | 67 ++++++--------------
 .../component/jms/jmsDestinationResolver.xml    | 37 -----------
 2 files changed, 20 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a13b3492/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDestinationResolverTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDestinationResolverTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDestinationResolverTest.java
index 8d85b60..492bc04 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDestinationResolverTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDestinationResolverTest.java
@@ -16,78 +16,51 @@
  */
 package org.apache.camel.component.jms;
 
+import javax.jms.ConnectionFactory;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.util.IOHelper;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static 
org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
 
 /**
- * @version 
+ * @version
  */
 public class JmsDestinationResolverTest extends CamelTestSupport {
 
-    protected MockEndpoint resultEndpoint;
     protected String componentName = "activemq";
-    protected String startEndpointUri;
-    private ClassPathXmlApplicationContext applicationContext;
-    
+
     @Test
     public void testSendAndReceiveMessage() throws Exception {
-        assertSendAndReceiveBody("Hello there!");
-    }
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived("Hello World");
+        result.message(0).header("cheese").isEqualTo(123);
 
-    protected void assertSendAndReceiveBody(Object expectedBody) throws 
InterruptedException {
-        resultEndpoint.expectedBodiesReceived(expectedBody);
-        resultEndpoint.message(0).header("cheese").isEqualTo(123);
-
-        sendExchange(expectedBody);
-
-        resultEndpoint.assertIsSatisfied();
-    }
+        template.sendBodyAndHeader("direct:start", "Hello World", "cheese", 
123);
 
-    protected void sendExchange(final Object expectedBody) {
-        template.sendBodyAndHeader(startEndpointUri, expectedBody, "cheese", 
123);
+        assertMockEndpointsSatisfied();
     }
 
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
 
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        startEndpointUri = "activemq:queue:test.a";
+        ConnectionFactory connectionFactory = 
CamelJmsTestHelper.createConnectionFactory();
+        camelContext.addComponent(componentName, 
jmsComponentAutoAcknowledge(connectionFactory));
 
-        super.setUp();
+        JmsComponent jms = camelContext.getComponent(componentName, 
JmsComponent.class);
+        jms.setDestinationResolver(new MyDestinationResolver());
 
-        resultEndpoint = context.getEndpoint("mock:result", 
MockEndpoint.class);
-    }
-    
-    @Override
-    protected CamelContext createCamelContext() throws Exception {
-        applicationContext = createApplicationContext();
-        return SpringCamelContext.springCamelContext(applicationContext);
-        
-    }
-    
-    protected ClassPathXmlApplicationContext createApplicationContext() {
-        return new 
ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsDestinationResolver.xml");
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
-        IOHelper.close(applicationContext);
+        return camelContext;
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                
from(startEndpointUri).to("activemq:queue:logicalNameForTestBQueue");
+                
from("direct:start").to("activemq:queue:logicalNameForTestBQueue");
+
                 from("activemq:queue:test.b").to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/a13b3492/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsDestinationResolver.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsDestinationResolver.xml
 
b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsDestinationResolver.xml
deleted file mode 100644
index a81ae5a..0000000
--- 
a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsDestinationResolver.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
-       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
-    ">
-
-  <!-- START SNIPPET: example -->
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>
-      <jmxAgent id="agent" disabled="true"/>
-  </camelContext>
-
-  <bean id="destinationResolver" 
class="org.apache.camel.component.jms.MyDestinationResolver"/>
-
-  <bean id="connectionFactory" 
class="org.apache.activemq.ActiveMQConnectionFactory">
-    <property name="brokerURL" 
value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
-  </bean>
-  <!-- END SNIPPET: example -->
-
-</beans>

Reply via email to