Search in sources :

Example 1 with SomeResponse

use of org.apache.schema_validation.types.SomeResponse in project cxf by apache.

the class ValidationClientServerTest method assertIgnoredResponseValidation.

private void assertIgnoredResponseValidation(Object validationConfig) throws Exception {
    SchemaValidation service = createService(validationConfig);
    // the request will result in invalid response but validation is turned off
    SomeResponse response = execute(service, "1234567890");
    assertEquals(response.getTransactionId(), "aaaaaaaaaaxxx");
    ((java.io.Closeable) service).close();
}
Also used : SomeResponse(org.apache.schema_validation.types.SomeResponse) SchemaValidation(org.apache.schema_validation.SchemaValidation)

Example 2 with SomeResponse

use of org.apache.schema_validation.types.SomeResponse in project cxf by apache.

the class ValidationClientServerTest method assertIgnoredRequestValidation.

private void assertIgnoredRequestValidation(Object validationConfig) throws Exception {
    SchemaValidation service = createService(validationConfig);
    // this is an invalid request but validation is turned off.
    SomeResponse response = execute(service, "1234567890aaaa");
    assertEquals(response.getTransactionId(), "aaaaaaaaaa");
    ((java.io.Closeable) service).close();
}
Also used : SomeResponse(org.apache.schema_validation.types.SomeResponse) SchemaValidation(org.apache.schema_validation.SchemaValidation)

Example 3 with SomeResponse

use of org.apache.schema_validation.types.SomeResponse in project cxf by apache.

the class ValidationClientServerTest method assertFailureResponseValidation.

private void assertFailureResponseValidation(Object validationConfig) throws Exception {
    SchemaValidation service = createService(validationConfig);
    // valid request
    SomeResponse response = execute(service, "1111111111");
    assertEquals(response.getTransactionId(), "aaaaaaaaaa");
    try {
        // valid request, but will result in invalid response
        execute(service, "1234567890");
        fail("should catch marshall exception as the invalid incoming message per schema");
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("Unmarshalling Error"));
        assertTrue(e.getMessage().contains("is not facet-valid with respect to pattern"));
    }
    ((java.io.Closeable) service).close();
}
Also used : SomeResponse(org.apache.schema_validation.types.SomeResponse) SchemaValidation(org.apache.schema_validation.SchemaValidation) WebServiceException(javax.xml.ws.WebServiceException)

Example 4 with SomeResponse

use of org.apache.schema_validation.types.SomeResponse in project cxf by apache.

the class ValidationClientServerTest method assertFailedRequestValidation.

private void assertFailedRequestValidation(Object validationConfig) throws Exception {
    SchemaValidation service = createService(validationConfig);
    SomeResponse response = execute(service, "1111111111");
    assertEquals(response.getTransactionId(), "aaaaaaaaaa");
    try {
        execute(service, "1234567890aaa");
        fail("should catch marshall exception as the invalid outgoing message per schema");
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("Marshalling Error"));
        assertTrue(e.getMessage().contains("is not facet-valid with respect to pattern"));
    }
    ((java.io.Closeable) service).close();
}
Also used : SomeResponse(org.apache.schema_validation.types.SomeResponse) SchemaValidation(org.apache.schema_validation.SchemaValidation) WebServiceException(javax.xml.ws.WebServiceException)

Example 5 with SomeResponse

use of org.apache.schema_validation.types.SomeResponse in project cxf by apache.

the class SchemaValidationImpl method doSomething.

@Override
public SomeResponse doSomething(SomeRequest in) throws DoSomethingFault {
    SomeResponse response = new SomeResponse();
    if (in.getId().equals("1234567890")) {
        // invalid transaction id
        response.setTransactionId("aaaaaaaaaaxxx");
    } else if (in.getId().equals("9999999999")) {
        SomeFault someFault = new SomeFault();
        someFault.setErrorCode("1234");
        throw new DoSomethingFault("Fault", someFault);
    } else if (in.getId().equals("8888888888")) {
        SomeFault someFault = new SomeFault();
        someFault.setErrorCode("1");
        throw new DoSomethingFault("Fault", someFault);
    } else {
        response.setTransactionId("aaaaaaaaaa");
    }
    return response;
}
Also used : DoSomethingFault(org.apache.schema_validation.DoSomethingFault) SomeFault(org.apache.schema_validation.types.SomeFault) SomeResponse(org.apache.schema_validation.types.SomeResponse)

Aggregations

SomeResponse (org.apache.schema_validation.types.SomeResponse)5 SchemaValidation (org.apache.schema_validation.SchemaValidation)4 WebServiceException (javax.xml.ws.WebServiceException)2 DoSomethingFault (org.apache.schema_validation.DoSomethingFault)1 SomeFault (org.apache.schema_validation.types.SomeFault)1