Search in sources :

Example 6 with AddNumbers

use of org.apache.handlers.AddNumbers in project cxf by apache.

the class HandlerInvocationUsingAddNumbersTest method testAddHandlerByAnnotationClientSide.

@Test
public void testAddHandlerByAnnotationClientSide() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
    AddNumbersServiceWithAnnotation service = new AddNumbersServiceWithAnnotation(wsdl, serviceName);
    AddNumbers port = service.getPort(portName, AddNumbers.class);
    setAddress(port, addNumbersAddress);
    int result = port.addNumbers(10, 20);
    assertEquals(200, result);
    int result1 = port.addNumbers(5, 6);
    assertEquals(11, result1);
}
Also used : AddNumbers(org.apache.handlers.AddNumbers) URL(java.net.URL) Test(org.junit.Test)

Example 7 with AddNumbers

use of org.apache.handlers.AddNumbers in project cxf by apache.

the class HandlerInvocationUsingAddNumbersTest method testHandlerInjectingResource.

@Test
public void testHandlerInjectingResource() throws Exception {
    // When CXF is deployed in a servlet container, ServletContextResourceResolver is used to resolve
    // Servlet context resources.
    Bus bus = BusFactory.getDefaultBus();
    ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
    assertNotNull(resourceManager);
    resourceManager.addResourceResolver(new TestResourceResolver());
    URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
    AddNumbersServiceWithAnnotation service = new AddNumbersServiceWithAnnotation(wsdl, serviceName);
    AddNumbers port = service.getPort(portName, AddNumbers.class);
    setAddress(port, addNumbersAddress);
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = ((BindingProvider) port).getBinding().getHandlerChain();
    SmallNumberHandler h = (SmallNumberHandler) handlerChain.get(0);
    assertEquals("injectedValue", h.getInjectedString());
}
Also used : Bus(org.apache.cxf.Bus) AddNumbers(org.apache.handlers.AddNumbers) Handler(javax.xml.ws.handler.Handler) ResourceManager(org.apache.cxf.resource.ResourceManager) URL(java.net.URL) Test(org.junit.Test)

Example 8 with AddNumbers

use of org.apache.handlers.AddNumbers in project cxf by apache.

the class SpringConfiguredAutoRewriteSoapAddressTest method testWsdlAddress.

@Test
public void testWsdlAddress() throws Exception {
    AddNumbers addNumbers = getApplicationContext().getBean("cxfHandlerTestClientEndpoint", AddNumbers.class);
    int r = addNumbers.addNumbers(10, 15);
    assertEquals(1015, r);
    List<String> serviceUrls = findAllServiceUrlsFromWsdl("localhost", port);
    assertEquals(1, serviceUrls.size());
    assertEquals("http://localhost:" + port + "/SpringEndpoint", serviceUrls.get(0));
    String version = System.getProperty("java.version");
    if (version.startsWith("1.8")) {
        // Just skip the test as "127.0.0.1" doesn't work in JDK8
        return;
    }
    serviceUrls = findAllServiceUrlsFromWsdl("127.0.0.1", port);
    assertEquals(1, serviceUrls.size());
    assertEquals("http://127.0.0.1:" + port + "/SpringEndpoint", serviceUrls.get(0));
}
Also used : AddNumbers(org.apache.handlers.AddNumbers) Test(org.junit.Test)

Aggregations

AddNumbers (org.apache.handlers.AddNumbers)8 Test (org.junit.Test)7 URL (java.net.URL)4 Handler (javax.xml.ws.handler.Handler)3 AddNumbersService (org.apache.handlers.AddNumbersService)2 SmallNumberHandler (demo.handlers.common.SmallNumberHandler)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Bus (org.apache.cxf.Bus)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 AbstractCXFSpringTest (org.apache.cxf.test.AbstractCXFSpringTest)1 AddNumbersFault (org.apache.handlers.AddNumbersFault)1