diff --git a/xsdlib/pom.xml b/xsdlib/pom.xml
index 60bc5dcd..fa77d1c8 100644
--- a/xsdlib/pom.xml
+++ b/xsdlib/pom.xml
@@ -161,6 +161,7 @@ EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
**/*Test.java
**/*TestCase.java
**/*TestCases.java
+ com/sun/msv/datatype/xsd/conformance/TestDriver.java
**/*$*
diff --git a/xsdlib/src/main/java/com/sun/msv/datatype/xsd/Base64BinaryType.java b/xsdlib/src/main/java/com/sun/msv/datatype/xsd/Base64BinaryType.java
index 41cba51b..bb835765 100644
--- a/xsdlib/src/main/java/com/sun/msv/datatype/xsd/Base64BinaryType.java
+++ b/xsdlib/src/main/java/com/sun/msv/datatype/xsd/Base64BinaryType.java
@@ -129,24 +129,22 @@ private static int calcLength( final char[] buf ) {
int i;
for( i=0; i=256 )
+ if( buf[i]>=256 || decodeMap[buf[i]] == -1 )
return -1; // incorrect character
- if( decodeMap[buf[i]]!=-1 )
- base64count++;
+ base64count++;
}
// once we saw '=', nothing but '=' can be appeared.
for( ; i=256 )
+ if( isXMLSpace(buf[i]) )
+ continue; // ignore whitespace
+ if( buf[i]!='=' )
return -1; // incorrect character
- if( decodeMap[buf[i]]!=-1 )
- return -1;
+ paddingCount++;
}
// no more than two paddings are allowed.
@@ -226,6 +224,11 @@ public String convertToLexicalValue( Object value, SerializationContext context
return serializeJavaObject( ((BinaryValueType)value).rawData, context );
}
+ private static boolean isXMLSpace(char c) {
+ // Per https://www.w3.org/TR/xml/#NT-S
+ return c == ' ' || c == '\r' || c == '\n' || c == '\t';
+ }
+
// serialization support
private static final long serialVersionUID = 1;
}
diff --git a/xsdlib/src/main/java/com/sun/msv/datatype/xsd/DateTimeBaseType.java b/xsdlib/src/main/java/com/sun/msv/datatype/xsd/DateTimeBaseType.java
index 2a45b7b6..f3869659 100644
--- a/xsdlib/src/main/java/com/sun/msv/datatype/xsd/DateTimeBaseType.java
+++ b/xsdlib/src/main/java/com/sun/msv/datatype/xsd/DateTimeBaseType.java
@@ -86,7 +86,11 @@ public final String convertToLexicalValue( Object value, SerializationContext co
/** converts our DateTimeValueType to a java-friendly Date type. */
public final Object _createJavaObject(String literal, ValidationContext context) {
- return CalendarParser.parse(getFormat(),literal);
+ try {
+ return CalendarParser.parse(getFormat(),literal);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
}
public final String serializeJavaObject(Object value, SerializationContext context) {
diff --git a/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/DataTypeTester.java b/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/DataTypeTester.java
index 43e2b1ea..ff6d238c 100644
--- a/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/DataTypeTester.java
+++ b/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/DataTypeTester.java
@@ -23,6 +23,7 @@
import java.io.PrintStream;
import java.util.List;
import org.jdom2.Element;
+import org.junit.Assert;
import org.relaxng.datatype.DatatypeException;
/**
@@ -215,11 +216,15 @@ public void testDataType(
// try round trip conversion.
Object o2 = typeObj.createValue(s,DummyContextProvider.theInstance);
if( o2==null || !o.equals(o2) )
+ {
+ System.out.println("equals error: \n\"" + o.toString() + "\"\n\"" + s + "\"\n\"" + o2.toString() + "\"");
roundTripError = true;
+ }
}
} catch( UnsupportedOperationException uoe ) {
// ignore this exception
} catch( IllegalArgumentException iae ) {
+ System.out.println("roundtrip IllegalArgumentException");
roundTripError = true;
}
@@ -240,7 +245,7 @@ public void testDataType(
Object o2 = typeObj.createJavaObject(s,DummyContextProvider.theInstance);
if( o2==null ) {
System.out.println("round-trip conversion failed");
- roundTripError = true;
+ roundTripError = true;
}
}
}
@@ -266,6 +271,8 @@ public void testDataType(
continue; // do not report error if
// the validator accepts things that
// may not be accepted.
+ }else if(roundTripError){
+ Assert.fail("RoundtripError!");
}
// dump error messages
@@ -293,13 +300,14 @@ public void testDataType(
if( typeObj.createJavaObject(wrongs[i],DummyContextProvider.theInstance)!=null )
err = true;
-
+
if( err ) {
if( !this.err.report( new UnexpectedResultException(
typeObj, baseType.getName(),
wrongs[i], false, ti ) ) )
{
out.println("test aborted");
+ Assert.fail("Test aborted!");
return;
}
}
diff --git a/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/TestDriverTest.java b/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/TestDriver.java
similarity index 93%
rename from xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/TestDriverTest.java
rename to xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/TestDriver.java
index 72b53364..77a282cd 100644
--- a/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/TestDriverTest.java
+++ b/xsdlib/src/test/java/com/sun/msv/datatype/xsd/conformance/TestDriver.java
@@ -16,6 +16,7 @@
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
+import org.junit.Assert;
import org.junit.Test;
import org.relaxng.datatype.Datatype;
import org.relaxng.datatype.DatatypeException;
@@ -25,7 +26,7 @@
*
* @author Kohsuke KAWAGUCHI
*/
-public class TestDriverTest implements ErrorReceiver
+public class TestDriver implements ErrorReceiver
{
@@ -33,7 +34,7 @@ public class TestDriverTest implements ErrorReceiver
public static void main (String args[]) throws Exception {
- TestDriverTest testDriver = new TestDriverTest();
+ TestDriver testDriver = new TestDriver();
if( args.length>=1 ) testDriver.parser = args[0];
else testDriver.parser = "org.apache.xerces.parsers.SAXParser";
// reads test case file
@@ -45,7 +46,7 @@ public void runTests() throws Exception {
try {
// reads test case file
- Document doc = new SAXBuilder(parser).build(TestDriverTest.class.getResourceAsStream("DataTypeTest.xml") );
+ Document doc = new SAXBuilder(parser).build(TestDriver.class.getResourceAsStream("DataTypeTest.xml") );
DataTypeTester tester = new DataTypeTester(System.out,this);
// perform test for each "case" item
@@ -55,6 +56,7 @@ public void runTests() throws Exception {
} catch(JDOMException e) {
e.printStackTrace();
System.err.println(e.getMessage());
+ Assert.fail(e.getMessage());
}
}
@@ -86,7 +88,7 @@ public boolean report( UnexpectedResultException exp ) {
try {
System.out.println("serializeJavaObject : "+exp.type.serializeJavaObject(jo,DummyContextProvider.theInstance) );
} catch( Exception e ) {
- System.out.println("serializeJavaObject : "+e );
+ System.out.println("serializeJavaObject : "+e );
}
if(o!=null)
@@ -111,7 +113,7 @@ public boolean report( UnexpectedResultException exp ) {
// do it again (for trace purpose)
exp.type.isValid(exp.testInstance,DummyContextProvider.theInstance);
-
+ Assert.fail("ErrorReported!");
return false;
}
@@ -128,7 +130,7 @@ public boolean reportTestCaseError( XSDatatype baseType, TypeIncubator incubator
}
catch( Exception ee ) { ; }
*/
-
+ Assert.fail("TestCaseErrorReported!");
return false;
}
}
diff --git a/xsdlib/src/test/resources/com/sun/msv/datatype/xsd/conformance/DataTypeTest.xml b/xsdlib/src/test/resources/com/sun/msv/datatype/xsd/conformance/DataTypeTest.xml
index bff736a9..34eba666 100644
--- a/xsdlib/src/test/resources/com/sun/msv/datatype/xsd/conformance/DataTypeTest.xml
+++ b/xsdlib/src/test/resources/com/sun/msv/datatype/xsd/conformance/DataTypeTest.xml
@@ -213,7 +213,16 @@
-
+
+
+
+
@@ -263,18 +272,18 @@
2001-01-01T00:00:00+14:00
- 9999999999999999999999999-05-13T02:14:00Z
2001-01-01T05:12:13.0000000000000000000000000000000000000000000001
- oooooo oo
+ oooooo o
-
+
+ 9999999999999999999999999-05-13T02:14:00Z
0000-01-01T12:12:12Z
- 1999-02-29T10:00:00Z
+
@@ -373,9 +382,9 @@
- --00--
+
--1--
- --13--
+
5
@@ -383,10 +392,10 @@
--03--(GMT)
--03--(+08:00)
--03--+1:00
- --03--+15:00
+
--03--+12
--03--08:00
- --03---14:01
+
@@ -446,8 +455,8 @@
ABCX
DEFG52==
HIJKL1x=
- AB))((==
52==
+ 5
2
= =
ooooo
@@ -469,6 +478,13 @@
tr===
onp
1qb==
+
+ AB))((==
+ AB==#@!
+ #!@AB==
+
+ AB==A
+ AB=A=
@@ -609,7 +625,7 @@
-
+
@@ -619,7 +635,7 @@
-
+
@@ -679,7 +695,7 @@
-
+
@@ -689,9 +705,9 @@
-
+
-
+
@@ -714,14 +730,15 @@
-
- -999999999999999999999999999999999999999999999999999999999999999999Z
- -10000
+
+
+
+ 10000
-0852+02:00
- -0312
+ 10312
-0019Z
- -0002
+ 10002
-0001-09:00
0001
0001Z
@@ -737,29 +754,29 @@
12555+09:00
99999999999999999999+05:00
- 999999999999999999999999999999999999999999999999999999999999999999
+
- ooooo oooooooo ooooo oo
+ oooo oooooooo ooooo o
-
-
+
+
-
-
+
+
- 0000
- 0000Z
- 0000+08:00
- -0000
- 00000000
- -000000
+
+
+
+
+
+
99
@@ -786,11 +803,11 @@
(1999)
1999:
1999-
- 01999
+
-
+
-
+
-0013-08-31
-0001-12-31
0001-01-01
@@ -871,7 +888,7 @@
2000/05/05
2000-01-01 Z +05:00
-
+
true
@@ -897,7 +914,7 @@
-
+
-9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
-123104809034590906573845
-9223372036854775809
@@ -1032,9 +1049,9 @@
#x11
-1E4
-
+
-
+
-INF
-999999999999999999999999999999999999999999999999999999999999999e99999999999999999999999999999999
-1.79769313486231570999999999999999999999999999e+308
@@ -1086,5 +1103,5 @@
1e2.5
0x123
-
-
\ No newline at end of file
+
+