Search in sources :

Example 16 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean 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);
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Test(org.junit.Test)

Example 17 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project camel by apache.

the class CxfConsumerTest method testInvokingServiceFromCXFClient.

// END SNIPPET: example
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.newInstance().createBus());
    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");
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Test(org.junit.Test)

Aggregations

ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)17 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)11 Test (org.junit.Test)6 IOException (java.io.IOException)1 IncidentService (org.apache.camel.example.cxf.incident.IncidentService)1 SoapFault (org.apache.cxf.binding.soap.SoapFault)1 Client (org.apache.cxf.endpoint.Client)1 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1