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"));
}
}
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 {
}
}
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);
// --
}
}
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"));
}
}
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());
}
Aggregations