You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/01/18 10:40:53 UTC
svn commit: r1060271 - in /camel/trunk/components/camel-cxf/src/test:
java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java
resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml
Author: davsclaus
Date: Tue Jan 18 09:40:52 2011
New Revision: 1060271
URL: http://svn.apache.org/viewvc?rev=1060271&view=rev
Log:
Added unit test based on user forum issue
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml
- copied, changed from r1060195, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java?rev=1060271&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java Tue Jan 18 09:40:52 2011
@@ -0,0 +1,92 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.cxf.HelloService;
+import org.apache.camel.component.cxf.HelloServiceImpl;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class FileToCxfMessageDataFormatTest extends CamelSpringTestSupport {
+
+ private Server server;
+
+ @Override
+ public void setUp() throws Exception {
+ deleteDirectory("target/filetocxf");
+
+ // set CXF
+ ServerFactoryBean factory = new ServerFactoryBean();
+
+ factory.setAddress("http://localhost:9001/router");
+ factory.setServiceClass(HelloService.class);
+ factory.setServiceBean(new HelloServiceImpl());
+
+ server = factory.create();
+ server.start();
+
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ server.stop();
+ server.destroy();
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml");
+ }
+
+ @Test
+ public void testFileToCxfMessageDataFormat() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
+ template.sendBodyAndHeader("file:target/filetocxf", createBody(), Exchange.FILE_NAME, "payload.xml");
+
+ assertMockEndpointsSatisfied();
+
+ String out = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
+ assertNotNull(out);
+ log.info("Reply payload as a String:\n" + out);
+ assertTrue("Should invoke the echo operation", out.contains("echo Camel"));
+ }
+
+ private String createBody() throws Exception {
+ return "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cxf=\"http://cxf.component.camel.apache.org/\">\n"
+ + " <soapenv:Header/>\n"
+ + " <soapenv:Body>\n"
+ + " <cxf:echo>\n"
+ + " <cxf:arg0>Camel</cxf:arg0>\n"
+ + " </cxf:echo>\n"
+ + " </soapenv:Body>\n"
+ + "</soapenv:Envelope>";
+ }
+}
Copied: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml (from r1060195, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml?p2=camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml&p1=camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml&r1=1060195&r2=1060271&rev=1060271&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml (original)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml Tue Jan 18 09:40:52 2011
@@ -24,18 +24,23 @@
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
">
- <bean id="fromEndpointJaxwsHandler" class="org.apache.camel.wsdl_first.JaxwsTestHandler"/>
+ <cxf:cxfEndpoint id="routerEndpoint"
+ address="http://localhost:9001/router"
+ serviceClass="org.apache.camel.component.cxf.HelloService">
+ <!-- use MESSAGE data format -->
+ <cxf:properties>
+ <entry key="dataFormat" value="MESSAGE"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
- <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9000/router"
- serviceClass="org.apache.camel.component.cxf.HelloService">
- <cxf:schemaLocations>
- <cxf:schemaLocation>classpath:wsdl/Message.xsd</cxf:schemaLocation>
- </cxf:schemaLocations>
- <cxf:handlers><ref bean="fromEndpointJaxwsHandler"/></cxf:handlers>
- </cxf:cxfEndpoint>
-
-
- <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9002/helloworld"
- serviceClass="org.apache.camel.component.cxf.HelloService"/>
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="file:target/filetocxf"/>
+ <to uri="log:request"/>
+ <inOut uri="routerEndpoint"/>
+ <to uri="log:reply"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
</beans>