camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r645992 - in /activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina: MinaConfigurationTest.java MinaExchangeDefaultTimeOutTest.java MinaExchangeTimeOutTest.java
Date Tue, 08 Apr 2008 16:30:37 GMT
Author: jstrachan
Date: Tue Apr  8 09:30:36 2008
New Revision: 645992

URL: http://svn.apache.org/viewvc?rev=645992&view=rev
Log:
refactored the unit tests a little to ensure they use different ports and don't sometimes
fail :)

Added:
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConfigurationTest.java
      - copied, changed from r645879, activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
      - copied, changed from r645879, activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
Modified:
    activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java

Copied: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConfigurationTest.java
(from r645879, activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConfigurationTest.java?p2=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConfigurationTest.java&p1=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java&r1=645879&r2=645992&rev=645992&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConfigurationTest.java
Tue Apr  8 09:30:36 2008
@@ -31,63 +31,18 @@
  *
  * @version $Revision$
  */
-public class MinaExchangeTimeOutTest extends ContextTestSupport {
+public class MinaConfigurationTest extends ContextTestSupport {
 
-    private static final int PORT = 6336;
-    protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
-
-    public void testDefaultTimeOut() {
-        try {
-            String result = (String)template.requestBody(uri, "Hello World");
-            assertEquals("Okay I will be faster in the future", result);
-        } catch (RuntimeCamelException e) {
-            fail("Should not get a RuntimeCamelException");
-        }
-    }
-
-    public void testUsingTimeoutParameter() throws Exception {
-
-        // use a timeout value of 2 seconds (timeout is in millis) so we should actually
get a response in this test
-        Endpoint endpoint = this.context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=2000");
-        Producer producer = endpoint.createProducer();
-        producer.start();
-        Exchange exchange = producer.createExchange();
-        exchange.getIn().setBody("Hello World");
-        try {
-            producer.process(exchange);
-            fail("Should have thrown an ExchangeTimedOutException wrapped in a RuntimeCamelException");
-        } catch (Exception e) {
-            assertTrue("Should have thrown an ExchangeTimedOutException", e instanceof ExchangeTimedOutException);
-        }
-        producer.stop();
-    }
+    private static final int PORT = 6337;
 
     public void testTimeoutInvalidParameter() throws Exception {
         // invalid timeout parameter that can not be converted to a number
         try {
-            this.context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=XXX");
+            context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=XXX");
             fail("Should have thrown a ResolveEndpointFailedException due to invalid timeout
parameter");
         } catch (ResolveEndpointFailedException e) {
             assertTrue(e.getCause() instanceof IllegalArgumentException);
             assertEquals("The timeout parameter is not a number: XXX", e.getCause().getMessage());
         }
     }
-
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-            public void configure() {
-                from(uri).process(new Processor() {
-                    public void process(Exchange e) throws Exception {
-                        assertEquals("Hello World", e.getIn().getBody(String.class));
-                        // MinaProducer has a default timeout of 30 seconds so we just wait
5 seconds
-                        // (template.requestBody is a MinaProducer behind the doors)
-                        Thread.sleep(5000);
-
-                        e.getOut().setBody("Okay I will be faster in the future");
-                    }
-                });
-            }
-        };
-    }
-
-}
+}
\ No newline at end of file

Copied: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
(from r645879, activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java?p2=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java&p1=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java&r1=645879&r2=645992&rev=645992&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
Tue Apr  8 09:30:36 2008
@@ -31,9 +31,9 @@
  *
  * @version $Revision$
  */
-public class MinaExchangeTimeOutTest extends ContextTestSupport {
+public class MinaExchangeDefaultTimeOutTest extends ContextTestSupport {
 
-    private static final int PORT = 6336;
+    private static final int PORT = 6338;
     protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
 
     public void testDefaultTimeOut() {
@@ -45,34 +45,6 @@
         }
     }
 
-    public void testUsingTimeoutParameter() throws Exception {
-
-        // use a timeout value of 2 seconds (timeout is in millis) so we should actually
get a response in this test
-        Endpoint endpoint = this.context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=2000");
-        Producer producer = endpoint.createProducer();
-        producer.start();
-        Exchange exchange = producer.createExchange();
-        exchange.getIn().setBody("Hello World");
-        try {
-            producer.process(exchange);
-            fail("Should have thrown an ExchangeTimedOutException wrapped in a RuntimeCamelException");
-        } catch (Exception e) {
-            assertTrue("Should have thrown an ExchangeTimedOutException", e instanceof ExchangeTimedOutException);
-        }
-        producer.stop();
-    }
-
-    public void testTimeoutInvalidParameter() throws Exception {
-        // invalid timeout parameter that can not be converted to a number
-        try {
-            this.context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=XXX");
-            fail("Should have thrown a ResolveEndpointFailedException due to invalid timeout
parameter");
-        } catch (ResolveEndpointFailedException e) {
-            assertTrue(e.getCause() instanceof IllegalArgumentException);
-            assertEquals("The timeout parameter is not a number: XXX", e.getCause().getMessage());
-        }
-    }
-
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
@@ -90,4 +62,4 @@
         };
     }
 
-}
+}
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java?rev=645992&r1=645991&r2=645992&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
(original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
Tue Apr  8 09:30:36 2008
@@ -36,15 +36,6 @@
     private static final int PORT = 6336;
     protected String uri = "mina:tcp://localhost:" + PORT + "?textline=true&sync=true";
 
-    public void testDefaultTimeOut() {
-        try {
-            String result = (String)template.requestBody(uri, "Hello World");
-            assertEquals("Okay I will be faster in the future", result);
-        } catch (RuntimeCamelException e) {
-            fail("Should not get a RuntimeCamelException");
-        }
-    }
-
     public void testUsingTimeoutParameter() throws Exception {
 
         // use a timeout value of 2 seconds (timeout is in millis) so we should actually
get a response in this test
@@ -60,17 +51,6 @@
             assertTrue("Should have thrown an ExchangeTimedOutException", e instanceof ExchangeTimedOutException);
         }
         producer.stop();
-    }
-
-    public void testTimeoutInvalidParameter() throws Exception {
-        // invalid timeout parameter that can not be converted to a number
-        try {
-            this.context.getEndpoint("mina:tcp://localhost:" + PORT + "?textline=true&sync=true&timeout=XXX");
-            fail("Should have thrown a ResolveEndpointFailedException due to invalid timeout
parameter");
-        } catch (ResolveEndpointFailedException e) {
-            assertTrue(e.getCause() instanceof IllegalArgumentException);
-            assertEquals("The timeout parameter is not a number: XXX", e.getCause().getMessage());
-        }
     }
 
     protected RouteBuilder createRouteBuilder() {



Mime
View raw message