Thanks Szczepan. I've just created GRADLE-1549 and attached the example. Cheers, Joe
On 14 May 2011 06:17, Szczepan Faber <[email protected]> wrote: > Hey, > > You can create a jira ticket and attach the zip. > > Cheers! > Szczepan > > 12-05-2011 17:43 użytkownik "Joe Schmetzer" <[email protected]> napisał: >> Hi all, >> >> I'm having troubles running an xml schema validation unit test from >> Gradle. It's a relatively simple test, but it uses some XML Schema 1.1 >> features in the XSD. These features seem to really react badly to >> running in a Gradle worker process. Running exactly the same code from >> Ant has no problems, but when running from Gradle, I get an error with >> a stack trace pointing to some problem deep in the XML processing >> libraries. Can anyone help with suggestions on how to avoid this, or >> fix the root cause? >> >> I have packaged up a small example which demonstrates this problem. >> There are 2 tests in the class. Both should pass, but when running >> from gradle, the first test fails with the following stack trace >> (which I have put below) >> >> Here's the test: >> >> SchemaValidationTest.java: >> ======================== >> package com.example.xmltest; >> import java.io.IOException; >> import org.junit.Test; >> import org.xml.sax.SAXException; >> import javax.xml.transform.Source; >> import javax.xml.transform.stream.StreamSource; >> import javax.xml.validation.Schema; >> import javax.xml.validation.SchemaFactory; >> import javax.xml.validation.Validator; >> public class SchemaValidationTest { >> @Test >> public void validateSchemaSimple() throws Exception { >> StreamSource schemaDocument = new >> StreamSource(getClass().getResourceAsStream("simpleWithAssert.xsd")); >> Source instanceDocument = new >> StreamSource(getClass().getResourceAsStream("simpleTest.xml")); >> validate(schemaDocument, instanceDocument); >> } >> @Test >> public void validateSchemaWithoutOnePointOneFeatures() throws >> Exception { >> StreamSource schemaDocument = new >> StreamSource(getClass().getResourceAsStream("simpleWithoutAssert.xsd")); >> Source instanceDocument = new >> StreamSource(getClass().getResourceAsStream("simpleTest.xml")); >> validate(schemaDocument, instanceDocument); >> } >> >> private void validate(StreamSource schemaDocument, >> Source instanceDocument) throws SAXException, >> IOException { >> SchemaFactory schemaFactory = >> SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1"); >> Schema schema = schemaFactory.newSchema(schemaDocument); >> Validator validator = schema.newValidator(); >> validator.validate(instanceDocument); >> } >> >> } >> ======================== >> >> simpleTest.xml: >> ======================== >> <?xml version="1.0" encoding="UTF-8"?> >> <idea state="Closed" closeddatetime="23-05-2007 18:45:23 BST" /> >> ======================== >> >> simpleWithAssert.xsd: >> ======================== >> <?xml version="1.0" encoding="ISO-8859-15"?> >> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> >> <xs:element name="idea"> >> <xs:complexType> >> <xs:attribute name="state" default="Open"> >> <xs:simpleType> >> <xs:restriction base="xs:token"> >> <xs:enumeration value="Open" /> >> <xs:enumeration value="Closed" /> >> </xs:restriction> >> </xs:simpleType> >> </xs:attribute> >> <xs:attribute name="closeddatetime" /> >> <xs:assert test="(@state ne 'Closed') or not(empty(@closeddatetime))" /> >> </xs:complexType> >> </xs:element> >> </xs:schema> >> ======================== >> >> simpleWithoutAssert.xsd: >> ======================== >> <?xml version="1.0" encoding="ISO-8859-15"?> >> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> >> <xs:element name="idea"> >> <xs:complexType> >> <xs:attribute name="state" default="Open"> >> <xs:simpleType> >> <xs:restriction base="xs:token"> >> <xs:enumeration value="Open" /> >> <xs:enumeration value="Closed" /> >> </xs:restriction> >> </xs:simpleType> >> </xs:attribute> >> <xs:attribute name="closeddatetime" /> >> </xs:complexType> >> </xs:element> >> </xs:schema> >> ======================== >> >> Stack trace: >> ======================== >> java.lang.AssertionError >> at >> org.eclipse.wst.xml.xpath2.processor.internal.types.QName.namespace(QName.java:235) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.name_test(DefaultEvaluator.java:1316) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1379) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.NameTest.accept(NameTest.java:39) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1242) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.ForwardStep.accept(ForwardStep.java:141) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:2003) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.AxisStep.accept(AxisStep.java:46) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1195) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:43) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_bin_args(DefaultEvaluator.java:752) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:563) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr.accept(CmpExpr.java:106) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_expr(DefaultEvaluator.java:264) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1475) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.ParExpr.accept(ParExpr.java:40) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:2036) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr.accept(FilterExpr.java:52) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1195) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:43) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_bin_args(DefaultEvaluator.java:752) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_logic_exp(DefaultEvaluator.java:459) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:481) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.OrExpr.accept(OrExpr.java:37) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1509) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.FunctionCall.accept(FunctionCall.java:46) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:2036) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr.accept(FilterExpr.java:52) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1195) >> at >> org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:43) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_expr(DefaultEvaluator.java:264) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:285) >> at org.eclipse.wst.xml.xpath2.processor.ast.XPath.accept(XPath.java:43) >> at >> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.evaluate(DefaultEvaluator.java:239) >> at >> org.apache.xerces.impl.xs.AbstractPsychoPathImpl.evaluatePsychoPathExpr(Unknown >> Source) >> at >> org.apache.xerces.impl.xs.XMLAssertPsychopathImpl.evaluateAssertion(Unknown >> Source) >> at >> org.apache.xerces.impl.xs.XMLAssertPsychopathImpl.evaluateAssertionsFromAComplexType(Unknown >> Source) >> at >> org.apache.xerces.impl.xs.XMLAssertPsychopathImpl.processAllAssertionsOnElement(Unknown >> Source) >> at org.apache.xerces.impl.xs.XMLAssertPsychopathImpl.endElement(Unknown >> Source) >> at >> org.apache.xerces.impl.xs.XSDAssertionValidator.handleEndElement(Unknown >> Source) >> at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown >> Source) >> at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown >> Source) >> at >> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown >> Source) >> at >> org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown >> Source) >> at >> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown >> Source) >> at >> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown >> Source) >> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) >> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) >> at >> org.apache.xerces.jaxp.validation.StreamValidatorHelper.validate(Unknown >> Source) >> at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown >> Source) >> at javax.xml.validation.Validator.validate(Validator.java:127) >> at >> com.youdevise.xmltest.SchemaValidationTest.validate(SchemaValidationTest.java:35) >> at >> com.youdevise.xmltest.SchemaValidationTest.validateSchemaSimple(SchemaValidationTest.java:19) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) >> at >> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) >> at >> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) >> at >> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) >> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:279) >> at >> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) >> at >> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48) >> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:247) >> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:57) >> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:245) >> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:47) >> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:238) >> at org.junit.runners.ParentRunner.run(ParentRunner.java:308) >> at >> org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:51) >> at >> org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:63) >> at >> org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) >> at >> org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) >> at >> org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) >> at >> org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:75) >> at $Proxy3.processTestClass(Unknown Source) >> at >> org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:86) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) >> at >> org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) >> at >> org.gradle.messaging.remote.internal.MethodInvocationUnmarshallingDispatch.dispatch(MethodInvocationUnmarshallingDispatch.java:48) >> at >> org.gradle.messaging.dispatch.DiscardOnFailureDispatch.dispatch(DiscardOnFailureDispatch.java:31) >> at >> org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:129) >> at >> org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33) >> at >> org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:69) >> at >> org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:63) >> at >> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) >> at >> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) >> at java.lang.Thread.run(Thread.java:619) >> ======================== >> >> I have all this code, build scripts, and library jars packed up in a >> zip file. It was 2.5MB includes jars, and I didn't want to post that >> to the mailing list. If anyone wants to have a look, let me know and >> I'll send you the zip. >> >> Thanks, >> Joe >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
