Search in sources :

Example 66 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.

the class HeaderClientServerTest method testReturnHeader.

@Test
public void testReturnHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
    assertNotNull(wsdl);
    SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
    assertNotNull(service);
    TestHeader proxy = service.getPort(portName, TestHeader.class);
    try {
        Holder<TestHeader5ResponseBody> out = new Holder<TestHeader5ResponseBody>();
        Holder<TestHeader5> outHeader = new Holder<TestHeader5>();
        TestHeader5 in = new TestHeader5();
        String val = new String(TestHeader5.class.getSimpleName());
        for (int idx = 0; idx < 2; idx++) {
            val += idx;
            in.setRequestType(val);
            proxy.testHeader5(out, outHeader, in);
            assertEquals(1000, out.value.getResponseType());
            assertEquals(val, outHeader.value.getRequestType());
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : TestHeader(org.apache.header_test.TestHeader) Holder(javax.xml.ws.Holder) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPHeaderService(org.apache.header_test.SOAPHeaderService) TestHeader5(org.apache.header_test.types.TestHeader5) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) TestHeader5ResponseBody(org.apache.header_test.types.TestHeader5ResponseBody) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 67 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.

the class ClientServerWebSocketTest method testBasicConnection2.

@Test
public void testBasicConnection2() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    // getPort only passing in SEI
    Greeter greeter = service.getPort(Greeter.class);
    updateGreeterAddress(greeter, PORT);
    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    try {
        for (int idx = 0; idx < 5; idx++) {
            String greeting = greeter.greetMe("Milestone-" + idx);
            assertNotNull("no response received from service", greeting);
            String exResponse = response1 + idx;
            assertEquals(exResponse, greeting);
            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response2, reply);
            greeter.greetMeOneWay("Milestone-" + idx);
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) URL(java.net.URL) Test(org.junit.Test)

Example 68 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.

the class ClientServerWebSocketTest method testBasicConnectionAndOneway.

@Test
public void testBasicConnectionAndOneway() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateGreeterAddress(greeter, PORT);
    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    try {
        for (int idx = 0; idx < 1; idx++) {
            String greeting = greeter.greetMe("Milestone-" + idx);
            assertNotNull("no response received from service", greeting);
            String exResponse = response1 + idx;
            assertEquals(exResponse, greeting);
            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response2, reply);
            greeter.greetMeOneWay("Milestone-" + idx);
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) URL(java.net.URL) Test(org.junit.Test)

Example 69 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.

the class ClientServerWebSocketTest method testBasicConnection.

@Test
public void testBasicConnection() throws Exception {
    SOAPService service = new SOAPService();
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateGreeterAddress(greeter, PORT);
    try {
        String reply = greeter.greetMe("test");
        assertNotNull("no response received from service", reply);
        assertEquals("Hello test", reply);
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals("Bonjour", reply);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
    BindingProvider bp = (BindingProvider) greeter;
    Map<String, Object> responseContext = bp.getResponseContext();
    Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
    assertEquals(200, responseCode.intValue());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) BindingProvider(javax.xml.ws.BindingProvider) Test(org.junit.Test)

Example 70 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project cxf by apache.

the class ProviderClientServerTest method testSOAPMessageModeDocLitWithSchemaValidation.

@Test
public void testSOAPMessageModeDocLitWithSchemaValidation() throws Exception {
    QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
    QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);
    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        setAddress(greeter, ADDRESS);
        try {
            greeter.greetMe("this is a greetMe message which length is more " + "than 30 so that I wanna a schema validation error");
            fail("Should have thrown an exception");
        } catch (Exception ex) {
            // expected
            assertTrue(ex.getMessage().contains("the length of the value is 96, but the required maximum is 30"));
        }
        try {
            greeter.greetMe("exceed maxLength");
            fail("Should have thrown an exception");
        } catch (Exception ex) {
            // expected
            assertTrue(ex.getMessage().contains("cvc-maxLength-valid"));
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) URL(java.net.URL) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)180 Test (org.junit.Test)66 IOException (java.io.IOException)37 URL (java.net.URL)25 Greeter (org.apache.hello_world_soap_http.Greeter)21 SOAPService (org.apache.hello_world_soap_http.SOAPService)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)14 Endpoint (javax.xml.ws.Endpoint)12 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)11 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)11 BufferedReader (java.io.BufferedReader)10 InputStreamReader (java.io.InputStreamReader)10 ServerSocket (java.net.ServerSocket)10 QName (javax.xml.namespace.QName)10 BindingProvider (javax.xml.ws.BindingProvider)10 Greeter (org.apache.cxf.greeter_control.Greeter)10 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 Socket (java.net.Socket)9 PollStatus (org.opennms.netmgt.poller.PollStatus)9