This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.6.x-fixes by this push:
new b3a135e645 [CXF-8979]add testcase
b3a135e645 is described below
commit b3a135e64536f0126f7f48a2521e7c108d279534
Author: Freeman Fang <[email protected]>
AuthorDate: Thu Nov 21 17:14:20 2024 -0500
[CXF-8979]add testcase
(cherry picked from commit 7168252593792e85c2ba92a64f1a053c9db0236e)
(cherry picked from commit 57a132e9b7ba26203d7aecd06718a5eee35caee9)
---
.../jaxws/SchemaValidationClientServerTest.java | 56 +++++++++++++++++-
.../wsdl_systest_jaxws/cxf8979-request.xml | 26 +++++++++
.../test/resources/wsdl_systest_jaxws/cxf8979.wsdl | 66 ++++++++++++++++++++++
.../test/resources/wsdl_systest_jaxws/cxf8979.xsd | 49 ++++++++++++++++
4 files changed, 195 insertions(+), 2 deletions(-)
diff --git
a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
index da68e4168a..0077822842 100644
---
a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
+++
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
@@ -19,12 +19,20 @@
package org.apache.cxf.systest.jaxws;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
import javax.xml.ws.Endpoint;
-
+import javax.xml.ws.Provider;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import org.apache.cxf.annotations.SchemaValidation;
import org.apache.cxf.ext.logging.LoggingInInterceptor;
import org.apache.cxf.ext.logging.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
@@ -46,10 +54,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
public class SchemaValidationClientServerTest extends
AbstractBusClientServerTestBase {
static final String PORT = allocatePort(Server.class);
-
+ private static URL wsdlUrl;
private final QName portName = new
QName("http://cxf.apache.org/jaxws/schemavalidation", "servicePort");
+
public static class Server extends AbstractBusTestServerBase {
@@ -67,6 +77,10 @@ public class SchemaValidationClientServerTest extends
AbstractBusClientServerTes
((EndpointImpl)ep).getInInterceptors().add(new
LoggingInInterceptor());
((EndpointImpl)ep).getOutInterceptors().add(new
LoggingOutInterceptor());
ep.publish(address);
+ EndpointImpl endpoint = (EndpointImpl)Endpoint.publish(
+ "http://localhost:" + PORT + "/server",
new TestEndpoint());
+ endpoint.getProperties().put("not-use-msv-schema-validator",
"true");
+ wsdlUrl =
this.getClass().getClassLoader().getResource("wsdl_systest_jaxws/cxf8979.wsdl");
}
public static void main(String[] args) {
@@ -81,6 +95,26 @@ public class SchemaValidationClientServerTest extends
AbstractBusClientServerTes
}
}
}
+
+ public static class TestClient extends Service {
+
+ protected TestClient(URL wsdlDocumentLocation, QName serviceName) {
+ super(wsdlDocumentLocation, serviceName);
+ }
+ }
+
+ @ServiceMode(value = Service.Mode.PAYLOAD)
+ @WebServiceProvider(wsdlLocation = "wsdl_systest_jaxws/cxf8979.wsdl",
+ serviceName = "TestService", portName = "TestService",
targetNamespace = "http://test.namespace/")
+ @SchemaValidation(type = SchemaValidation.SchemaValidationType.REQUEST)
+ public static class TestEndpoint implements Provider<Source> {
+
+
+ @Override
+ public Source invoke(Source request) {
+ return request;
+ }
+ }
@BeforeClass
public static void startServers() throws Exception {
@@ -157,5 +191,23 @@ public class SchemaValidationClientServerTest extends
AbstractBusClientServerTes
}
}
+
+ @Test
+ public void testWithValidation() {
+ QName serviceName = new QName("http://test.namespace/", "TestService");
+ QName port = new QName("http://test.namespace/", "TestService");
+ TestClient service = new TestClient(wsdlUrl, serviceName);
+ Source request =
readResource("wsdl_systest_jaxws/cxf8979-request.xml");
+ Dispatch<Source> dispatcher = service.createDispatch(port,
Source.class, Service.Mode.MESSAGE);
+
dispatcher.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + PORT +
"/server");
+
+ dispatcher.invoke(request);
+ }
+
+ private Source readResource(String resName) {
+ return new
StreamSource(this.getClass().getClassLoader().getResourceAsStream(resName));
+ }
+
}
diff --git
a/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979-request.xml
b/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979-request.xml
new file mode 100644
index 0000000000..d074f1cfa3
--- /dev/null
+++ b/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979-request.xml
@@ -0,0 +1,26 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one *
or more
+ contributor license agreements. See the NOTICE file *
distributed with
+ this work for additional information * regarding copyright
ownership.
+ The ASF licenses this file * to you under the Apache License,
Version
+ 2.0 (the * "License"); you may not use this file except in
compliance
+ * with the License. You may obtain a copy of the License at * *
+ http://www.apache.org/licenses/LICENSE-2.0 * * Unless required
by
+ applicable law or agreed to in writing, * software distributed
under
+ the License is distributed on an * "AS IS" BASIS, WITHOUT
WARRANTIES
+ OR CONDITIONS OF ANY * KIND, either express or implied. See the
+ License for the * specific language governing permissions and
+ limitations * under the License.
+ -->
+<SOAP-ENV:Envelope
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:test="http://test.namespace/"
+>
+ <SOAP-ENV:Body>
+ <test:Root>
+ <test:AbstractElement
xsi:type="test:STE_ReproducerBasis">Valid1</test:AbstractElement>
+ <test:ConcreteElement>Valid2</test:ConcreteElement>
+ </test:Root>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
diff --git a/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979.wsdl
b/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979.wsdl
new file mode 100644
index 0000000000..22dcfd6efe
--- /dev/null
+++ b/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979.wsdl
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one *
or more
+ contributor license agreements. See the NOTICE file *
distributed with
+ this work for additional information * regarding copyright
ownership.
+ The ASF licenses this file * to you under the Apache License,
Version
+ 2.0 (the * "License"); you may not use this file except in
compliance
+ * with the License. You may obtain a copy of the License at * *
+ http://www.apache.org/licenses/LICENSE-2.0 * * Unless required
by
+ applicable law or agreed to in writing, * software distributed
under
+ the License is distributed on an * "AS IS" BASIS, WITHOUT
WARRANTIES
+ OR CONDITIONS OF ANY * KIND, either express or implied. See the
+ License for the * specific language governing permissions and
+ limitations * under the License.
+ -->
+
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:test="http://test.namespace/"
+
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
+
targetNamespace="http://test.namespace/">
+
+ <wsdl:types>
+ <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
targetNamespace="http://test.namespace/"
+ attributeFormDefault="qualified"
+ elementFormDefault="qualified">
+ <xsd:include schemaLocation="cxf8979.xsd"/>
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="TestMessage">
+ <wsdl:part name="Body" element="test:Root"/>
+ </wsdl:message>
+ <wsdl:message name="TestMessageResponse">
+ <wsdl:part name="Body" element="test:Root"/>
+ </wsdl:message>
+
+ <wsdl:portType name="TestServicePortType">
+ <wsdl:operation name="TestOp">
+ <wsdl:input message="test:TestMessage"/>
+ <wsdl:output message="test:TestMessageResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="TestServiceBinding" type="test:TestServicePortType">
+ <soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="TestOp">
+ <soapbind:operation soapAction=""/>
+ <wsdl:input>
+ <soapbind:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soapbind:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="TestService">
+ <wsdl:port name="TestService" binding="test:TestServiceBinding">
+ <soapbind:address
location="http://localhost:8080/TestService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+
+</wsdl:definitions>
diff --git a/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979.xsd
b/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979.xsd
new file mode 100644
index 0000000000..e4c12e655c
--- /dev/null
+++ b/systests/jaxws/src/test/resources/wsdl_systest_jaxws/cxf8979.xsd
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one *
or more
+ contributor license agreements. See the NOTICE file *
distributed with
+ this work for additional information * regarding copyright
ownership.
+ The ASF licenses this file * to you under the Apache License,
Version
+ 2.0 (the * "License"); you may not use this file except in
compliance
+ * with the License. You may obtain a copy of the License at * *
+ http://www.apache.org/licenses/LICENSE-2.0 * * Unless required
by
+ applicable law or agreed to in writing, * software distributed
under
+ the License is distributed on an * "AS IS" BASIS, WITHOUT
WARRANTIES
+ OR CONDITIONS OF ANY * KIND, either express or implied. See the
+ License for the * specific language governing permissions and
+ limitations * under the License.
+ -->
+
+<xsd:schema
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://test.namespace/"
+ targetNamespace="http://test.namespace/"
+ elementFormDefault="qualified"
+ attributeFormDefault="qualified">
+
+ <xsd:element name="Root">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="AbstractElement"
type="test:STE_Reproducer" minOccurs="0"/>
+ <xsd:element name="ConcreteElement"
type="test:STE_ReproducerBasis" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="STE_Reproducer" abstract="true">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="STE_ReproducerBasis" final="#all">
+ <xsd:simpleContent>
+ <xsd:restriction base="test:STE_Reproducer">
+ <xsd:enumeration value="Valid1"/>
+ <xsd:enumeration value="Valid2"/>
+ </xsd:restriction>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+</xsd:schema>