camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [8/9] git commit: Fixed test
Date Tue, 11 Mar 2014 08:51:35 GMT
Fixed test


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

Branch: refs/heads/camel-2.12.x
Commit: 3f47a99aabff2875da223468f46cf8a301867b94
Parents: e7f9695
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Mar 11 09:35:35 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Mar 11 09:53:47 2014 +0100

----------------------------------------------------------------------
 .../sjms/producer/QueueProducerQoSTest.java     | 109 ++++++++++++++++++
 .../sjms/producer/QueueProduerQoSTest.java      | 112 -------------------
 .../component/sjms/support/JmsTestSupport.java  |   2 +
 3 files changed, 111 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3f47a99a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
new file mode 100644
index 0000000..c82842a
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
@@ -0,0 +1,109 @@
+/**
+ * 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.sjms.producer;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.DestinationViewMBean;
+import org.apache.activemq.broker.region.policy.PolicyEntry;
+import org.apache.activemq.broker.region.policy.PolicyMap;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+import org.junit.Test;
+
+public class QueueProducerQoSTest extends JmsTestSupport {
+
+    private static final String TEST_INONLY_DESTINATION_NAME = "queue.producer.test.qos.inonly";
+    private static final String TEST_INOUT_DESTINATION_NAME = "queue.producer.test.qos.inout";
+
+    private static final String EXPIRED_MESSAGE_ROUTE_ID = "expiredAdvisoryRoute";
+
+    @Test
+    public void testInOutQueueProducerTTL() throws Exception {
+
+        NotifyBuilder expireMatcher = new NotifyBuilder(context)
+                .fromRoute(EXPIRED_MESSAGE_ROUTE_ID).whenCompleted(1).create();
+
+        String endpoint = String.format("sjms:queue:%s?ttl=1000&exchangePattern=InOut&responseTimeOut=500",
TEST_INOUT_DESTINATION_NAME);
+
+        try {
+            template.requestBody(endpoint, "test message");
+            fail("we aren't expecting any consumers, so should not succeed");
+        } catch (Exception e) {
+            // we are expecting an exception here because there are no consumers on this
queue,
+            // so we will not be able to do a real InOut/request-response, but that's okay
+            // we're just interested in the message becoming expired
+        }
+
+        // we should delay a bit so broker can run its expiration processes...
+        assertFalse(expireMatcher.matches(2, TimeUnit.SECONDS));
+
+        DestinationViewMBean queue = getQueueMBean(TEST_INOUT_DESTINATION_NAME);
+        assertEquals("There were unexpected messages left in the queue: " + TEST_INOUT_DESTINATION_NAME,
+                0, queue.getQueueSize());
+    }
+
+    @Test
+    public void testInOnlyQueueProducerTTL() throws Exception {
+        NotifyBuilder expireMatcher = new NotifyBuilder(context)
+                .fromRoute(EXPIRED_MESSAGE_ROUTE_ID).whenCompleted(1).create();
+
+        String endpoint = String.format("sjms:queue:%s?ttl=1000", TEST_INONLY_DESTINATION_NAME);
+        template.sendBody(endpoint, "test message");
+
+        // we should delay a bit so broker can run its expiration processes...
+        assertFalse(expireMatcher.matches(2, TimeUnit.SECONDS));
+
+        DestinationViewMBean queue = getQueueMBean(TEST_INONLY_DESTINATION_NAME);
+        assertEquals("There were unexpected messages left in the queue: " + TEST_INONLY_DESTINATION_NAME,
+                0, queue.getQueueSize());
+    }
+
+    @Override
+    protected void configureBroker(BrokerService broker) throws Exception {
+        broker.setUseJmx(true);
+        broker.setPersistent(true);
+        broker.setDataDirectory("target/activemq-data");
+        broker.deleteAllMessages();
+        broker.setAdvisorySupport(true);
+        broker.addConnector(brokerUri);
+
+        // configure expiration rate
+        ActiveMQQueue queueName = new ActiveMQQueue(">");
+        PolicyEntry entry = new PolicyEntry();
+        entry.setDestination(queueName);
+        entry.setExpireMessagesPeriod(1000);
+
+        PolicyMap policyMap = new PolicyMap();
+        policyMap.put(queueName, entry);
+        broker.setDestinationPolicy(policyMap);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("sjms:topic:ActiveMQ.Advisory.Expired.Queue.>")
+                        .routeId(EXPIRED_MESSAGE_ROUTE_ID)
+                        .to("mock:expiredAdvisory");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3f47a99a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProduerQoSTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProduerQoSTest.java
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProduerQoSTest.java
deleted file mode 100644
index 36d0827..0000000
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProduerQoSTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * 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.sjms.producer;
-
-
-import java.util.concurrent.TimeUnit;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.camel.builder.NotifyBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.sjms.support.JmsTestSupport;
-import org.junit.Test;
-
-
-public class QueueProduerQoSTest extends JmsTestSupport {
-
-    private static final String TEST_INONLY_DESTINATION_NAME = "queue.producer.test.qos.inonly";
-    private static final String TEST_INOUT_DESTINATION_NAME = "queue.producer.test.qos.inout";
-
-    private static final String EXPIRED_MESSAGE_ROUTE_ID = "expiredAdvisoryRoute";
-
-    @Test
-    public void testInOutQueueProducerTTL() throws Exception {
-
-        NotifyBuilder expireMatcher = new NotifyBuilder(context)
-                .fromRoute(EXPIRED_MESSAGE_ROUTE_ID).whenCompleted(1).create();
-
-        String endpoint = String.format("sjms:queue:%s?ttl=1000&exchangePattern=InOut&responseTimeOut=500",
TEST_INOUT_DESTINATION_NAME);
-
-        try {
-            template.requestBody(endpoint, "test message");
-            fail("we aren't expecting any consumers, so should not succeed");
-        } catch (Exception e) {
-            // we are expecting an exception here because there are no consumers on this
queue,
-            // so we will not be able to do a real InOut/request-response, but that's okay
-            // we're just interested in the message becoming expired
-        }
-
-        // we should delay a bit so broker can run its expiration processes...
-        expireMatcher.matches(2, TimeUnit.SECONDS);
-
-        DestinationViewMBean queue = getQueueMBean(TEST_INOUT_DESTINATION_NAME);
-        assertEquals("There were unexpected messages left in the queue: " + TEST_INOUT_DESTINATION_NAME,
-                0, queue.getQueueSize());
-    }
-
-    @Test
-    public void testInOnlyQueueProducerTTL() throws Exception {
-        NotifyBuilder expireMatcher = new NotifyBuilder(context)
-                .fromRoute(EXPIRED_MESSAGE_ROUTE_ID).whenCompleted(1).create();
-
-        String endpoint = String.format("sjms:queue:%s?ttl=1000", TEST_INONLY_DESTINATION_NAME);
-        template.sendBody(endpoint, "test message");
-
-        // we should delay a bit so broker can run its expiration processes...
-        expireMatcher.matches(2, TimeUnit.SECONDS);
-
-
-        DestinationViewMBean queue = getQueueMBean(TEST_INONLY_DESTINATION_NAME);
-        assertEquals("There were unexpected messages left in the queue: " + TEST_INONLY_DESTINATION_NAME,
-                0, queue.getQueueSize());
-    }
-
-    @Override
-    protected void configureBroker(BrokerService broker) throws Exception {
-        broker.setUseJmx(true);
-        broker.setPersistent(true);
-        broker.setDataDirectory("target/activemq-data");
-        broker.deleteAllMessages();
-        broker.setAdvisorySupport(true);
-        broker.addConnector(brokerUri);
-
-        // configure expiration rate
-        ActiveMQQueue queueName = new ActiveMQQueue(">");
-        PolicyEntry entry = new PolicyEntry();
-        entry.setDestination(queueName);
-        entry.setExpireMessagesPeriod(1000);
-
-        PolicyMap policyMap = new PolicyMap();
-        policyMap.put(queueName, entry);
-        broker.setDestinationPolicy(policyMap);
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("sjms:topic:ActiveMQ.Advisory.Expired.Queue.>")
-                        .routeId(EXPIRED_MESSAGE_ROUTE_ID)
-                        .to("mock:expiredAdvisory");
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/3f47a99a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/JmsTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/JmsTestSupport.java
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/JmsTestSupport.java
index 6bf4ff8..7b3e1f7 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/JmsTestSupport.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/JmsTestSupport.java
@@ -55,6 +55,8 @@ public class JmsTestSupport extends CamelTestSupport {
      */
     @Override
     protected void doPreSetup() throws Exception {
+        deleteDirectory("target/activemq-data");
+
         brokerUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable(33333);
 
         broker = new BrokerService();


Mime
View raw message