You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/06/09 02:59:26 UTC

[1/2] git commit: CAMEL-6442 fix the IllegalStateException issue in camel-netty-http route

Updated Branches:
  refs/heads/master d33db16a3 -> 868a358ad


CAMEL-6442 fix the IllegalStateException issue in camel-netty-http route


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

Branch: refs/heads/master
Commit: 868a358adb801498e2e82b7d8f65547fd4e62eba
Parents: c59092e
Author: Willem Jiang <ni...@apache.org>
Authored: Sat Jun 8 22:33:01 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Sun Jun 9 08:56:34 2013 +0800

----------------------------------------------------------------------
 .../netty/http/NettyRouteSimpleTest.java        | 51 ++++++++++++++++++++
 .../camel/component/netty/NettyProducer.java    | 19 +++++++-
 2 files changed, 69 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/868a358a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyRouteSimpleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyRouteSimpleTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyRouteSimpleTest.java
new file mode 100644
index 0000000..ae5e1ee
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyRouteSimpleTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.netty.http;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NettyRouteSimpleTest extends BaseNettyTest {
+
+    @Test
+    public void testHttpSimple() throws Exception {
+        getMockEndpoint("mock:input1").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:input2").expectedBodiesReceived("Hello World");
+
+        String out = template.requestBody("netty-http:http://localhost:{{port}}/foo", "Hello World", String.class);
+        assertEquals("Bye World", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            int port2 = getNextPort();
+
+            @Override
+            public void configure() throws Exception {
+                from("netty-http:http://0.0.0.0:{{port}}/foo")
+                    .to("mock:input1")
+                    .to("netty-http:http://0.0.0.0:" + port2 + "/bar");
+                from("netty-http:http://0.0.0.0:" + port2 + "/bar")
+                    .to("mock:input2")
+                    .transform().constant("Bye World");
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/868a358a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
index df3c40e..77cee1c 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
@@ -18,8 +18,10 @@ package org.apache.camel.component.netty;
 
 import java.net.InetSocketAddress;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.CamelContext;
@@ -399,7 +401,22 @@ public class NettyProducer extends DefaultAsyncProducer {
         if (LOG.isTraceEnabled()) {
             LOG.trace("Waiting for operation to complete {} for {} millis", channelFuture, configuration.getConnectTimeout());
         }
-        channelFuture.awaitUninterruptibly(configuration.getConnectTimeout());
+        // here we need to wait it in other thread
+        final CountDownLatch channelLatch = new CountDownLatch(1);
+        channelFuture.addListener(new ChannelFutureListener() {
+            @Override
+            public void operationComplete(ChannelFuture cf) throws Exception {
+                channelLatch.countDown();
+            }
+        });
+         
+        try {
+            channelLatch.await(configuration.getConnectTimeout(), TimeUnit.MILLISECONDS);
+        } catch (InterruptedException ex) {
+            throw new CamelException("Interrupted while waiting for " + "connection to "
+                                     + configuration.getAddress());
+        }
+        
 
         if (!channelFuture.isDone() || !channelFuture.isSuccess()) {
             throw new CamelException("Cannot connect to " + configuration.getAddress(), channelFuture.getCause());


[2/2] git commit: Changed the surefire fork mode to make sure the blueprint tests can be passed

Posted by ni...@apache.org.
Changed the surefire fork mode to make sure the blueprint tests can be passed


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

Branch: refs/heads/master
Commit: c59092e50c43b294bc4ecea424281e450ed18d97
Parents: d33db16
Author: Willem Jiang <ni...@apache.org>
Authored: Fri Jun 7 21:13:56 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Sun Jun 9 08:56:34 2013 +0800

----------------------------------------------------------------------
 components/camel-test-blueprint/pom.xml                  | 11 ++++++++++-
 .../BlueprintProduceConsumeImplicitPropertyTest.java     |  4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c59092e5/components/camel-test-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/pom.xml b/components/camel-test-blueprint/pom.xml
index d39c9e2..6843f8d 100644
--- a/components/camel-test-blueprint/pom.xml
+++ b/components/camel-test-blueprint/pom.xml
@@ -163,5 +163,14 @@
         </dependency>
 
     </dependencies>
-
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>pertest</forkMode>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/c59092e5/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintProduceConsumeImplicitPropertyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintProduceConsumeImplicitPropertyTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintProduceConsumeImplicitPropertyTest.java
index e90450e..536cf74 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintProduceConsumeImplicitPropertyTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintProduceConsumeImplicitPropertyTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.test.blueprint;
 
-import org.junit.Ignore;
+//import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -30,7 +30,7 @@ public class BlueprintProduceConsumeImplicitPropertyTest extends CamelBlueprintT
     }
 
     @Test
-    @Ignore("Test fails. Fix Me!")
+    //@Ignore("Test fails. Fix Me!")
     public void testImplicit() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(1);