Author: ningjiang
Date: Fri Nov 16 15:03:50 2012
New Revision: 1410385
URL: http://svn.apache.org/viewvc?rev=1410385&view=rev
Log:
CAMEL-5778 Added xmlrpc dataformat
Added:
camel/trunk/components/camel-xmlrpc/src/test/java/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.java
camel/trunk/components/camel-xmlrpc/src/test/resources/org/
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/xmlrpc/
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.xml
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
camel/trunk/components/camel-xmlrpc/pom.xml
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java?rev=1410385&r1=1410384&r2=1410385&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
Fri Nov 16 15:03:50 2012
@@ -49,6 +49,7 @@ import org.apache.camel.model.dataformat
import org.apache.camel.model.dataformat.XMLSecurityDataFormat;
import org.apache.camel.model.dataformat.XStreamDataFormat;
import org.apache.camel.model.dataformat.XmlJsonDataFormat;
+import org.apache.camel.model.dataformat.XmlRpcDataFormat;
import org.apache.camel.model.dataformat.ZipDataFormat;
import org.apache.camel.processor.MarshalProcessor;
import org.apache.camel.spi.DataFormat;
@@ -93,6 +94,7 @@ public class MarshalDefinition extends N
@XmlElement(required = false, name = "tidyMarkup", type =
TidyMarkupDataFormat.class),
@XmlElement(required = false, name = "xmlBeans", type =
XMLBeansDataFormat.class),
@XmlElement(required = false, name = "xmljson", type =
XmlJsonDataFormat.class),
+ @XmlElement(required = false, name = "xmlrpc", type =
XmlRpcDataFormat.class),
@XmlElement(required = false, name = "xstream", type =
XStreamDataFormat.class),
@XmlElement(required = false, name = "pgp", type = PGPDataFormat.class),
@XmlElement(required = false, name = "zip", type = ZipDataFormat.class)}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java?rev=1410385&r1=1410384&r2=1410385&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
Fri Nov 16 15:03:50 2012
@@ -49,6 +49,7 @@ import org.apache.camel.model.dataformat
import org.apache.camel.model.dataformat.XMLSecurityDataFormat;
import org.apache.camel.model.dataformat.XStreamDataFormat;
import org.apache.camel.model.dataformat.XmlJsonDataFormat;
+import org.apache.camel.model.dataformat.XmlRpcDataFormat;
import org.apache.camel.model.dataformat.ZipDataFormat;
import org.apache.camel.processor.UnmarshalProcessor;
import org.apache.camel.spi.DataFormat;
@@ -93,6 +94,7 @@ public class UnmarshalDefinition extends
@XmlElement(required = false, name = "tidyMarkup", type =
TidyMarkupDataFormat.class),
@XmlElement(required = false, name = "xmlBeans", type =
XMLBeansDataFormat.class),
@XmlElement(required = false, name = "xmljson", type =
XmlJsonDataFormat.class),
+ @XmlElement(required = false, name = "xmlrpc", type =
XmlRpcDataFormat.class),
@XmlElement(required = false, name = "xstream", type =
XStreamDataFormat.class),
@XmlElement(required = false, name = "pgp", type = PGPDataFormat.class),
@XmlElement(required = false, name = "zip", type = ZipDataFormat.class)}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java?rev=1410385&r1=1410384&r2=1410385&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
Fri Nov 16 15:03:50 2012
@@ -60,6 +60,7 @@ public class DataFormatsDefinition {
@XmlElement(required = false, name = "tidyMarkup", type =
TidyMarkupDataFormat.class),
@XmlElement(required = false, name = "xmlBeans", type =
XMLBeansDataFormat.class),
@XmlElement(required = false, name = "xmljson", type =
XmlJsonDataFormat.class),
+ @XmlElement(required = false, name = "xmlrpc", type =
XmlRpcDataFormat.class),
@XmlElement(required = false, name = "xstream", type =
XStreamDataFormat.class),
@XmlElement(required = false, name = "pgp", type =
PGPDataFormat.class),
@XmlElement(required = false, name = "zip", type =
ZipDataFormat.class)}
Modified: camel/trunk/components/camel-xmlrpc/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlrpc/pom.xml?rev=1410385&r1=1410384&r2=1410385&view=diff
==============================================================================
--- camel/trunk/components/camel-xmlrpc/pom.xml (original)
+++ camel/trunk/components/camel-xmlrpc/pom.xml Fri Nov 16 15:03:50 2012
@@ -66,6 +66,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
<scope>test</scope>
</dependency>
Added:
camel/trunk/components/camel-xmlrpc/src/test/java/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlrpc/src/test/java/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.java?rev=1410385&view=auto
==============================================================================
---
camel/trunk/components/camel-xmlrpc/src/test/java/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.java
(added)
+++
camel/trunk/components/camel-xmlrpc/src/test/java/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.java
Fri Nov 16 15:03:50 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.dataformat.xmlrpc;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.xmlrpc.XmlRpcRequestImpl;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringXmlRpcDataFormatTest extends CamelSpringTestSupport {
+
+ @Test
+ public void testRequestMessage() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:request");
+ mock.expectedMessageCount(1);
+ XmlRpcRequest result = template.requestBody("direct:request", new
XmlRpcRequestImpl("greet", new Object[]{"you", 2}), XmlRpcRequest.class);
+ assertNotNull(result);
+ assertEquals("Get a wrong request operation name", "greet",
result.getMethodName());
+ assertEquals("Get a wrong request parameter size", 2,
result.getParameterCount());
+ assertEquals("Get a wrong request parameter", 2,
result.getParameter(1));
+ assertMockEndpointsSatisfied();
+
+ }
+
+ @Test
+ public void testResponseMessage() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:response");
+ mock.expectedBodiesReceived("GreetMe from XmlRPC");
+ template.sendBody("direct:response", "GreetMe from XmlRPC");
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.xml");
+ }
+
+}
Added:
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.xml?rev=1410385&view=auto
==============================================================================
---
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.xml
(added)
+++
camel/trunk/components/camel-xmlrpc/src/test/resources/org/apache/camel/dataformat/xmlrpc/SpringXmlRpcDataFormatTest.xml
Fri Nov 16 15:03:50 2012
@@ -0,0 +1,53 @@
+<?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"
+ 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">
+
+ <!-- START SNIPPET: e1 -->
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <!-- we define the xml rpc data formats to be used -->
+ <dataFormats>
+ <xmlrpc id="xmlrpcRequest" request="true"/>
+ <xmlrpc id="xmlrpcResponse" request="false"/>
+ </dataFormats>
+
+ <route>
+ <from uri="direct:request"/>
+ <marshal ref="xmlrpcRequest"/>
+ <unmarshal>
+ <xmlrpc request="true"/>
+ </unmarshal>
+ <to uri="mock:request" />
+ </route>
+
+ <route>
+ <from uri="direct:response"/>
+ <marshal>
+ <xmlrpc request="false"/>
+ </marshal>
+ <unmarshal ref="xmlrpcResponse"/>
+ <to uri="mock:response" />
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: e1 -->
+
+</beans>