Search in sources :

Example 61 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfHttpJmsClientServerTest method testClientInvocation.

@Test
public void testClientInvocation() throws MalformedURLException {
    String address = ROUTER_ADDRESS.replace("{{routerPort}}", System.getProperty("routerPort"));
    Client client = new Client(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("exception expected but none thrown");
    } catch (PingMeFault ex) {
        FaultDetail detail = ex.getFaultInfo();
        assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
        assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
    }
}
Also used : PingMeFault(org.apache.hello_world_soap_http.PingMeFault) Greeter(org.apache.hello_world_soap_http.Greeter) FaultDetail(org.apache.hello_world_soap_http.types.FaultDetail) Test(org.junit.Test)

Example 62 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfConsumerSoap12Test method testInvokeGreeter.

@Test
public void testInvokeGreeter() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    Service service = Service.create(SERVICE_NAME);
    service.addPort(PORT_NAME, "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
    Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
    greeter.greetMeOneWay("test");
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Greeter(org.apache.hello_world_soap_http.Greeter) Service(javax.xml.ws.Service) Test(org.junit.Test)

Example 63 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfPayloadProviderRouterTest method testInvokeGreetMeOverProvider.

@Test
public void testInvokeGreetMeOverProvider() throws Exception {
    Service service = Service.create(serviceName);
    service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/", "http://localhost:" + CXFTestSupport.getPort2() + "/" + getClass().getSimpleName() + "/CamelContext/RouterPort");
    Greeter greeter = service.getPort(routerPortName, Greeter.class);
    org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(greeter);
    VerifyInboundInterceptor icp = new VerifyInboundInterceptor();
    client.getInInterceptors().add(icp);
    int ic = implementor.getInvocationCount();
    icp.setCalled(false);
    String reply = greeter.greetMe("test");
    assertEquals("Got the wrong reply ", "Hello test", reply);
    assertTrue("No Inbound message received", icp.isCalled());
    assertEquals("The target service not invoked", ++ic, implementor.getInvocationCount());
    icp.setCalled(false);
    greeter.greetMeOneWay("call greetMe OneWay !");
    assertFalse("An unnecessary inbound message", icp.isCalled());
    // wait a few seconds for the async oneway service to be invoked
    Thread.sleep(3000);
    assertEquals("The target service not invoked", ++ic, implementor.getInvocationCount());
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) Service(javax.xml.ws.Service) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 64 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfEndpointJMSConsumerTest method testInvocation.

@Test
public void testInvocation() {
    // Here we just the address with JMS URI
    String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue" + "?jndiInitialContextFactory" + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=" + "vm://localhost";
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(Greeter.class);
    factory.setAddress(address);
    Greeter greeter = factory.create(Greeter.class);
    String response = greeter.greetMe("Willem");
    assertEquals("Get a wrong response", "Hello Willem", response);
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 65 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project camel by apache.

the class CxfPayloadProviderRouterTest method testInvokeGreetMeOverProvider.

@Test
public void testInvokeGreetMeOverProvider() throws Exception {
    Service service = Service.create(serviceName);
    service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/", "http://localhost:" + getPort2() + "/" + getClass().getSimpleName() + "/CamelContext/RouterPort");
    Greeter greeter = service.getPort(routerPortName, Greeter.class);
    org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(greeter);
    VerifyInboundInterceptor icp = new VerifyInboundInterceptor();
    client.getInInterceptors().add(icp);
    int ic = implementor.getInvocationCount();
    icp.setCalled(false);
    String reply = greeter.greetMe("test");
    assertEquals("Got the wrong reply ", "Hello test", reply);
    assertTrue("No Inbound message received", icp.isCalled());
    assertEquals("The target service not invoked", ++ic, implementor.getInvocationCount());
    icp.setCalled(false);
    greeter.greetMeOneWay("call greetMe OneWay !");
    assertFalse("An unnecessary inbound message", icp.isCalled());
    // wait a few seconds for the async oneway service to be invoked
    Thread.sleep(3000);
    assertEquals("The target service not invoked", ++ic, implementor.getInvocationCount());
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) Service(javax.xml.ws.Service) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Aggregations

Greeter (org.apache.hello_world_soap_http.Greeter)104 Test (org.junit.Test)78 SOAPService (org.apache.hello_world_soap_http.SOAPService)55 URL (java.net.URL)47 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)24 BindingProvider (javax.xml.ws.BindingProvider)23 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)21 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)21 Service (javax.xml.ws.Service)19 Client (org.apache.cxf.endpoint.Client)17 Endpoint (javax.xml.ws.Endpoint)13 QName (javax.xml.namespace.QName)10 Bus (org.apache.cxf.Bus)10 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)10 ExecutorService (java.util.concurrent.ExecutorService)9 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 File (java.io.File)6 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)6 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6 InvocationHandler (java.lang.reflect.InvocationHandler)5