use of org.apache.schema_validation.SchemaValidation 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();
}
use of org.apache.schema_validation.SchemaValidation 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();
}
use of org.apache.schema_validation.SchemaValidation 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();
}
use of org.apache.schema_validation.SchemaValidation in project cxf by apache.
the class ValidationClientServerTest method testSchemaValidationServerForMethod.
@Test
public void testSchemaValidationServerForMethod() throws Exception {
SchemaValidation validation = createService(Boolean.FALSE, "SoapPortMethodValidate");
ComplexStruct complexStruct = new ComplexStruct();
complexStruct.setElem1("one");
complexStruct.setElem3(3);
try {
validation.setComplexStruct(complexStruct);
fail("Set ComplexStruct should have thrown ProtocolException");
} catch (WebServiceException e) {
String expected = "'{\"http://apache.org/schema_validation/types\":elem2}' is expected.";
assertTrue(e.getMessage(), e.getMessage().indexOf(expected) != -1);
}
SchemaValidation novlidation = createService(Boolean.FALSE, "SoapPort");
try {
novlidation.setComplexStruct(complexStruct);
} catch (WebServiceException e) {
fail("Exception is not expected :" + e);
}
}
use of org.apache.schema_validation.SchemaValidation in project cxf by apache.
the class ValidationClientServerTest method doProviderTest.
private void doProviderTest(String postfix) throws Exception {
SchemaValidation validation = createService(Boolean.FALSE, postfix);
SomeRequest req = new SomeRequest();
req.setId("9999999999");
try {
validation.doSomething(req);
fail("Should have faulted");
} catch (DoSomethingFault e) {
assertEquals("1234", e.getFaultInfo().getErrorCode());
}
req.setId("8888888888");
try {
validation.doSomething(req);
fail("Should have faulted");
} catch (DoSomethingFault e) {
fail("Should not have happened");
} catch (WebServiceException e) {
String expected = "Value '1' is not facet-valid";
assertTrue(e.getMessage().indexOf(expected) != -1);
}
((java.io.Closeable) validation).close();
}
Aggregations