Search in sources :

Example 1 with HelloResponse

use of org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse in project jbossws-cxf by jbossws.

the class SchemaValidationTestCase method testSchemaValidationEndpoint.

@Test
@RunAsClient
public void testSchemaValidationEndpoint() throws Exception {
    QName serviceName = new QName("http://jboss.org/schemavalidation", "HelloService");
    URL wsdlURL = JBossWSTestHelper.getResourceURL("jaxws/samples/schemavalidation/WEB-INF/wsdl/hello.wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Hello proxy = (Hello) service.getPort(new QName("http://jboss.org/schemavalidation", "ValidatingHelloPort"), Hello.class);
    ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL + "/validatingHello");
    // valid value (see xsd restriction in the wsdl)
    HelloResponse hr = proxy.helloRequest("JBoss");
    assertNotNull(hr);
    assertEquals(1, hr.getReturn());
    try {
        proxy.helloRequest("number");
        fail("validation error is expected");
    } catch (Exception e) {
        assertTrue("not respect to enumration error is expected", e.getMessage().contains("is not facet-valid with respect to enumeration"));
    }
}
Also used : QName(javax.xml.namespace.QName) HelloResponse(org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 2 with HelloResponse

use of org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse in project jbossws-cxf by jbossws.

the class SchemaValidationTestCase method testClientSideSchemaValidationUsingConfiguration.

@Test
@RunAsClient
@WrapThreadContextClassLoader
public void testClientSideSchemaValidationUsingConfiguration() throws Exception {
    try {
        QName serviceName = new QName("http://jboss.org/schemavalidation", "HelloService");
        URL wsdlURL = JBossWSTestHelper.getResourceURL("jaxws/samples/schemavalidation/validatingClient.wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        Hello proxy = (Hello) service.getPort(new QName("http://jboss.org/schemavalidation", "HelloPort"), Hello.class);
        ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL + "/hello");
        // enable client side schema validation
        ClientConfigUtil.setConfigProperties(proxy, "META-INF/jaxws-client-config.xml", "Test Validating Client Config");
        HelloResponse hr = proxy.helloRequest("JBoss");
        assertNotNull(hr);
        assertEquals(2, hr.getReturn());
        try {
            proxy.helloRequest("number");
            fail("validation error is expected");
        } catch (Exception e) {
            assertTrue("not respect to enumration error is expected", e.getMessage().contains("is not facet-valid with respect to enumeration"));
        }
    } finally {
    }
}
Also used : QName(javax.xml.namespace.QName) HelloResponse(org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 3 with HelloResponse

use of org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse in project jbossws-cxf by jbossws.

the class Helper method testDefaultClientValidation.

public boolean testDefaultClientValidation() throws Exception {
    // first verify schema validation is not enabled yet: a wsdl with schema restrictions is used on client side,
    // but schema validation is not enabled; the invoked endpoint does not have schema validation on
    final QName serviceName = new QName("http://jboss.org/schemavalidation", "HelloService");
    final QName portName = new QName("http://jboss.org/schemavalidation", "HelloPort");
    final URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("validatingClient.wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Hello proxy = (Hello) service.getPort(portName, Hello.class);
    ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
    HelloResponse hr = proxy.helloRequest("JBoss");
    if (hr == null || hr.getReturn() != 2) {
        return false;
    }
    hr = proxy.helloRequest("number");
    if (hr == null || hr.getReturn() != 2) {
        return false;
    }
    final ClientConfig defClientConfig = (ClientConfig) getAndVerifyDefaultConfiguration(true);
    // then modify default conf to enable default client schema validation
    try {
        modifyDefaultConfiguration(true);
        service = Service.create(wsdlURL, serviceName);
        proxy = (Hello) service.getPort(portName, Hello.class);
        ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
        hr = proxy.helloRequest("JBoss");
        if (hr == null || hr.getReturn() != 2) {
            return false;
        }
        try {
            proxy.helloRequest("number");
            return false;
        } catch (Exception e) {
            return e.getMessage().contains("is not facet-valid with respect to enumeration");
        }
    } finally {
        // -- restore default conf --
        registerClientConfigAndReload(defClientConfig);
    // --
    }
}
Also used : QName(javax.xml.namespace.QName) HelloResponse(org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse) Service(javax.xml.ws.Service) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) URL(java.net.URL)

Example 4 with HelloResponse

use of org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse in project jbossws-cxf by jbossws.

the class SchemaValidationTestCase method testClientSideSchemaValidation.

@Test
@RunAsClient
public void testClientSideSchemaValidation() throws Exception {
    QName serviceName = new QName("http://jboss.org/schemavalidation", "HelloService");
    URL wsdlURL = JBossWSTestHelper.getResourceURL("jaxws/samples/schemavalidation/validatingClient.wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Hello proxy = (Hello) service.getPort(new QName("http://jboss.org/schemavalidation", "HelloPort"), Hello.class);
    ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL + "/hello");
    // enable client side schema validation
    ((BindingProvider) proxy).getRequestContext().put("schema-validation-enabled", true);
    HelloResponse hr = proxy.helloRequest("JBoss");
    assertNotNull(hr);
    assertEquals(2, hr.getReturn());
    try {
        proxy.helloRequest("number");
        fail("validation error is expected");
    } catch (Exception e) {
        assertTrue("not respect to enumration error is expected", e.getMessage().contains("is not facet-valid with respect to enumeration"));
    }
}
Also used : QName(javax.xml.namespace.QName) HelloResponse(org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 5 with HelloResponse

use of org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse in project jbossws-cxf by jbossws.

the class SchemaValidationTestCase method testNoSchemaValidationEndpoint.

@Test
@RunAsClient
public void testNoSchemaValidationEndpoint() throws Exception {
    QName serviceName = new QName("http://jboss.org/schemavalidation", "HelloService");
    URL wsdlURL = JBossWSTestHelper.getResourceURL("jaxws/samples/schemavalidation/WEB-INF/wsdl/hello.wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Hello proxy = (Hello) service.getPort(new QName("http://jboss.org/schemavalidation", "HelloPort"), Hello.class);
    ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL + "/hello");
    HelloResponse hr = proxy.helloRequest("JBoss");
    assertNotNull(hr);
    assertEquals(2, hr.getReturn());
    // validation is not enabled...
    hr = proxy.helloRequest("number");
    assertNotNull(hr);
    assertEquals(2, hr.getReturn());
}
Also used : QName(javax.xml.namespace.QName) HelloResponse(org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Aggregations

HelloResponse (org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse)8 URL (java.net.URL)6 QName (javax.xml.namespace.QName)6 Service (javax.xml.ws.Service)6 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)5 JBossWSTest (org.jboss.wsf.test.JBossWSTest)5 Test (org.junit.Test)5 ClientConfig (org.jboss.wsf.spi.metadata.config.ClientConfig)1 WrapThreadContextClassLoader (org.jboss.wsf.test.WrapThreadContextClassLoader)1