use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfSimpleRouterWithUnwrappedStyleTest method getCXFClient.
protected HelloService getCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(getRouterAddress());
clientBean.setServiceClass(HelloService.class);
clientBean.getServiceFactory().setWrapped(false);
HelloService client = (HelloService) proxyFactory.create();
return client;
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfCustomizedExceptionTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(routerAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(bus);
HelloService client = (HelloService) proxyFactory.create();
try {
client.echo("hello world");
fail("Expect to get an exception here");
} catch (Exception e) {
assertEquals("Expect to get right exception message", EXCEPTION_MESSAGE, e.getMessage());
assertTrue("Exception is not instance of SoapFault", e instanceof SoapFault);
assertEquals("Expect to get right detail message", DETAIL_TEXT, ((SoapFault) e).getDetail().getTextContent());
//In CXF 2.1.2 , the fault code is per spec , the below fault-code is for SOAP 1.1
assertEquals("Expect to get right fault-code", "{http://schemas.xmlsoap.org/soap/envelope/}Client", ((SoapFault) e).getFaultCode().toString());
}
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfConsumerMessageTest method testInvokingServiceFromClient.
@Test
public void testInvokingServiceFromClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
HelloService client = (HelloService) proxyFactory.create();
String result = client.echo(TEST_MESSAGE);
assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
Boolean bool = client.echoBoolean(Boolean.TRUE);
assertNotNull("The result should not be null", bool);
assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfConsumerPayloadXPathClientServerTest method execTest.
private void execTest(int size) throws Exception {
buildTestMessage(size);
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
HelloService client = (HelloService) proxyFactory.create();
String result = client.echo(testMessage);
assertEquals("We should get the echo string result from router", "echo Hello World!", result);
//check received requests
assertEquals("Lengths of testMessage and receiveMessage should be equal (conversion body to String),", testMessage.length(), receivedMessageStringApplyingXPath.length());
assertEquals("Lengths of receivedMessageByDom and receivedMessageCxfPayloadApplyingXPath should be equal", receivedMessageCxfPayloadApplyingXPath.length(), receivedMessageByDom.length());
assertEquals("Lengths of testMessage and receiveMessage should be equal (body is CxfPayload),", testMessage.length(), receivedMessageCxfPayloadApplyingXPath.length());
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfConsumerResponseTest method testInvokingServiceFromCXFClient.
// END SNIPPET: example
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
HelloService client = (HelloService) proxyFactory.create();
assertNotNull(client);
String result = client.echo(TEST_MESSAGE);
assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
Boolean bool = client.echoBoolean(Boolean.TRUE);
assertNotNull("The result should not be null", bool);
assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
int beforeCallingPing = pingCounter;
client.ping();
int afterCallingPing = pingCounter;
assertTrue("The ping operation doesn't be called", afterCallingPing - beforeCallingPing == 1);
}
Aggregations