Author: ningjiang
Date: Fri Mar 19 02:55:38 2010
New Revision: 925084
URL: http://svn.apache.org/viewvc?rev=925084&view=rev
Log:
CAMEL-2560 applied patch for camel-soap tests with thanks to Christian
Added:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java
(with props)
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java
(with props)
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
(with props)
Removed:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServerBean.java
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripContext.xml
Modified:
camel/trunk/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapClientTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfServerTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalSetterTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapRoundtripTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapServerTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest.java
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapCxfServerTest-context.xml
Modified:
camel/trunk/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
(original)
+++
camel/trunk/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
Fri Mar 19 02:55:38 2010
@@ -143,7 +143,7 @@ public class SoapJaxbDataFormat extends
}
final JAXBElement<?> content;
if (exception != null) {
- content = createFaultFromException(exception, soapAction);
+ content = createFaultFromException(exception);
} else {
content = createBodyContentFromObject(inputObject, soapAction);
}
@@ -192,11 +192,10 @@ public class SoapJaxbDataFormat extends
* the throwable if present
*
* @param exception
- * @param soapAction
* @return SOAP fault from given Throwable
*/
@SuppressWarnings("unchecked")
- private JAXBElement<Fault> createFaultFromException(final Throwable
exception, String soapAction) {
+ private JAXBElement<Fault> createFaultFromException(final Throwable
exception) {
WebFault webFault = exception.getClass().getAnnotation(WebFault.class);
if (webFault == null || webFault.targetNamespace() == null) {
throw new RuntimeException("The exception " +
exception.getClass().getName()
Added:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java?rev=925084&view=auto
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java
(added)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java
Fri Mar 19 02:55:38 2010
@@ -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.dataformat.soap;
+
+import com.example.customerservice.Customer;
+import com.example.customerservice.CustomerService;
+import com.example.customerservice.GetCustomersByName;
+import com.example.customerservice.GetCustomersByNameResponse;
+import com.example.customerservice.NoSuchCustomer;
+import com.example.customerservice.NoSuchCustomerException;
+
+/**
+ * Simple implementation of CustomerService that supports
+ * returning a customer or a NoSuchCustomerException depending on input
+ */
+public class CustomerServiceImpl implements CustomerService {
+
+ /**
+ * If the request.name is "none" a NoSuchCustomerException is thrown in
any other case
+ * a dummy customer is returned that has the same name as the request
+ */
+ public GetCustomersByNameResponse getCustomersByName(GetCustomersByName
request)
+ throws NoSuchCustomerException {
+ if ("none".equals(request.getName())) {
+ NoSuchCustomer noSuchCustomer = new NoSuchCustomer();
+ noSuchCustomer.setCustomerId(request.getName());
+ throw new NoSuchCustomerException("Customer not found",
noSuchCustomer);
+ }
+ GetCustomersByNameResponse response = new GetCustomersByNameResponse();
+ Customer customer = new Customer();
+ customer.setName(request.getName());
+ customer.setRevenue(100000);
+ response.getReturn().add(customer);
+ return response;
+ }
+
+}
Propchange:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/CustomerServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java?rev=925084&view=auto
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java
(added)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java
Fri Mar 19 02:55:38 2010
@@ -0,0 +1,34 @@
+/**
+ * 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.soap;
+
+import java.io.InputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+final class FileReplyProcessor implements Processor {
+ private final InputStream in;
+
+ FileReplyProcessor(InputStream in) {
+ this.in = in;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody(in);
+ }
+}
\ No newline at end of file
Propchange:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/FileReplyProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapClientTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapClientTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapClientTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapClientTest.java
Fri Mar 19 02:55:38 2010
@@ -25,44 +25,27 @@ import com.example.customerservice.Custo
import com.example.customerservice.GetCustomersByName;
import com.example.customerservice.GetCustomersByNameResponse;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.bean.ProxyHelper;
import org.apache.camel.dataformat.soap.name.ElementNameStrategy;
import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
-import org.apache.camel.test.CamelTestSupport;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+/**
+ * Test that uses a dynamic proxy for CustomerService to send a request as
SOAP and
+ * work with a static return SOAP message.
+ */
public class SoapClientTest extends CamelTestSupport {
- private final class FileReplyProcessor implements Processor {
- private final InputStream in;
-
- private FileReplyProcessor(InputStream in) {
- this.in = in;
- }
-
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody(in);
- }
- }
-
- protected CustomerService proxy;
@Produce(uri = "direct:start")
- protected ProducerTemplate producer;
+ CustomerService customerService;
- @SuppressWarnings("unchecked")
+ @Test
public void testRoundTrip() throws Exception {
- context.setTracing(true);
- Endpoint startEndpoint = context.getEndpoint("direct:start");
- ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
- proxy = ProxyHelper.createProxy(startEndpoint, classLoader,
CustomerService.class);
-
- GetCustomersByNameResponse response = proxy
+ GetCustomersByNameResponse response = customerService
.getCustomersByName(new GetCustomersByName());
+
Assert.assertEquals(1, response.getReturn().size());
Customer firstCustomer = response.getReturn().get(0);
Assert.assertEquals(100000.0, firstCustomer.getRevenue());
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java
Fri Mar 19 02:55:38 2010
@@ -36,6 +36,10 @@ import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Checks for interoperability between a CXF client that is attached using
+ * the Camel transport for CXF and the SOAP data format
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SoapCxfClientTest extends RouteBuilder {
@@ -71,7 +75,7 @@ public class SoapCxfClientTest extends R
String jaxbPackage = GetCustomersByName.class.getPackage().getName();
ElementNameStrategy elNameStrat = new TypeNameStrategy();
SoapJaxbDataFormat soapDataFormat = new
SoapJaxbDataFormat(jaxbPackage, elNameStrat);
- CustomerServerBean serverBean = new CustomerServerBean();
+ CustomerServiceImpl serverBean = new CustomerServiceImpl();
from("direct:cxfclient").onException(Exception.class) //
.handled(true) //
.marshal(soapDataFormat) //
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfServerTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfServerTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfServerTest.java
Fri Mar 19 02:55:38 2010
@@ -25,32 +25,25 @@ import com.example.customerservice.GetCu
import com.example.customerservice.NoSuchCustomer;
import com.example.customerservice.NoSuchCustomerException;
-import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.bean.ProxyHelper;
-import org.apache.camel.component.direct.DirectEndpoint;
import org.apache.camel.dataformat.soap.name.ElementNameStrategy;
import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+/**
+ * Checks for interoperability between a CXF server that is attached using
+ * the Camel transport for CXF and a dynamic proxy using the SOAP data format
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SoapCxfServerTest extends RouteBuilder {
- protected CustomerService customerServiceProxy;
-
- @EndpointInject(uri = "direct:camelClient")
- protected DirectEndpoint clientEndpoint;
-
- @SuppressWarnings("unchecked")
- @Before
- public void init() throws Exception {
- customerServiceProxy = ProxyHelper.createProxy(clientEndpoint,
CustomerService.class);
- }
+ @Produce(uri = "direct:camelClient")
+ CustomerService customerServiceProxy;
@Test
public void testSuccess() throws NoSuchCustomerException {
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalSetterTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalSetterTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalSetterTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalSetterTest.java
Fri Mar 19 02:55:38 2010
@@ -19,8 +19,8 @@ package org.apache.camel.dataformat.soap
import com.example.customerservice.GetCustomersByName;
/**
- * Works like SoapMarshalTest but the Dataformat is initialized by using the
setters
- * instead of the contructor
+ * Works like SoapMarshalTest but the data format is initialized by using the
setters
+ * instead of the constructor
*/
public class SoapMarshalSetterTest extends SoapMarshalTest {
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapMarshalTest.java
Fri Mar 19 02:55:38 2010
@@ -31,8 +31,12 @@ import org.apache.camel.builder.RouteBui
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.dataformat.soap.name.ElementNameStrategy;
import org.apache.camel.dataformat.soap.name.TypeNameStrategy;
-import org.apache.camel.test.CamelTestSupport;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+/**
+ *
+ */
public class SoapMarshalTest extends CamelTestSupport {
@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;
@@ -47,6 +51,7 @@ public class SoapMarshalTest extends Cam
* @throws IOException
* @throws InterruptedException
*/
+ @Test
public void testMarshalNormalObject() throws IOException,
InterruptedException {
InputStream in =
this.getClass().getResourceAsStream("SoapMarshalTestExpectedResult.xml");
resultEndpoint.expectedMessageCount(1);
@@ -65,6 +70,7 @@ public class SoapMarshalTest extends Cam
* @throws IOException
* @throws InterruptedException
*/
+ @Test
public void testMarshalException() throws IOException,
InterruptedException {
InputStream in =
this.getClass().getResourceAsStream("SoapMarshalTestExpectedFault.xml");
resultEndpoint.expectedMessageCount(1);
@@ -76,6 +82,9 @@ public class SoapMarshalTest extends Cam
resultEndpoint.assertIsSatisfied();
}
+ /**
+ * Create data format by using the constructor
+ */
protected SoapJaxbDataFormat createDataFormat() {
String jaxbPackage = GetCustomersByName.class.getPackage().getName();
ElementNameStrategy elStrat = new TypeNameStrategy();
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapRoundtripTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapRoundtripTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapRoundtripTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapRoundtripTest.java
Fri Mar 19 02:55:38 2010
@@ -30,7 +30,8 @@ import org.apache.camel.builder.RouteBui
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.dataformat.soap.name.ElementNameStrategy;
import org.apache.camel.dataformat.soap.name.TypeNameStrategy;
-import org.apache.camel.test.CamelTestSupport;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
public class SoapRoundtripTest extends CamelTestSupport {
@EndpointInject(uri = "mock:result")
@@ -39,6 +40,7 @@ public class SoapRoundtripTest extends C
@Produce(uri = "direct:start")
protected ProducerTemplate producer;
+ @Test
public void testRoundTrip() throws IOException, InterruptedException {
resultEndpoint.expectedMessageCount(1);
GetCustomersByName request = new GetCustomersByName();
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapServerTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapServerTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapServerTest.java
Fri Mar 19 02:55:38 2010
@@ -28,17 +28,24 @@ import org.apache.camel.ProducerTemplate
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.dataformat.soap.name.ElementNameStrategy;
import org.apache.camel.dataformat.soap.name.TypeNameStrategy;
-import org.apache.camel.test.CamelTestSupport;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+/*
+ * Checks the soap data format by using fixed request and expected response
+ * messages that are run against an implementation of the CustomerService
+ */
public class SoapServerTest extends CamelTestSupport {
@Produce(uri = "direct:start")
protected ProducerTemplate producer;
+ @Test
public void testSuccess() throws IOException, InterruptedException {
sendAndCheckReply("request.xml", "response.xml");
}
+ @Test
public void testFault() throws IOException, InterruptedException {
sendAndCheckReply("requestFault.xml", "responseFault.xml");
}
@@ -61,7 +68,7 @@ public class SoapServerTest extends Came
public void configure() throws Exception {
ElementNameStrategy elNameStrat = new TypeNameStrategy();
SoapJaxbDataFormat soapDataFormat = new
SoapJaxbDataFormat(jaxbPackage, elNameStrat);
- CustomerServerBean serverBean = new CustomerServerBean();
+ CustomerServiceImpl serverBean = new CustomerServiceImpl();
from("direct:start").onException(Exception.class) //
.handled(true) //
.marshal(soapDataFormat) //
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest.java
Fri Mar 19 02:55:38 2010
@@ -16,30 +16,46 @@
*/
package org.apache.camel.dataformat.soap;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Service;
-import org.apache.camel.spring.SpringCamelContext;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import java.io.IOException;
-public class SoapSpringRoundtripTest extends SoapRoundtripTest {
+import junit.framework.Assert;
+
+import com.example.customerservice.GetCustomersByName;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Works like SoapRoundTripTest but uses a spring configuration instead of the
java dsl
+ */
+...@runwith(SpringJUnit4ClassRunner.class)
+...@contextconfiguration
+public class SoapSpringRoundtripTest {
- protected CamelContext createCamelContext() throws Exception {
- setUseRouteBuilder(false);
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint resultEndpoint;
- final AbstractXmlApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/dataformat/soap/SoapSpringRoundtripContext.xml");
- setCamelContextService(new Service() {
- public void start() throws Exception {
- applicationContext.start();
-
- }
-
- public void stop() throws Exception {
- applicationContext.stop();
- }
- });
+ @Produce(uri = "direct:start")
+ protected ProducerTemplate producer;
- return SpringCamelContext.springCamelContext(applicationContext);
+ @Test
+ public void testRoundTrip() throws IOException, InterruptedException {
+ resultEndpoint.expectedMessageCount(1);
+ GetCustomersByName request = new GetCustomersByName();
+ request.setName("Müller");
+ producer.sendBody(request);
+ resultEndpoint.assertIsSatisfied();
+ Exchange exchange = resultEndpoint.getExchanges().get(0);
+ GetCustomersByName received = exchange.getIn().getBody(
+ GetCustomersByName.class);
+ Assert.assertNotNull(received);
+ Assert.assertEquals("Müller", received.getName());
}
-
}
Modified:
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
(original)
+++
camel/trunk/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
Fri Mar 19 02:55:38 2010
@@ -31,6 +31,10 @@ import org.apache.camel.builder.RouteBui
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.CamelTestSupport;
+/**
+ * Checks that a static soap request is unmarshalled to the correct java
+ * objects
+ */
public class SoapUnMarshalTest extends CamelTestSupport {
private static final String SERVICE_PACKAGE = GetCustomersByName.class
.getPackage().getName();
Modified:
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapCxfServerTest-context.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapCxfServerTest-context.xml?rev=925084&r1=925083&r2=925084&view=diff
==============================================================================
---
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapCxfServerTest-context.xml
(original)
+++
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapCxfServerTest-context.xml
Fri Mar 19 02:55:38 2010
@@ -31,7 +31,7 @@
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-camel.xml" />
- <bean id="serviceImpl"
class="org.apache.camel.dataformat.soap.CustomerServerBean"/>
+ <bean id="serviceImpl"
class="org.apache.camel.dataformat.soap.CustomerServiceImpl"/>
<jaxws:endpoint id="customerServiceEndpoint"
serviceName="customer:CustomerServiceService"
Added:
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml?rev=925084&view=auto
==============================================================================
---
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
(added)
+++
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
Fri Mar 19 02:55:38 2010
@@ -0,0 +1,43 @@
+<?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-2.5.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 soap jaxb data formats -->
+ <dataFormats>
+ <soapjaxb id="soap" contextPath="com.example.customerservice"
elementNameStrategyRef="myNameStrategy"/>
+ </dataFormats>
+
+ <route>
+ <from uri="direct:start"/>
+ <marshal ref="soap"/>
+ <unmarshal ref="soap"/>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+ <!-- END SNIPPET: e1 -->
+
+</beans>
Propchange:
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/SoapSpringRoundtripTest-context.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml