Author: alessio.soldano(a)jboss.com
Date: 2012-08-30 09:07:13 -0400 (Thu, 30 Aug 2012)
New Revision: 16686
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/schemavalidation/client.wsdl
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/SchemaValidationTestCase.java
Log:
[JBWS-3500] Adding testcase for client side schema validation
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/SchemaValidationTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/SchemaValidationTestCase.java 2012-08-30
12:24:00 UTC (rev 16685)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/schemavalidation/SchemaValidationTestCase.java 2012-08-30
13:07:13 UTC (rev 16686)
@@ -47,7 +47,7 @@
return new JBossWSCXFTestSetup(SchemaValidationTestCase.class,
"jaxws-samples-schemavalidation.war");
}
- public void testSchemaValidation() throws Exception
+ public void testSchemaValidationEndpoint() throws Exception
{
QName serviceName = new
QName("http://jboss.org/schemavalidation",
"HelloService");
URL wsdlURL =
getResourceURL("jaxws/samples/schemavalidation/WEB-INF/wsdl/hello.wsdl");
@@ -65,7 +65,7 @@
}
}
- public void testNoSchemaValidation() throws Exception
+ public void testNoSchemaValidationEndpoint() throws Exception
{
QName serviceName = new
QName("http://jboss.org/schemavalidation",
"HelloService");
URL wsdlURL =
getResourceURL("jaxws/samples/schemavalidation/WEB-INF/wsdl/hello.wsdl");
@@ -79,4 +79,23 @@
assertNotNull(hr);
assertEquals(2, hr.getReturn());
}
+
+ public void testClientSideSchemaValidation() throws Exception
+ {
+ QName serviceName = new
QName("http://jboss.org/schemavalidation",
"HelloService");
+ URL wsdlURL =
getResourceURL("jaxws/samples/schemavalidation/client.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,
serviceURL);
+
((BindingProvider)proxy).getRequestContext().put("schema-validation-enabled",
true); //enable client side schema validation
+ HelloResponse hr = proxy.helloRequest("JBoss");
+ assertNotNull(hr);
+ assertEquals(2, hr.getReturn());
+ try {
+ proxy.helloRequest("number");
+ fail("validation error is expeced");
+ } catch (Exception e) {
+ assertTrue("not respect to enumration error is expected",
e.getMessage().contains("is not facet-valid with respect to enumeration"));
+ }
+ }
}
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/schemavalidation/client.wsdl
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/schemavalidation/client.wsdl
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/schemavalidation/client.wsdl 2012-08-30
13:07:13 UTC (rev 16686)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ name="helloworld"
+
targetNamespace="http://jboss.org/schemavalidation"
+
xmlns:tns="http://jboss.org/schemavalidation"
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+
xmlns:x1="http://jboss.org/schemavalidation/types">
+ <types>
+ <xsd:schema
+
xmlns="http://www.w3.org/2001/XMLSchema"
+
targetNamespace="http://jboss.org/schemavalidation/types"
+ elementFormDefault="qualified">
+
+ <complexType name="helloResponse">
+ <sequence>
+ <element name="return" type="xsd:int" />
+ </sequence>
+ </complexType>
+ <element name="helloResponse"
type="x1:helloResponse"/>
+
+ <element name="helloRequest">
+ <simpleType>
+ <restriction base="xsd:string">
+ <enumeration value="JBoss"/>
+ <enumeration value="CXF"/>
+ </restriction>
+ </simpleType>
+ </element>
+ </xsd:schema>
+ </types>
+ <message name="helloRequest">
+ <part name="parameters" element="x1:helloRequest" />
+ </message>
+ <message name="helloResponse">
+ <part name="result" element="x1:helloResponse" />
+ </message>
+ <portType name="hello">
+ <operation name="helloRequest">
+ <input message="tns:helloRequest" />
+ <output message="tns:helloResponse" />
+ </operation>
+ </portType>
+ <binding name="HelloBinding" type="tns:hello">
+ <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
+ <operation name="helloRequest">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloService">
+ <port name="HelloPort" binding="tns:HelloBinding">
+ <soap:address
location="http://localhost:8080/schemavalidation/hello" />
+ </port>
+ </service>
+</definitions>
\ No newline at end of file