Skip to content
43 changes: 26 additions & 17 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,12 @@ Authors:

<batchtest fork="yes" todir="test-reports">
<fileset dir="${build.dir}/classes">
<include name="dom/DTest.class"/>
<include name="dom/DTest.class"/>
<include name="dom/ids/Test.class"/>
<include name="dom/traversal/*Test.class"/>
<include name="dom/range/TestCompare.class"/>
<include name="idc/IDConstraintTests.class"/>
<include name="idc/IDConstraintTests.class"/>
<include name="schema/Test.class"/>
<include name="schema/annotations/*Test.class"/>
<include name="schema/config/BasicTest.class"/>
<include name="schema/config/FeaturePropagationTest.class"/>
Expand All @@ -837,23 +839,30 @@ Authors:
<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="xinclude/Test.class"/>
<include name="schema/Test.class"/>
<include name="jaxp/JAXPSpecTest.class"/>
<include name="dom/ids/Test.class"/>
</fileset>
<include name="jaxp/JAXPSpecTest.class"/>
<include name="xinclude/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"/>
-->
</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