Author: ema Date: Fri Aug 30 09:14:35 2013 New Revision: 1518919 URL: http://svn.apache.org/r1518919 Log: Merged revisions 1518917 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
................ r1518917 | ema | 2013-08-30 17:00:11 +0800 (Fri, 30 Aug 2013) | 13 lines Merged revisions 1518175,1518587 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1518175 | ema | 2013-08-28 20:12:30 +0800 (Wed, 28 Aug 2013) | 1 line [CXF-5237]:Schema validatation doesn't work in mtom enabled provider service ........ r1518587 | ema | 2013-08-29 19:10:19 +0800 (Thu, 29 Aug 2013) | 1 line [CXF-5237]:Validate XMLStream with MSV validator ........ ................ Added: cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_schema_validation/ - copied from r1518917, cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_schema_validation/ cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/resources/wsdl_systest/mtom_provider_validate.wsdl - copied unchanged from r1518917, cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/resources/wsdl_systest/mtom_provider_validate.wsdl Modified: cxf/branches/2.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/core/pom.xml cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/Messages.properties cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java cxf/branches/2.6.x-fixes/systests/jaxws/pom.xml cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java cxf/branches/2.6.x-fixes/systests/uncategorized/pom.xml Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1518917 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/core/pom.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/pom.xml?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/core/pom.xml (original) +++ cxf/branches/2.6.x-fixes/rt/core/pom.xml Fri Aug 30 09:14:35 2013 @@ -74,7 +74,11 @@ <artifactId>cxf-api</artifactId> <version>${project.version}</version> </dependency> - + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-wstx-msv-validation</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/Messages.properties URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/Messages.properties?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/Messages.properties (original) +++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/Messages.properties Fri Aug 30 09:14:35 2013 @@ -22,3 +22,4 @@ COULD_NOT_READ_XML_STREAM = Could not pa COULD_NOT_WRITE_XML_STREAM = Could not generate the XML stream. COULD_NOT_READ_XML_STREAM_CAUSED_BY = Could not parse the XML stream caused by: {0}: {1}. COULD_NOT_WRITE_XML_STREAM_CAUSED_BY = Could not generate the XML stream caused by: {0}: {1}. +COULD_NOT_VALIDATE_XML_STREAM = Failed to initialize MSV validator and validate the XMLStream. Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java (original) +++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Fri Aug 30 09:14:35 2013 @@ -28,6 +28,7 @@ import javax.activation.DataSource; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; @@ -36,9 +37,6 @@ import javax.xml.validation.Schema; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import org.xml.sax.SAXException; import org.apache.cxf.common.classloader.ClassLoaderUtils; import org.apache.cxf.common.logging.LogUtils; @@ -52,13 +50,14 @@ import org.apache.cxf.service.model.Mess import org.apache.cxf.staxutils.DepthXMLStreamReader; import org.apache.cxf.staxutils.FragmentStreamReader; import org.apache.cxf.staxutils.StaxSource; +import org.apache.cxf.staxutils.StaxStreamFilter; import org.apache.cxf.staxutils.StaxUtils; import org.apache.cxf.staxutils.W3CDOMStreamReader; - - +import org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl; public class XMLStreamDataReader implements DataReader<XMLStreamReader> { private static final Logger LOG = LogUtils.getL7dLogger(XMLStreamDataReader.class); + private static final QName XOP = new QName("http://www.w3.org/2004/08/xop/include", "Include"); private final Class<?> preferred; private Schema schema; @@ -153,9 +152,6 @@ public class XMLStreamDataReader impleme } catch (XMLStreamException e) { throw new Fault("COULD_NOT_READ_XML_STREAM_CAUSED_BY", LOG, e, e.getClass().getCanonicalName(), e.getMessage()); - } catch (SAXException e) { - throw new Fault("COULD_NOT_READ_XML_STREAM_CAUSED_BY", LOG, e, - e.getClass().getCanonicalName(), e.getMessage()); } } @@ -206,15 +202,27 @@ public class XMLStreamDataReader impleme return input; } - private Element validate(XMLStreamReader input) - throws XMLStreamException, SAXException, IOException { + private Element validate(XMLStreamReader input) throws XMLStreamException { DOMSource ds = read(input); - schema.newValidator().validate(ds); - Node nd = ds.getNode(); - if (nd instanceof Document) { - return ((Document)nd).getDocumentElement(); + Element rootElement = null; + if (ds.getNode() instanceof Document) { + rootElement = ((Document)ds.getNode()).getDocumentElement(); + } else { + rootElement = (Element)ds.getNode(); } - return (Element)ds.getNode(); + + //filter xop node + XMLStreamReader reader = StaxUtils.createXMLStreamReader(ds); + XMLStreamReader filteredReader = + StaxUtils.createFilteredReader(reader, + new StaxStreamFilter(new QName[] {XOP})); + + XMLStreamWriter nullWriter = StaxUtils.createXMLStreamWriter(new NUllOutputStream()); + //TODO: expensive to create WoodstoxValidationImpl ? + WoodstoxValidationImpl impl = new WoodstoxValidationImpl(message.getExchange().getBus()); + impl.setupValidation(nullWriter, message.getExchange().getService().getServiceInfos().get(0)); + StaxUtils.copy(filteredReader, nullWriter); + return rootElement; } private InputStream getInputStream(XMLStreamReader input) @@ -267,4 +275,13 @@ public class XMLStreamDataReader impleme message = (Message)value; } } + class NUllOutputStream extends OutputStream { + public void write(byte[] b, int off, int len) { + } + public void write(int b) { + } + + public void write(byte[] b) throws IOException { + } + } } Modified: cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java (original) +++ cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java Fri Aug 30 09:14:35 2013 @@ -21,7 +21,6 @@ package org.apache.cxf.bus.spring; import org.junit.Assert; import org.junit.Test; - import org.springframework.beans.BeansException; public class BusApplicationContextTest extends Assert { @@ -41,6 +40,6 @@ public class BusApplicationContextTest e ctx = new BusApplicationContext(cfgFile, false); assertEquals("Unexpected number of resources", 1, ctx.getConfigResources().length); ctx = new BusApplicationContext(cfgFile, true); - assertEquals("Unexpected number of resources", 2, ctx.getConfigResources().length); + assertEquals("Unexpected number of resources", 3, ctx.getConfigResources().length); } } Modified: cxf/branches/2.6.x-fixes/systests/jaxws/pom.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxws/pom.xml?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxws/pom.xml (original) +++ cxf/branches/2.6.x-fixes/systests/jaxws/pom.xml Fri Aug 30 09:14:35 2013 @@ -216,5 +216,17 @@ <groupId>xalan</groupId> <artifactId>xalan</artifactId> </dependency> + <dependency> + <groupId>net.java.dev.msv</groupId> + <artifactId>msv-core</artifactId> + <exclusions> + <exclusion> + <groupId>net.java.dev.msv</groupId> + <artifactId>msv-testharness</artifactId> + </exclusion> + </exclusions> + <scope>test</scope> + </dependency> + </dependencies> </project> Modified: cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java Fri Aug 30 09:14:35 2013 @@ -150,7 +150,7 @@ public class ProviderClientServerTest ex fail("Should have thrown an exception"); } catch (Exception ex) { //expected - assertTrue(ex.getMessage().contains("cvc-maxLength-valid")); + assertTrue(ex.getMessage().contains("the length of the value is 96, but the required maximum is 30")); } try { Modified: cxf/branches/2.6.x-fixes/systests/uncategorized/pom.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/uncategorized/pom.xml?rev=1518919&r1=1518918&r2=1518919&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/uncategorized/pom.xml (original) +++ cxf/branches/2.6.x-fixes/systests/uncategorized/pom.xml Fri Aug 30 09:14:35 2013 @@ -416,5 +416,16 @@ <artifactId>commons-httpclient</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>net.java.dev.msv</groupId> + <artifactId>msv-core</artifactId> + <exclusions> + <exclusion> + <groupId>net.java.dev.msv</groupId> + <artifactId>msv-testharness</artifactId> + </exclusion> + </exclusions> + <scope>test</scope> + </dependency> </dependencies> </project>
