Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -835,24 +835,33 @@ Authors:
<include name="schema/config/IgnoreXSIType_A_C_Test.class"/>
<include name="schema/config/IgnoreXSIType_C_A_Test.class"/>
<include name="schema/config/RootSimpleTypeDefinitionTest.class"/>
<include name="schema/config/RootTypeDefinitionTest.class"/>
<include name="schema/config/UseGrammarPoolOnly_False_Test.class"/>
<!-- These tests are failing. Fix them.
<include name="schema/config/IgnoreXSIType_C_AC_Test.class"/>
<include name="schema/config/IgnoreXSIType_C_CA_Test.class"/>
<include name="schema/config/IgnoreXSIType_C_C_Test.class"/>
<include name="schema/config/SurrogatePairLengthTest.class"/>
<include name="schema/config/UseGrammarPoolOnly_True_Test.class"/>
<include name="schema/config/UnparsedEntityCheckingTest.class"/>
-->
<include name="schema/Test.class"/>
<include name="schema/config/RootTypeDefinitionTest.class"/>
<include name="schema/config/UseGrammarPoolOnly_False_Test.class"/>
<!-- These tests are failing. Fix them.
<include name="schema/config/IgnoreXSIType_C_AC_Test.class"/>
<include name="schema/config/IgnoreXSIType_C_CA_Test.class"/>
<include name="schema/config/IgnoreXSIType_C_C_Test.class"/>
<include name="schema/config/UseGrammarPoolOnly_True_Test.class"/>
<include name="schema/config/UnparsedEntityCheckingTest.class"/>
-->
<include name="schema/Test.class"/>
<include name="jaxp/JAXPSpecTest.class"/>
<include name="dom/ids/Test.class"/>
</fileset>
</batchtest>
</fileset>
</batchtest>


<formatter type="brief" usefile="false"/>
<formatter type="brief" usefile="false"/>
</junit>

<junit fork="yes"
haltonfailure="no"
haltonerror="yes"
failureproperty="test.failed"
errorproperty="test.failed"
showoutput="yes">
<classpath refid="test.classpath"/>
<test name="schema.config.SurrogatePairLengthTest" todir="test-reports"/>
<formatter type="brief" usefile="false"/>
</junit>
<fail if="test.failed" message="JUnit tests failed! Check the output above."/>

Expand Down
60 changes: 33 additions & 27 deletions tests/schema/config/SurrogatePairLengthTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package schema.config;

import junit.framework.Assert;

import org.apache.xerces.xs.ElementPSVI;
import org.apache.xerces.xs.ItemPSVI;

Expand All @@ -27,56 +25,64 @@
*/
public class SurrogatePairLengthTest extends BaseTest {

// Can only test when the property is set
static {
System.setProperty("org.apache.xerces.impl.dv.xs.useCodePointCountForStringLength", "true");
private String originalProperty;

protected void setUp() throws Exception {
originalProperty = System.getProperty(
"org.apache.xerces.impl.dv.xs.useCodePointCountForStringLength");
System.setProperty(
"org.apache.xerces.impl.dv.xs.useCodePointCountForStringLength", "true");
super.setUp();
}

protected void tearDown() throws Exception {
if (originalProperty != null) {
System.setProperty(
"org.apache.xerces.impl.dv.xs.useCodePointCountForStringLength",
originalProperty);
} else {
System.clearProperty(
"org.apache.xerces.impl.dv.xs.useCodePointCountForStringLength");
}
super.tearDown();
}

private static final String LENGTH_ERROR = "cvc-length-valid";


protected String getXMLDocument() {
return "surrogate.xml";
}

protected String getSchemaFile() {
return "surrogate.xsd";
}

protected String[] getRelevantErrorIDs() {
return new String[] { LENGTH_ERROR };
return new String[] { "cvc-length-valid" };
}

public SurrogatePairLengthTest(String name) {
super(name);
}

// Can only test when the property is set
public void testSetTrue() {
try {
validateDocument();
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Validation failed: " + e.getMessage());
}


public void testSetTrue() throws Exception {
validateDocument();
checkValidResult();
}

private void checkValidResult() {
assertNoError(LENGTH_ERROR);
assertNoError("cvc-length-valid");

assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
.getValidationAttempted());
assertElementName("root", fRootNode.getElementDeclaration().getName());

ElementPSVI child = super.getChild(1);
assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
.getValidationAttempted());
assertElementName("e1", child.getElementDeclaration().getName());
assertTypeName("length", child.getTypeDefinition().getName());

child = super.getChild(2);
assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
Expand Down
Loading