-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a reproducer for #189 'Undefined ID' not thrown when validating w…
…ith SimpleNsStreamWriter
- Loading branch information
Showing
3 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package failing; | ||
|
||
import javax.xml.stream.*; | ||
|
||
import org.codehaus.stax2.validation.*; | ||
|
||
import wstxtest.vstream.BaseValidationTest; | ||
|
||
/** | ||
* A reproducer for https://github.com/FasterXML/woodstox/issues/189 | ||
* Move to {@link wstxtest.vstream.TestRelaxNG} once fixed. | ||
*/ | ||
public class TestRelaxNG189 | ||
extends BaseValidationTest | ||
{ | ||
|
||
/** | ||
* Test case for testing handling ID/IDREF/IDREF attributes, using | ||
* schema datatype library. | ||
*/ | ||
public void testSimpleIdAttrsWriter() | ||
throws XMLStreamException | ||
{ | ||
final String schemaDef = | ||
"<element xmlns='http://relaxng.org/ns/structure/1.0'" | ||
+" datatypeLibrary='http://www.w3.org/2001/XMLSchema-datatypes' name='root'>\n" | ||
+" <oneOrMore>\n" | ||
+" <element name='leaf'>\n" | ||
+" <attribute name='id'><data type='ID' /></attribute>\n" | ||
+" <optional>\n" | ||
+" <attribute name='ref'><data type='IDREF' /></attribute>\n" | ||
+" </optional>\n" | ||
+" <optional>\n" | ||
+" <attribute name='refs'><data type='IDREFS' /></attribute>\n" | ||
+" </optional>\n" | ||
+" </element>\n" | ||
+" </oneOrMore>\n" | ||
+"</element>" | ||
; | ||
|
||
XMLValidationSchema schema = parseRngSchema(schemaDef); | ||
|
||
String XML; | ||
|
||
// And then invalid one, with dangling ref | ||
XML = "<root>" | ||
+" <leaf id='a' ref='second' />\n" | ||
+"</root>" | ||
; | ||
verifyFailure(XML, schema, "reference to undefined id", | ||
"Undefined ID", true, false, true); | ||
|
||
// and another one with some of refs undefined | ||
XML = "<root>" | ||
+" <leaf refs='this other' id='this' />\n" | ||
+"</root>" | ||
; | ||
verifyFailure(XML, schema, "reference to undefined id", | ||
"Undefined ID", true, false, true); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package failing; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
|
||
import org.codehaus.stax2.validation.XMLValidationSchema; | ||
|
||
import wstxtest.msv.TestW3CSchema; | ||
|
||
/** | ||
*/ | ||
public class TestW3CSchema189 | ||
extends TestW3CSchema | ||
{ | ||
|
||
/** | ||
* A reproducer for https://github.com/FasterXML/woodstox/issues/189 | ||
* Move to {@link TestW3CSchema} once fixed. | ||
*/ | ||
public void testSimpleNonNsUndefinedIdWriter189() throws XMLStreamException | ||
{ | ||
XMLValidationSchema schema = parseW3CSchema(SIMPLE_NON_NS_SCHEMA); | ||
String XML = "<personnel><person id='a1'>" | ||
+ "<name><family>F</family><given>G</given>" | ||
+ "</name><link manager='m3' /></person></personnel>"; | ||
verifyFailure(XML, schema, "undefined referenced id ('m3')", | ||
"Undefined ID 'm3'", true, false, true); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters