elharo commented on code in PR #113:
URL: https://github.com/apache/xerces-j/pull/113#discussion_r3543998914
##########
tests/xinclude/Test.java:
##########
@@ -39,219 +37,79 @@
import xni.Writer;
-/**
- * Tests for XInclude implementation.
- * Use -f option to see the error message log
- * @author Peter McCracken, IBM
Review Comment:
You can keep the @author tag
##########
tests/xinclude/Test.java:
##########
@@ -468,36 +221,31 @@ private String stripUserDir(StringBuffer buf) {
String str = getPathWithoutEscapes(buf.toString());
int start = 0, end = 0;
- // strip ones in URI form
while ((start = str.indexOf(userURI, start)) != -1) {
end = start + userURI.length();
- // we add one, to get rid of the '/' after the user directory path
Review Comment:
This comment is useful and should be retained
##########
tests/xinclude/Test.java:
##########
@@ -468,36 +221,31 @@ private String stripUserDir(StringBuffer buf) {
String str = getPathWithoutEscapes(buf.toString());
int start = 0, end = 0;
- // strip ones in URI form
Review Comment:
This comment is useful and should be retained
##########
tests/xinclude/Test.java:
##########
@@ -39,219 +37,79 @@
import xni.Writer;
-/**
- * Tests for XInclude implementation.
- * Use -f option to see the error message log
- * @author Peter McCracken, IBM
- */
-public class Test implements XMLErrorHandler {
- /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
+public class Test extends TestCase implements XMLErrorHandler {
protected static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
-
- /** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
-
- /** Schema validation feature id
(http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
-
- /** Schema full checking feature id
(http://apache.org/xml/features/validation/schema-full-checking). */
protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
"http://apache.org/xml/features/validation/schema-full-checking";
-
- /** Property identifier: error handler. */
protected static final String ERROR_HANDLER =
"http://apache.org/xml/properties/internal/error-handler";
- // this array contains whether the test number NN (contained in file
testNN.xml)
- // is meant to be a pass or fail test
- // true means the test should pass
private static final int NUM_TESTS = 41;
private static final boolean[] TEST_RESULTS = new boolean[] {
- // one value for each test
- true, true, true, true, true, true, false, true, false, true, // 10
- false, false, false, false, true, true, true, false, true, true, // 20
- true, false, true, false, false, false, true, true, false, true, // 30
- true, false, true, true, true, true, true, true, false, false, // 40
- true, };
-
- private String fOutputDirectory = "tests/xinclude/output";
-
- public static void main(String[] args) {
- Test tester = new Test();
- boolean testsSpecified = false;
- for (int i = 0; i < args.length; i++) {
- if (args[i].charAt(0) == '-' && args[i].length() > 1) {
- switch (args[i].charAt(1)) {
- case 'g' :
- tester.fGenerate = true;
- if (args.length > i + 1
- && args[i + 1].charAt(0) != '-') {
- try {
- Integer.parseInt(args[i + 1]);
- // if it parses as an integer, we'll assume
it's a test number
- tester.setLogFile(System.err);
- }
- catch (NumberFormatException e) {
- tester.fOutputDirectory = args[++i];
- }
- }
- break;
- case 'h' :
- printUsage();
- return;
- case 'f' :
- if (args.length > i + 1
- && args[i + 1].charAt(0) != '-') {
- try {
- Integer.parseInt(args[i + 1]);
- // if it parses as an integer, we'll assume
it's a test number
- tester.setLogFile(System.err);
- }
- catch (NumberFormatException e) {
- // if it doesn't parse as an integer,
- // we assume it's the log file name
- try {
- tester.setLogFile(
- new PrintStream(
- new FileOutputStream(args[++i])));
- }
- catch (IOException ioe) {
- System.err.println(
- "Couldn't open log file: " + args[i]);
- }
- }
- }
- else {
- tester.setLogFile(System.err);
- }
- break;
- default :
- System.err.println("Unrecognized option: " + args[i]);
- }
- }
- else {
- testsSpecified = true;
- tester.addTest(Integer.parseInt(args[i]));
- }
- }
-
- if (!testsSpecified) {
- for (int i = 1; i <= NUM_TESTS; i++) {
- tester.addTest(i);
- }
- }
-
- // Create output directory if it does not already exist.
- if (tester.fGenerate) {
- File outputDir = new File(tester.fOutputDirectory);
- if (!outputDir.exists()) {
- outputDir.mkdirs();
- }
- }
- tester.runTests();
- }
-
- private final PrintStream DEFAULT_LOG_STREAM =
- new PrintStream(new OutputStream() {
- public void write(int b) throws IOException {
- }
- });
+ true, true, true, true, true, true, false, true, false, true,
+ false, false, false, false, true, true, true, false, true, true,
+ true, false, true, false, false, false, true, true, false, true,
+ true, false, true, true, true, true, true, true, false, false,
+ true,
+ };
private Writer fWriter;
- private String fResults;
private PrintWriter fOutputWriter;
- private int[] fTests = new int[NUM_TESTS];
- private int fNumTests = 0;
- public boolean fGenerate;
- public PrintStream fLogStream;
- public Test() throws XNIException {
+ public Test(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
XMLParserConfiguration parserConfig = new
XIncludeParserConfiguration();
parserConfig.setFeature(NAMESPACES_FEATURE_ID, true);
parserConfig.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
parserConfig.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
fWriter = new Writer(parserConfig);
-
- // this has to be done AFTER fWriter is created
Review Comment:
This comment is useful and should be retained
##########
tests/xinclude/Test.java:
##########
@@ -468,36 +221,31 @@ private String stripUserDir(StringBuffer buf) {
String str = getPathWithoutEscapes(buf.toString());
int start = 0, end = 0;
- // strip ones in URI form
while ((start = str.indexOf(userURI, start)) != -1) {
end = start + userURI.length();
- // we add one, to get rid of the '/' after the user directory path
- str = str.substring(0, start) + str.substring(end+1);
+ str = str.substring(0, start) + str.substring(end + 1);
}
while ((start = str.indexOf(userDir, start)) != -1) {
end = start + userDir.length();
- // we add one, to get rid of the '/' after the user directory path
Review Comment:
This comment is useful and should be retained
##########
tests/xinclude/Test.java:
##########
@@ -39,219 +37,79 @@
import xni.Writer;
-/**
- * Tests for XInclude implementation.
- * Use -f option to see the error message log
- * @author Peter McCracken, IBM
- */
-public class Test implements XMLErrorHandler {
- /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
+public class Test extends TestCase implements XMLErrorHandler {
protected static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
-
- /** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
-
- /** Schema validation feature id
(http://apache.org/xml/features/validation/schema). */
protected static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
-
- /** Schema full checking feature id
(http://apache.org/xml/features/validation/schema-full-checking). */
protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
"http://apache.org/xml/features/validation/schema-full-checking";
-
- /** Property identifier: error handler. */
protected static final String ERROR_HANDLER =
"http://apache.org/xml/properties/internal/error-handler";
- // this array contains whether the test number NN (contained in file
testNN.xml)
Review Comment:
This comment is useful and should be retained
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]