Author: ningjiang
Date: Thu Dec 4 05:54:19 2008
New Revision: 723325
URL: http://svn.apache.org/viewvc?rev=723325&view=rev
Log:
CAMEL-1145 fixed the NPE after the copy work of CxfExchange
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
(with props)
Modified:
activemq/camel/trunk/components/camel-cxf/pom.xml
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
Modified: activemq/camel/trunk/components/camel-cxf/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/pom.xml?rev=723325&r1=723324&r2=723325&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/pom.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/pom.xml Thu Dec 4 05:54:19 2008
@@ -211,6 +211,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java?rev=723325&r1=723324&r2=723325&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
Thu Dec 4 05:54:19 2008
@@ -55,6 +55,11 @@
public CxfExchange(CamelContext context, ExchangePattern pattern) {
super(context, pattern);
}
+
+ public CxfExchange(CxfExchange exchange) {
+ super(exchange);
+ this.exchange = exchange.exchange;
+ }
public CxfExchange(CamelContext context, ExchangePattern pattern, Message
inMessage) {
this(context, pattern);
@@ -73,7 +78,7 @@
@Override
public org.apache.camel.Exchange newInstance() {
- return new CxfExchange(this.getContext(), this.getPattern(),
this.getExchange());
+ return new CxfExchange(this);
}
@Override
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java?rev=723325&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java
Thu Dec 4 05:54:19 2008
@@ -0,0 +1,73 @@
+/**
+ * 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.cxf;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.non_wrapper.types.GetPerson;
+import org.apache.camel.non_wrapper.types.GetPersonResponse;
+import org.apache.camel.processor.DelegateProcessor;
+import org.apache.cxf.message.MessageContentsList;
+
+
+public class RouteBuilderCxfTracer extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("cxf:http://localhost:9000/PersonService/"
+ + "?serviceClass=org.apache.camel.non_wrapper.Person"
+ + "&serviceName={http://camel.apache.org/non-wrapper}PersonService"
+ + "&portName={http://camel.apache.org/non-wrapper}soap"
+ + "&dataFormat=POJO")
+ .intercept(new MyDelegate()).to("direct:something");
+
+ from("direct:something")
+ .process(new DoSomethingProcessor())
+ .process(new DoNothingProcessor());
+ }
+
+ private class DoSomethingProcessor implements Processor {
+ public void process(Exchange exchange) throws Exception {
+ exchange.getOut().setBody(exchange.getIn().getBody() + " world!");
+ }
+ }
+
+ private class DoNothingProcessor implements Processor {
+ public void process(Exchange exchange) throws Exception {
+ exchange.getOut().setBody(exchange.getIn().getBody());
+ }
+ }
+
+ private class MyDelegate extends DelegateProcessor {
+ @Override
+ protected void processNext(Exchange e) throws Exception {
+ MessageContentsList mclIn = (MessageContentsList)
e.getIn().getBody();
+ e.getIn().setBody(((GetPerson) mclIn.get(0)).getPersonId(),
String.class);
+
+ super.processNext(e);
+
+ GetPersonResponse gpr = new GetPersonResponse();
+ gpr.setName("Bill");
+ gpr.setPersonId(e.getOut().getBody(String.class));
+ gpr.setSsn("Test");
+
+ MessageContentsList mclOut = new MessageContentsList();
+ mclOut.set(0, gpr);
+ e.getOut().setBody(mclOut, MessageContentsList.class);
+ }
+ }
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/RouteBuilderCxfTracer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java?rev=723325&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java
Thu Dec 4 05:54:19 2008
@@ -0,0 +1,47 @@
+/**
+ * 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.cxf;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.camel.non_wrapper.Person;
+import org.apache.camel.non_wrapper.PersonService;
+import org.apache.camel.non_wrapper.types.GetPerson;
+import org.apache.camel.non_wrapper.types.GetPersonResponse;
+import org.springframework.test.context.ContextConfiguration;
+import
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
[EMAIL PROTECTED](locations = {
"/org/apache/camel/component/cxf/context-camel-1145.xml" })
+public class TestCamel1145Route extends AbstractJUnit38SpringContextTests {
+
+ public void testCamel1145Route() throws Exception {
+ URL wsdlURL = new URL("http://localhost:9000/PersonService/?wsdl");
+ PersonService ss = new PersonService(wsdlURL, new
QName("http://camel.apache.org/non-wrapper", "PersonService"));
+ Person client = ss.getSoap();
+ GetPerson request = new GetPerson();
+ request.setPersonId("hello");
+ GetPersonResponse response = client.getPerson(request);
+
+ assertEquals("we should get the right answer from router", "Bill",
response.getName());
+ assertEquals("we should get the right answer from router", "Test",
response.getSsn());
+ assertEquals("we should get the right answer from router", "hello
world!", response.getPersonId());
+
+ }
+}
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/TestCamel1145Route.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml?rev=723325&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
Thu Dec 4 05:54:19 2008
@@ -0,0 +1,60 @@
+<?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://activemq.apache.org/camel/schema/spring"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+ http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <camel:camelContext id="camelJiraContext">
+ <camel:jmxAgent id="agent" disabled="true" />
+ </camel:camelContext>
+
+ <bean id="camelTracer"
class="org.apache.camel.processor.interceptor.Tracer">
+ <property name="enabled" value="true"/>
+ <property name="traceExceptions" value="true"/>
+ <property name="traceInterceptors" value="true"/>
+ <property name="logLevel" value="INFO"/>
+ </bean>
+
+ <bean id="traceFormatter"
class="org.apache.camel.processor.interceptor.TraceFormatter">
+ <property name="showBody" value="true"/>
+ <property name="showBodyType" value="true"/>
+ <property name="showProperties" value="true"/>
+ <property name="showHeaders" value="true"/>
+ </bean>
+
+ <bean id="producerTemplate"
+ factory-bean="camelJiraContext"
+ factory-method="createProducerTemplate">
+ </bean>
+
+ <bean class="org.apache.camel.component.cxf.RouteBuilderCxfTracer"/>
+</beans>
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/context-camel-1145.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml