Search in sources :

Example 1 with AddNumberImpl

use of org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl in project cxf by apache.

the class WSAFromJavaTest method testAddNumbersFault.

@Test
public void testAddNumbersFault() throws Exception {
    ByteArrayOutputStream input = setupInLogging();
    ByteArrayOutputStream output = setupOutLogging();
    AddNumberImpl port = getPort();
    try {
        port.addNumbers(-1, 2);
    } catch (AddNumbersException_Exception e) {
        assert true;
    } catch (Exception e) {
        e.printStackTrace();
        assert false;
    }
    assertTrue(output.toString().indexOf("http://cxf.apache.org/input") != -1);
    String expectedFault = "http://server.addr_fromjava.ws.systest.cxf.apache.org/AddNumberImpl/" + "addNumbers/Fault/AddNumbersException";
    assertTrue(input.toString(), input.toString().indexOf(expectedFault) != -1);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 2 with AddNumberImpl

use of org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl in project cxf by apache.

the class WSAFromJavaTest method testAddNumbers3Fault.

@Test
public void testAddNumbers3Fault() throws Exception {
    ByteArrayOutputStream input = setupInLogging();
    ByteArrayOutputStream output = setupOutLogging();
    AddNumberImpl port = getPort();
    try {
        port.addNumbers3(-1, 2);
    } catch (AddNumbersException_Exception e) {
        assert true;
    } catch (Exception e) {
        e.printStackTrace();
        assert false;
    }
    assertTrue(output.toString(), output.toString().indexOf("http://cxf.apache.org/input") != -1);
    assertTrue(input.toString(), input.toString().indexOf("http://cxf.apache.org/fault3") != -1);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 3 with AddNumberImpl

use of org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl in project cxf by apache.

the class WSAFromJavaTest method testUnmatchedActions.

@Test
public void testUnmatchedActions() throws Exception {
    AddNumberImpl port = getPort();
    BindingProvider bp = (BindingProvider) port;
    java.util.Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://cxf.apache.org/input4");
    try {
        // CXF-2035
        port.addNumbers3(-1, -1);
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("Unexpected wrapper"));
    }
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) BindingProvider(javax.xml.ws.BindingProvider) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 4 with AddNumberImpl

use of org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl in project cxf by apache.

the class WSAFromJavaTest method testAddNumbersJaxWsContext.

@Test
public void testAddNumbersJaxWsContext() throws Exception {
    ByteArrayOutputStream output = setupOutLogging();
    AddNumberImpl port = getPort();
    BindingProvider bp = (BindingProvider) port;
    java.util.Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "cxf");
    try {
        assertEquals(3, port.addNumbers(1, 2));
        fail("Should have thrown an ActionNotSupported exception");
    } catch (SOAPFaultException ex) {
    // expected
    }
    assertLogContains(output.toString(), "//wsa:Action", "cxf");
    assertTrue(output.toString(), output.toString().indexOf("SOAPAction=\"cxf\"") != -1);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BindingProvider(javax.xml.ws.BindingProvider) Test(org.junit.Test)

Example 5 with AddNumberImpl

use of org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl in project cxf by apache.

the class WSAFromJavaTest method testNoRelatesToHeader.

@Test
public void testNoRelatesToHeader() throws Exception {
    new LoggingFeature().initialize(this.getBus());
    AddNumberImpl port = getPort();
    Client c = ClientProxy.getClient(port);
    c.getInInterceptors().add(new RemoveRelatesToHeaderInterceptor());
    long start = System.currentTimeMillis();
    port.addNumbers(1, 2);
    try {
        port.addNumbers3(-1, -1);
    } catch (Exception ex) {
    // ignore, expected
    }
    long end = System.currentTimeMillis();
    assertTrue((end - start) < 50000);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Client(org.apache.cxf.endpoint.Client) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Aggregations

AddNumberImpl (org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl)9 Test (org.junit.Test)8 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 AddNumbersException_Exception (org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception)5 BindingProvider (javax.xml.ws.BindingProvider)3 LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature)2 URL (java.net.URL)1 Client (org.apache.cxf.endpoint.Client)1 AddNumberImplService (org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImplService)1