Author: veithen
Date: Wed Dec 20 21:35:47 2017
New Revision: 1818856
URL: http://svn.apache.org/viewvc?rev=1818856&view=rev
Log:
Enable schema validation in the JiBX tests.
Modified:
axis/axis2/java/core/branches/schema-validation/modules/jibx/pom.xml
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
axis/axis2/java/core/branches/schema-validation/systests/echo/services.xml
Modified: axis/axis2/java/core/branches/schema-validation/modules/jibx/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/modules/jibx/pom.xml?rev=1818856&r1=1818855&r2=1818856&view=diff
==============================================================================
--- axis/axis2/java/core/branches/schema-validation/modules/jibx/pom.xml
(original)
+++ axis/axis2/java/core/branches/schema-validation/modules/jibx/pom.xml Wed
Dec 20 21:35:47 2017
@@ -76,6 +76,13 @@
<type>aar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>schema-validation</artifactId>
+ <version>${project.version}</version>
+ <type>mar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<url>http://axis.apache.org/axis2/java/core/</url>
<scm>
@@ -237,6 +244,7 @@
<generatedAxis2xml>
<modules>
<module>checker</module>
+ <module>schema-validation</module>
</modules>
</generatedAxis2xml>
</configuration>
Modified:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java?rev=1818856&r1=1818855&r2=1818856&view=diff
==============================================================================
---
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
(original)
+++
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
Wed Dec 20 21:35:47 2017
@@ -34,26 +34,38 @@ import javax.xml.validation.SchemaFactor
import org.apache.axiom.om.OMException;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.util.JavaUtils;
import org.apache.ws.commons.schema.XmlSchema;
import org.xml.sax.SAXException;
public class SchemaValidationHandler extends AbstractHandler {
public InvocationResponse invoke(MessageContext msgContext) throws
AxisFault {
+ AxisService service = msgContext.getAxisService();
+ Parameter parameter = service.getParameter("disableSchemaValidation");
+ if (parameter != null &&
JavaUtils.isTrueExplicitly(parameter.getValue())) {
+ return InvocationResponse.CONTINUE;
+ }
+ List<XmlSchema> schemas = service.getSchema();
+ if (schemas.isEmpty()) {
+ return InvocationResponse.CONTINUE;
+ }
SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- List<Source> schemas = new ArrayList<Source>();
- for (XmlSchema schema : msgContext.getAxisService().getSchema()) {
+ List<Source> schemaSources = new ArrayList<Source>();
+ for (XmlSchema schema : schemas) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
schema.write(baos);
} catch (UnsupportedEncodingException ex) {
throw AxisFault.makeFault(ex);
}
- schemas.add(new StreamSource(new
ByteArrayInputStream(baos.toByteArray())));
+ schemaSources.add(new StreamSource(new
ByteArrayInputStream(baos.toByteArray())));
}
Schema schema;
try {
- schema = schemaFactory.newSchema(schemas.toArray(new
Source[schemas.size()]));
+ schema = schemaFactory.newSchema(schemaSources.toArray(new
Source[schemaSources.size()]));
} catch (SAXException ex) {
throw new AxisFault("Failed to compile schemas", ex);
}
Modified:
axis/axis2/java/core/branches/schema-validation/systests/echo/services.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/systests/echo/services.xml?rev=1818856&r1=1818855&r2=1818856&view=diff
==============================================================================
--- axis/axis2/java/core/branches/schema-validation/systests/echo/services.xml
(original)
+++ axis/axis2/java/core/branches/schema-validation/systests/echo/services.xml
Wed Dec 20 21:35:47 2017
@@ -19,6 +19,8 @@
<service name="Echo">
<parameter
name="ServiceClass">org.apache.axis2.echo.EchoService</parameter>
+ <!-- This parameter is recognized by the schema-validation module -->
+ <parameter name="disableSchemaValidation">true</parameter>
<operation name="echo">
<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>