Search in sources :

Example 6 with SchemaValidation

use of org.apache.schema_validation.SchemaValidation 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 7 with SchemaValidation

use of org.apache.schema_validation.SchemaValidation in project cxf by apache.

the class ValidationClientServerTest method testSchemaValidationClient.

@Test
public void testSchemaValidationClient() throws Exception {
    SchemaValidation validation = createService(Boolean.TRUE, "SoapPort");
    runSchemaValidationTest(validation);
    ((java.io.Closeable) validation).close();
}
Also used : SchemaValidation(org.apache.schema_validation.SchemaValidation) Test(org.junit.Test)

Example 8 with SchemaValidation

use of org.apache.schema_validation.SchemaValidation in project cxf by apache.

the class ValidationClientServerTest method createService.

private SchemaValidation createService(Object validationConfig, String postfix) throws Exception {
    URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
    assertNotNull(wsdl);
    SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
    assertNotNull(service);
    SchemaValidation validation = service.getPort(portName, SchemaValidation.class);
    setAddress(validation, "http://localhost:" + PORT + "/SoapContext/" + postfix);
    ((BindingProvider) validation).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
    ((BindingProvider) validation).getResponseContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
    new LoggingFeature().initialize((Client) validation, getBus());
    return validation;
}
Also used : LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) SchemaValidationService(org.apache.schema_validation.SchemaValidationService) URL(java.net.URL) SchemaValidation(org.apache.schema_validation.SchemaValidation)

Example 9 with SchemaValidation

use of org.apache.schema_validation.SchemaValidation in project cxf by apache.

the class ValidationClientServerTest method testSchemaValidationServer.

@Test
public void testSchemaValidationServer() throws Exception {
    SchemaValidation validation = createService(Boolean.FALSE, "SoapPortValidate");
    runSchemaValidationTest(validation);
    ((java.io.Closeable) validation).close();
}
Also used : SchemaValidation(org.apache.schema_validation.SchemaValidation) Test(org.junit.Test)

Aggregations

SchemaValidation (org.apache.schema_validation.SchemaValidation)9 WebServiceException (javax.xml.ws.WebServiceException)4 SomeResponse (org.apache.schema_validation.types.SomeResponse)4 Test (org.junit.Test)3 URL (java.net.URL)1 LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature)1 DoSomethingFault (org.apache.schema_validation.DoSomethingFault)1 SchemaValidationService (org.apache.schema_validation.SchemaValidationService)1 ComplexStruct (org.apache.schema_validation.types.ComplexStruct)1 SomeRequest (org.apache.schema_validation.types.SomeRequest)1