camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hekon...@apache.org
Subject camel git commit: Improved AMQP test coverage.
Date Tue, 01 Dec 2015 16:31:26 GMT
Repository: camel
Updated Branches:
  refs/heads/master de6f32fe3 -> 106783fee


Improved AMQP test coverage.


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

Branch: refs/heads/master
Commit: 106783fee2b9de40f12e4f85cc01731af7b75aa3
Parents: de6f32f
Author: Henryk Konsek <hekonsek@gmail.com>
Authored: Tue Dec 1 17:31:18 2015 +0100
Committer: Henryk Konsek <hekonsek@gmail.com>
Committed: Tue Dec 1 17:31:18 2015 +0100

----------------------------------------------------------------------
 .../camel/component/amqp/AMQPComponent.java     |  2 -
 .../camel/component/amqp/AMQPRouteTest.java     | 48 ++++++++++++--------
 2 files changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/106783fe/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
index e326cf4..3100e20 100644
--- a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
+++ b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
@@ -17,11 +17,9 @@
 package org.apache.camel.component.amqp;
 
 import java.net.MalformedURLException;
-import java.net.URISyntaxException;
 import javax.jms.ConnectionFactory;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Component;
 import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.jms.JmsConfiguration;
 import org.apache.qpid.jms.JmsConnectionFactory;

http://git-wip-us.apache.org/repos/asf/camel/blob/106783fe/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
b/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
index 73ac9e0..d5d37db 100644
--- a/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
+++ b/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
@@ -18,22 +18,38 @@ package org.apache.camel.component.amqp;
 
 import org.apache.activemq.broker.BrokerService;
 import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import static org.apache.camel.component.amqp.AMQPComponent.amqpComponent;
 
 public class AMQPRouteTest extends CamelTestSupport {
 
-    protected MockEndpoint resultEndpoint;
+    static BrokerService broker;
 
-    protected BrokerService broker;
+    @EndpointInject(uri = "mock:result")
+    MockEndpoint resultEndpoint;
 
     String expectedBody = "Hello there!";
 
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        broker = new BrokerService();
+        broker.setPersistent(false);
+        broker.addConnector("amqp://0.0.0.0:5672");
+        broker.start();
+    }
+
+    @AfterClass
+    public static void afterClass() throws Exception {
+        broker.stop();
+    }
+
     @Test
     public void testJmsQueue() throws Exception {
         resultEndpoint.expectedMessageCount(1);
@@ -43,6 +59,12 @@ public class AMQPRouteTest extends CamelTestSupport {
     }
 
     @Test
+    public void testRequestReply() {
+        String response = template.requestBody("amqp1-0:queue:inOut", expectedBody, String.class);
+        assertEquals("response", response);
+    }
+
+    @Test
     public void testJmsTopic() throws Exception {
         resultEndpoint.expectedMessageCount(2);
         resultEndpoint.message(0).header("cheese").isEqualTo(123);
@@ -50,23 +72,6 @@ public class AMQPRouteTest extends CamelTestSupport {
         resultEndpoint.assertIsSatisfied();
     }
 
-    @Before
-    public void setUp() throws Exception {
-        broker = new BrokerService();
-        broker.setPersistent(false);
-        broker.addConnector("amqp://0.0.0.0:5672");
-        broker.start();
-
-        super.setUp();
-        resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class);
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-        broker.stop();
-    }
-
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
         camelContext.addComponent("amqp1-0", amqpComponent("amqp://localhost:5672"));
@@ -80,6 +85,9 @@ public class AMQPRouteTest extends CamelTestSupport {
                     .to("log:routing")
                     .to("mock:result");
 
+                from("amqp1-0:queue:inOut")
+                        .setBody().constant("response");
+
                 from("amqp1-0:topic:ping")
                         .to("log:routing")
                         .to("mock:result");


Mime
View raw message