Author: ningjiang
Date: Fri Aug 7 11:55:33 2009
New Revision: 801960
URL: http://svn.apache.org/viewvc?rev=801960&view=rev
Log:
CAMEL-1889 create unit tests for camel-example-cxf
Added:
camel/trunk/examples/camel-example-cxf/src/test/
camel/trunk/examples/camel-example-cxf/src/test/java/
camel/trunk/examples/camel-example-cxf/src/test/java/org/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
(with props)
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java
(with props)
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
(with props)
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
(with props)
camel/trunk/examples/camel-example-cxf/src/test/resources/
camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
(with props)
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
(with props)
Modified:
camel/trunk/examples/camel-example-cxf/pom.xml
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/CamelCxfExample.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/Client.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/JAXWSClient.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/CamelCxfExample.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/Client.java
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/jms/JmsBroker.java
camel/trunk/examples/camel-example-cxf/src/main/resources/wsdl/hello_world.wsdl
Modified: camel/trunk/examples/camel-example-cxf/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/pom.xml?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf/pom.xml (original)
+++ camel/trunk/examples/camel-example-cxf/pom.xml Fri Aug 7 11:55:33 2009
@@ -82,6 +82,18 @@
<artifactId>xercesImpl</artifactId>
<version>2.8.1</version>
</dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ </dependency>
</dependencies>
@@ -136,6 +148,24 @@
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ <systemProperties>
+ <property>
+ <name>java.util.logging.config.file</name>
+
<value>${basedir}/target/test-classes/logging.properties</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
Fri Aug 7 11:55:33 2009
@@ -16,16 +16,13 @@
*/
package org.apache.camel.example.camel.transport;
-import java.io.File;
import java.net.MalformedURLException;
-import java.net.URL;
+
import javax.xml.namespace.QName;
-import javax.xml.ws.ProtocolException;
import javax.xml.ws.Service;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.PingMeFault;
-import org.apache.hello_world_soap_http.SOAPService;
import org.apache.hello_world_soap_http.types.FaultDetail;
public final class Client {
@@ -35,6 +32,7 @@
private static final QName PORT_NAME
= new QName("http://apache.org/hello_world_soap_http", "CamelPort");
private Service service;
+ private Greeter port;
public Client(String address) throws MalformedURLException {
@@ -42,15 +40,18 @@
service = Service.create(SERVICE_NAME);
service.addPort(PORT_NAME,
javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,
address);
+
+ System.out.println("Acquiring router port ...");
+ port = service.getPort(PORT_NAME, Greeter.class);
}
-
+ public Greeter getProxy() {
+ return port;
+ }
public void invoke() throws Exception {
- System.out.println("Acquiring router port ...");
- Greeter port = service.getPort(PORT_NAME, Greeter.class);
String resp;
System.out.println("Invoking sayHi...");
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/CamelCxfExample.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/CamelCxfExample.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/CamelCxfExample.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/CamelCxfExample.java
Fri Aug 7 11:55:33 2009
@@ -46,6 +46,17 @@
private CamelCxfExample() {
}
+
+ static class MyRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ // Here we just pass the exception back , don't need to use
errorHandler
+ errorHandler(noErrorHandler());
+ from(ROUTER_ENDPOINT_URI).to(SERVICE_ENDPOINT_URI);
+ }
+
+ }
public static void main(String args[]) throws Exception {
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/Client.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/Client.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/Client.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/Client.java
Fri Aug 7 11:55:33 2009
@@ -32,6 +32,7 @@
= new QName("http://apache.org/hello_world_soap_http", "SOAPService");
private String wsdlLocation;
private SOAPService soapService;
+
public Client(String wsdl) throws MalformedURLException {
URL wsdlURL = null;
@@ -47,13 +48,18 @@
}
soapService = new SOAPService(wsdlURL, SERVICE_NAME);
}
+
+ public Greeter getProxy() {
+ Greeter port = soapService.getSoapOverHttpRouter();
+ return port;
+ }
public void invoke() throws Exception {
System.out.println("Acquiring router port ...");
- Greeter port = soapService.getSoapOverHttpRouter();
+ Greeter port = getProxy();
String resp;
System.out.println("Invoking sayHi...");
@@ -66,15 +72,6 @@
System.out.println("Server responded with: " + resp);
System.out.println();
- System.out.println("Invoking greetMe with invalid length string,
expecting exception...");
- try {
- resp = port.greetMe("Invoking greetMe with invalid length string,
expecting exception...");
- } catch (ProtocolException e) {
- System.out.println("Expected exception has occurred: " +
e.getClass().getName());
- }
-
- System.out.println();
-
System.out.println("Invoking greetMeOneWay...");
port.greetMeOneWay(System.getProperty("user.name"));
System.out.println("No response from server as method is OneWay");
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java
Fri Aug 7 11:55:33 2009
@@ -16,11 +16,13 @@
*/
package org.apache.camel.example.cxf.jaxrs;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.bean.BeanInvocation;
import org.apache.camel.component.cxf.CxfConstants;
@@ -29,9 +31,10 @@
import org.apache.camel.example.cxf.jaxrs.resources.BookStoreImpl;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.spring.Main;
+import org.apache.camel.util.ObjectHelper;
public class CamelRouterBuilder extends RouteBuilder {
- private static final String SOAP_ENDPOINT_URI =
"cxf://http://localhost:9000/soap"
+ private static final String SOAP_ENDPOINT_URI =
"cxf://http://localhost:9006/soap"
+
"?serviceClass=org.apache.camel.example.cxf.jaxrs.resources.BookStore";
private static final String REST_ENDPOINT_URI =
"cxfrs://http://localhost:9002/rest"
+
"?resourceClasses=org.apache.camel.example.cxf.jaxrs.resources.BookStoreImpl";
@@ -87,31 +90,35 @@
// populate the message queue with some messages
from(SOAP_ENDPOINT_URI)
- .process(new MappingProcessor(BookStoreImpl.class))
- .bean(new BookStoreImpl(false));
+ .process(new MappingProcessor(new BookStoreImpl(false)));
+
from(REST_ENDPOINT_URI)
- .process(new MappingProcessor(BookStoreImpl.class))
- .bean(new BookStoreImpl(true));
+ .process(new MappingProcessor(new BookStoreImpl(true)));
+
}
- // Mapping the request to bean's invocation
+ // Mapping the request to object's invocation
private class MappingProcessor implements Processor {
private Class beanClass;
+ private Object instance;
- public MappingProcessor(Class clazz) {
- beanClass = clazz;
+ public MappingProcessor(Object obj) {
+ beanClass = obj.getClass();
+ instance = obj;
}
public void process(Exchange exchange) throws Exception {
String operationName =
exchange.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
Method method = findMethod(operationName,
exchange.getIn().getBody(Object[].class));
- BeanInvocation invocation = new BeanInvocation();
- invocation.setMethod(method);
- invocation.setArgs(exchange.getIn().getBody(Object[].class));
- exchange.getOut().setBody(invocation);
+ try {
+ Object response = method.invoke(instance,
exchange.getIn().getBody(Object[].class));
+ exchange.getOut().setBody(response);
+ } catch (InvocationTargetException e) {
+ throw (Exception)e.getCause();
+ }
}
private Method findMethod(String operationName, Object[] parameters)
throws SecurityException, NoSuchMethodException {
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/JAXWSClient.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/JAXWSClient.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/JAXWSClient.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/JAXWSClient.java
Fri Aug 7 11:55:33 2009
@@ -27,7 +27,7 @@
public JAXWSClient() {
JaxWsProxyFactoryBean cfb = new JaxWsProxyFactoryBean();
cfb.setServiceClass(BookStore.class);
- cfb.setAddress("http://localhost:9000/soap");
+ cfb.setAddress("http://localhost:9006/soap");
bookStore = (BookStore) cfb.create();
}
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/CamelCxfExample.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/CamelCxfExample.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/CamelCxfExample.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/CamelCxfExample.java
Fri Aug 7 11:55:33 2009
@@ -36,7 +36,9 @@
// set the client's service access point
Client client = new
Client("http://localhost:9000/GreeterContext/SOAPMessageService");
// invoke the services
- client.invoke();
+ String response = client.invoke();
+
+ System.out.println(response);
} catch (Exception ex) {
ex.printStackTrace();
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/Client.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/Client.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/Client.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/provider/Client.java
Fri Aug 7 11:55:33 2009
@@ -41,7 +41,7 @@
this.endpointAddress = endpointAddress;
}
- public void invoke() throws Exception {
+ public String invoke() throws Exception {
// Service Qname as defined in the WSDL.
QName serviceName = new
QName("http://apache.org/hello_world_soap_http", "SOAPService");
@@ -96,8 +96,8 @@
SOAPElement bodyElement =
(SOAPElement)body.getChildElements(responseName).next();
String responseMessageText = bodyElement.getTextContent();
-
- System.out.println(responseMessageText);
+
+ return responseMessageText;
}
Modified:
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/jms/JmsBroker.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/jms/JmsBroker.java?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/jms/JmsBroker.java
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/jms/JmsBroker.java
Fri Aug 7 11:55:33 2009
@@ -24,7 +24,7 @@
public final class JmsBroker {
JMSEmbeddedBroker jmsBrokerThread;
- String jmsBrokerUrl = "tcp://localhost:61616";
+ String jmsBrokerUrl = "vm://localhost";
String activeMQStorageDir;
public JmsBroker() {
}
Modified:
camel/trunk/examples/camel-example-cxf/src/main/resources/wsdl/hello_world.wsdl
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/main/resources/wsdl/hello_world.wsdl?rev=801960&r1=801959&r2=801960&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/main/resources/wsdl/hello_world.wsdl
(original)
+++
camel/trunk/examples/camel-example-cxf/src/main/resources/wsdl/hello_world.wsdl
Fri Aug 7 11:55:33 2009
@@ -240,7 +240,7 @@
jndiConnectionFactoryName="ConnectionFactory"
jndiDestinationName="dynamicQueues/test.soap.jmstransport.queue">
<jms:JMSNamingProperty name="java.naming.factory.initial"
value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
- <jms:JMSNamingProperty name="java.naming.provider.url"
value="tcp://localhost:61616"/>
+ <jms:JMSNamingProperty name="java.naming.provider.url"
value="vm://localhost"/>
</jms:address>
</wsdl:port>
</wsdl:service>
Added:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java?rev=801960&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
(added)
+++
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
Fri Aug 7 11:55:33 2009
@@ -0,0 +1,79 @@
+/**
+ * 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.example.camel.transport;
+
+import java.net.MalformedURLException;
+
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.PingMeFault;
+import org.apache.hello_world_soap_http.types.FaultDetail;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CamelTransportClientServerTest extends Assert {
+ private static Server server = new Server();
+
+ @BeforeClass
+ public static void startUpServer() throws Exception {
+ server.prepare();
+ server.start();
+ }
+
+ @AfterClass
+ public static void shutDownServer() {
+ server.stop();
+ }
+
+ @Test
+ public void testClientInvocation() throws MalformedURLException {
+ Client client = new
Client("http://localhost:9091/GreeterContext/GreeterPort");
+ Greeter port = client.getProxy();
+
+ assertNotNull("The proxy should not be null", port);
+ String resp = port.sayHi();
+ assertEquals("Get a wrong response ", "Bonjour from EndpointA", resp);
+
+ resp = port.sayHi();
+ assertEquals("Get a wrong response ", "Bonjour from EndpointB", resp);
+
+
+ resp = port.greetMe("Mike");
+ assertEquals("Get a wrong response ", "Hello Mike from EndpointA",
resp);
+
+ resp = port.greetMe("James");
+ assertEquals("Get a wrong response ", "Hello James from EndpointB",
resp);
+
+ port.greetMeOneWay(System.getProperty("user.name"));
+
+ try {
+ System.out.println("Invoking pingMe, expecting exception...");
+ port.pingMe("hello");
+ fail("expects the exception here");
+ } catch (PingMeFault ex) {
+ assertEquals("Get a wrong exception message", "PingMeFault raised
by server EndpointB", ex.getMessage());
+ FaultDetail detail = ex.getFaultInfo();
+ assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
+ assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
+ }
+
+ }
+
+
+
+}
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java?rev=801960&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java
(added)
+++
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java
Fri Aug 7 11:55:33 2009
@@ -0,0 +1,82 @@
+/**
+ * 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.example.cxf;
+
+import java.net.MalformedURLException;
+
+import javax.xml.ws.ProtocolException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.example.cxf.CamelCxfExample.MyRouteBuilder;
+import org.apache.camel.example.jms.JmsBroker;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.PingMeFault;
+import org.apache.hello_world_soap_http.types.FaultDetail;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CxfHttpJmsClientServerTest extends CamelTestSupport {
+ static JmsBroker broker = new JmsBroker();
+ static Server server = new Server();
+ private static final String ROUTER_ADDRESS =
"http://localhost:9001/SoapContext/SoapPort";
+
+ @BeforeClass
+ public static void startUpJmsBroker() throws Exception {
+ broker.start();
+ server.start();
+ }
+
+ @AfterClass
+ public static void shutDownJmsBroker() throws Exception {
+ server.stop();
+ broker.stop();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new MyRouteBuilder();
+ }
+
+ @Test
+ public void testClientInvocation() throws MalformedURLException {
+ Client client = new Client(ROUTER_ADDRESS + "?wsdl");
+ Greeter proxy = client.getProxy();
+
+ String resp;
+ resp = proxy.sayHi();
+ assertEquals("Get a wrong response", "Bonjour", resp);
+
+ resp = proxy.greetMe("Willem");
+ assertEquals("Get a wrong response", "Hello Willem", resp);
+
+ proxy.greetMeOneWay(System.getProperty("user.name"));
+
+ try {
+ proxy.pingMe("hello");
+ fail("expect exception here");
+ } catch (PingMeFault ex) {
+ FaultDetail detail = ex.getFaultInfo();
+ assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
+ assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
+ }
+ }
+
+
+
+}
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/CxfHttpJmsClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java?rev=801960&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
(added)
+++
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
Fri Aug 7 11:55:33 2009
@@ -0,0 +1,69 @@
+/**
+ * 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.example.cxf.jaxrs;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.example.cxf.jaxrs.resources.Book;
+import org.apache.camel.example.cxf.jaxrs.resources.BookNotFoundFault;
+import org.apache.camel.example.cxf.jaxrs.resources.BookStore;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class JAXRSClientServerTest extends CamelTestSupport {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new CamelRouterBuilder();
+ }
+
+ @Test
+ public void testJAXWSClient() throws BookNotFoundFault {
+ JAXWSClient jaxwsClient = new JAXWSClient();
+ BookStore bookStore = jaxwsClient.getBookStore();
+
+ bookStore.addBook(new Book("Camel User Guide", 234L));
+ Book book = bookStore.getBook(123L);
+ assertNotNull("We should find the book here", book);
+
+ try {
+ book = bookStore.getBook(124L);
+ fail("We should not have this book");
+ } catch (Exception exception) {
+ assertTrue("The exception should be BookNotFoundFault", exception
instanceof BookNotFoundFault);
+ }
+ }
+
+ @Test
+ public void testJAXRSClient() throws BookNotFoundFault {
+
+ // JAXRSClient invocation
+ JAXRSClient jaxrsClient = new JAXRSClient();
+ BookStore bookStore = jaxrsClient.getBookStore();
+
+ bookStore.addBook(new Book("Camel User Guide", 124L));
+ Book book = bookStore.getBook(124L);
+ assertNotNull("We should find the book here", book);
+
+ try {
+ book = bookStore.getBook(126L);
+ fail("We should not have this book");
+ } catch (Exception exception) {
+ assertTrue("The exception should be BookNotFoundFault", exception
instanceof BookNotFoundFault);
+ }
+ }
+
+}
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java?rev=801960&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
(added)
+++
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
Fri Aug 7 11:55:33 2009
@@ -0,0 +1,45 @@
+/**
+ * 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.example.provider;
+
+import org.apache.camel.example.cxf.provider.Client;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ProviderClientServerTest extends CamelSpringTestSupport {
+
+ @Test
+ public void testClientInvocation() throws Exception {
+ // set the client's service access point
+ Client client = new
Client("http://localhost:9000/GreeterContext/SOAPMessageService");
+ // invoke the services
+ String response = client.invoke();
+
+ assertEquals("Get a wrong response", "Greetings from Apache Camel!!!!
Request was Hello Camel!!", response);
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+
+ return new ClassPathXmlApplicationContext(new
String[]{"/org/apache/camel/example/cxf/provider/CamelCXFRouteConfig.xml"});
+ }
+
+
+
+}
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties?rev=801960&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
(added)
+++ camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
Fri Aug 7 11:55:33 2009
@@ -0,0 +1,38 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, file
+
+log4j.logger.org.apache.activemq.spring=WARN
+#log4j.logger.org.apache.camel.component=TRACE
+log4j.logger.org.apache.camel.impl.converter=WARN
+log4j.logger.org.apache.camel.component.cxf=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+log4j.appender.file.file=target/camel-cxf-test.log
+log4j.appender.file.append=true
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties?rev=801960&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
(added)
+++
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
Fri Aug 7 11:55:33 2009
@@ -0,0 +1,75 @@
+#
+#
+# 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.
+#
+#
+############################################################
+# Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+# Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler
+# classes. These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+#handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers. For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 5000000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+#com.xyz.foo.level = SEVERE
+org.apache.cxf.level = FINEST
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/examples/camel-example-cxf/src/test/resources/logging.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain