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 2014/12/18 07:21:57 UTC
[1/3] camel git commit: CAMEL-8157 Fixed NPE error of
camel-example-servlet-tomcat with the streamcache enabled.
Repository: camel
Updated Branches:
refs/heads/master 5bd61ab55 -> 0368fcb1c
CAMEL-8157 Fixed NPE error of camel-example-servlet-tomcat with the streamcache enabled.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0368fcb1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0368fcb1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0368fcb1
Branch: refs/heads/master
Commit: 0368fcb1c37606875b425d86ebf138d7557f50a9
Parents: f1bd37b
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Dec 18 12:23:36 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Dec 18 14:20:49 2014 +0800
----------------------------------------------------------------------
.../camel/processor/CamelInternalProcessor.java | 7 ++-
.../HttpClientRouteExampleSpringTest.java | 48 +++++++++++++++++
.../component/servlet/example-camelContext.xml | 52 ++++++++++++++++++
.../camel/component/servlet/web-example.xml | 57 ++++++++++++++++++++
4 files changed, 163 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0368fcb1/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
index 47c2311..099af1b 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
@@ -755,7 +755,12 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor {
@Override
public void after(Exchange exchange, StreamCache sc) throws Exception {
- Object body = exchange.getIn().getBody();
+ Object body = null;
+ if (exchange.hasOut()) {
+ body = exchange.getOut().getBody();
+ } else {
+ body = exchange.getIn().getBody();
+ }
if (body != null && body instanceof StreamCache) {
// reset so the cache is ready to be reused after processing
((StreamCache) body).reset();
http://git-wip-us.apache.org/repos/asf/camel/blob/0368fcb1/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
new file mode 100644
index 0000000..7530776
--- /dev/null
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.servlet;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.servletunit.ServletUnitClient;
+import org.junit.Before;
+import org.junit.Test;
+
+public class HttpClientRouteExampleSpringTest extends ServletCamelRouterTestSupport {
+ @Test
+ public void testHttpRestricMethod() throws Exception {
+
+ ServletUnitClient client = newClient();
+ // Send a web get method request
+ WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
+ WebResponse response = client.getResponse(req);
+
+ System.out.println(response.getText());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ startCamelContext = false;
+ super.setUp();
+ }
+
+ protected String getConfiguration() {
+ return "/org/apache/camel/component/servlet/web-example.xml";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0368fcb1/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/example-camelContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/example-camelContext.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/example-camelContext.xml
new file mode 100644
index 0000000..13637de
--- /dev/null
+++ b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/example-camelContext.xml
@@ -0,0 +1,52 @@
+<?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"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ 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
+ ">
+
+ <camelContext id="camel" streamCache="true" xmlns="http://camel.apache.org/schema/spring" >
+ <route id="helloRoute">
+ <!-- incoming requests from the servlet is routed -->
+ <from uri="servlet:///hello"/>
+ <choice>
+ <when>
+ <!-- is there a header with the key name? -->
+ <header>name</header>
+ <!-- yes so return back a message to the user -->
+ <transform>
+ <simple>Hello ${header.name} how are you?</simple>
+ </transform>
+ </when>
+ <otherwise>
+ <!-- if no name parameter then output a syntax to the user -->
+ <transform>
+ <constant>Add a name parameter to uri, eg ?name=foo</constant>
+ </transform>
+ </otherwise>
+ </choice>
+ </route>
+ </camelContext>
+
+
+
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/0368fcb1/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml
new file mode 100644
index 0000000..c39b313
--- /dev/null
+++ b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<!--
+ 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.
+-->
+<!-- START SNIPPET: web -->
+<web-app>
+
+ <!-- tell Spring where it should load the XML file -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>classpath:org/apache/camel/component/servlet/example-camelContext.xml</param-value>
+ </context-param>
+
+ <!-- spring context listener which loads the XML file -->
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <!-- Camel Servlet -->
+ <servlet>
+ <servlet-name>CamelServlet</servlet-name>
+ <display-name>Camel Http Transport Servlet</display-name>
+ <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
+ <init-param>
+ <param-name>matchOnUriPrefix</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ </servlet>
+
+ <!-- Camel Servlet mappings -->
+ <servlet-mapping>
+ <servlet-name>CamelServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+<!-- END SNIPPET: web -->
\ No newline at end of file
[3/3] camel git commit: Fixed the CS error of camel component
Posted by ni...@apache.org.
Fixed the CS error of camel component
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ccab027f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ccab027f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ccab027f
Branch: refs/heads/master
Commit: ccab027f48df20e04c21e48ab0ce34056facffc5
Parents: 5bd61ab
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Dec 18 11:23:29 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Dec 18 14:20:49 2014 +0800
----------------------------------------------------------------------
.../camel/component/jetty/DefaultJettyHttpBinding.java | 2 +-
.../java/org/apache/camel/test/junit4/TestSupport.java | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ccab027f/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
index 5137d15..92b6c21 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
@@ -192,7 +192,7 @@ public class DefaultJettyHttpBinding implements JettyHttpBinding {
}
Map<String, String> getSimpleMap(Map<String, Collection<String>> headers) {
- Map<String, String> result = new HashMap<String ,String>();
+ Map<String, String> result = new HashMap<String , String>();
for (String key : headers.keySet()) {
Collection<String> valueCol = headers.get(key);
String value = (valueCol == null) ? null : valueCol.iterator().next();
http://git-wip-us.apache.org/repos/asf/camel/blob/ccab027f/components/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java b/components/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java
index f086c82..0df328a 100644
--- a/components/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java
+++ b/components/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java
@@ -149,11 +149,11 @@ public abstract class TestSupport extends Assert {
}
public static <T extends Throwable> T assertThrowable(Class<T> expectedType, Throwable t) {
- assertNotNull("Expected an exinstance of type: " + expectedType.getName() + " but was null", t);
- if (!expectedType.isInstance(t)) {
- throw new AssertionError("Unexpected throwable", t);
- }
- return expectedType.cast(t);
+ assertNotNull("Expected an exinstance of type: " + expectedType.getName() + " but was null", t);
+ if (!expectedType.isInstance(t)) {
+ throw new AssertionError("Unexpected throwable", t);
+ }
+ return expectedType.cast(t);
}
public static void assertEndpointUri(Endpoint endpoint, String uri) {
[2/3] camel git commit: Support to run the servlet example with Jetty
maven plugin
Posted by ni...@apache.org.
Support to run the servlet example with Jetty maven plugin
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f1bd37b0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f1bd37b0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f1bd37b0
Branch: refs/heads/master
Commit: f1bd37b0ad0a3f7efbf0de2e99bb913cd9ccec6e
Parents: ccab027
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Dec 18 11:44:19 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Dec 18 14:20:49 2014 +0800
----------------------------------------------------------------------
examples/camel-example-servlet-tomcat-no-spring/pom.xml | 1 +
examples/camel-example-servlet-tomcat/pom.xml | 11 +++++++++++
2 files changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f1bd37b0/examples/camel-example-servlet-tomcat-no-spring/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-servlet-tomcat-no-spring/pom.xml b/examples/camel-example-servlet-tomcat-no-spring/pom.xml
index c3ed38e..7721a0b 100755
--- a/examples/camel-example-servlet-tomcat-no-spring/pom.xml
+++ b/examples/camel-example-servlet-tomcat-no-spring/pom.xml
@@ -62,6 +62,7 @@
<build>
<plugins>
+ <!-- allows running this example with mvn:jetty-run -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/camel/blob/f1bd37b0/examples/camel-example-servlet-tomcat/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-servlet-tomcat/pom.xml b/examples/camel-example-servlet-tomcat/pom.xml
index 1df0c40..0fa479b 100755
--- a/examples/camel-example-servlet-tomcat/pom.xml
+++ b/examples/camel-example-servlet-tomcat/pom.xml
@@ -63,5 +63,16 @@
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <!-- allows running this example with mvn:jetty-run -->
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>${jetty-version}</version>
+ </plugin>
+ </plugins>
+ </build>
</project>