summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2023-07-01 23:00:37 +0100
committerVictor Chang <vichang@google.com>2023-07-02 19:11:11 +0100
commitb2d8c03c6e25d086ebd88c9a5f77b592216eeda9 (patch)
treebf72daa9335c00d8949070fb17bcd68fb0c816cf
parent2283551ff10575045c6fc3eb00175f43819afa77 (diff)
downloadapache-xml-b2d8c03c6e25d086ebd88c9a5f77b592216eeda9.tar.gz
Run ApacheXML tests in CtsLibcoreTestCases
Adds @Test to test methods that are passing on Android. The other tests need further to build / run / pass on Android. {} blocks are added into a few files to fix the SuspiciousIndentation Errorprone errors Bug: 283931833 Test: atest CtsLibcoreTestCases:org.apache.qetest Change-Id: Id68283b134bb5ca4fab2a9e3107b5a5bd16fc1dd
-rw-r--r--Android.bp60
-rw-r--r--test/README.md28
-rw-r--r--test/README.version2
-rw-r--r--test/android_src/org/apache/test/android/AndroidFileUtils.java86
-rw-r--r--test/android_src/org/apache/test/android/TestLogger.java162
-rw-r--r--test/java/src/org/apache/qetest/FileBasedTest.java7
-rw-r--r--test/java/src/org/apache/qetest/QetestUtils.java8
-rw-r--r--test/java/src/org/apache/qetest/Reporter.java5
-rw-r--r--test/java/src/org/apache/qetest/dtm/TestDTMTrav.java35
-rw-r--r--test/java/src/org/apache/qetest/trax/ErrorListenerAPITest.java7
-rw-r--r--test/java/src/org/apache/qetest/trax/ErrorListenerTest.java7
-rw-r--r--test/java/src/org/apache/qetest/trax/ParameterTest.java7
-rw-r--r--test/java/src/org/apache/qetest/trax/TemplatesAPITest.java7
-rw-r--r--test/java/src/org/apache/qetest/trax/TransformerAPITest.java7
-rw-r--r--test/java/src/org/apache/qetest/trax/URIResolverTest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/OutputSettingsTest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/PrefixResolverAPITest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/ProgrammaticDOMTest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/SerializedStylesheetTest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/SystemIDResolverAPITest.java8
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/TestXPathAPI.java19
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/TraceListenerTest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/TransformStateTest.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/TransformStateTestlet.java7
-rw-r--r--test/java/src/org/apache/qetest/xalanj2/XalanDumper.java4
-rw-r--r--test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java6
-rw-r--r--test/trace-src/org/apache/xalan/trace/TraceManager.java3
27 files changed, 495 insertions, 29 deletions
diff --git a/Android.bp b/Android.bp
index 762b32d..9f2c596 100644
--- a/Android.bp
+++ b/Android.bp
@@ -85,3 +85,63 @@ java_library {
system_modules: "core-all-system-modules",
min_sdk_version: "31",
}
+
+java_library_static {
+ name: "apache-xml-tests",
+ visibility: [
+ "//libcore",
+ "//packages/modules/ArtPrebuilt",
+ ],
+ srcs: [
+ "test/android_src/**/*.java",
+ "test/java/src/**/*.java",
+ "test/tests/bugzilla/**/*.java",
+ "test/tests/extensions/java/**/*.java",
+ // org.apache.xalan.trace package in xalan-java has to be imported because
+ // the test version is 2.7.3 while the implementation version is 2_7_1.
+ "test/trace-src/org/apache/xalan/trace/**/*.java",
+ ],
+ exclude_srcs: [
+ // The following java files fail to build.
+ "test/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.java",
+ "test/java/src/org/apache/qetest/xsl/XSLTestAntTask.java",
+ "test/java/src/org/apache/qetest/xsl/XsltcTestsTask.java",
+ "test/java/src/org/apache/qetest/xslwrapper/XTWrapper.java",
+ "test/java/src/org/apache/qetest/xslwrapper/XsltcMainWrapper.java",
+ "test/tests/bugzilla/Bugzilla1110.java",
+ "test/tests/bugzilla/Bugzilla1288.java",
+ "test/tests/bugzilla/Bugzilla6181.java",
+ "test/tests/extensions/java/javaElem01.java",
+ "test/tests/extensions/java/javaSample4.java",
+ "test/java/src/org/apache/qetest/xalanj2/TraceListenerTest.java",
+ "test/java/src/org/apache/qetest/xslwrapper/XalanProcessWrapper.java",
+ "test/tests/bugzilla/BugzillaNodeInfo.java",
+ ],
+ java_resource_dirs: [
+ "test/tests",
+ "test/java/xdocs",
+ ],
+ // soong_zip doesn't accept this file, likely due to unescaped space characters.
+ exclude_java_resources: ["test/tests/conf-gold/output/Test 31 Gif.gif"],
+
+ errorprone: {
+ javacflags: [
+ "-Xep:MissingOverride:OFF",
+ "-Xep:LockOnBoxedPrimitive:WARN",
+ ],
+ },
+ static_libs: [
+ "apache-xml-jtidy-prebuilt",
+ ],
+ libs: [
+ "apache-xml",
+ "junit",
+ ],
+ sdk_version: "none",
+ system_modules: "core-all-system-modules",
+}
+
+java_import {
+ name: "apache-xml-jtidy-prebuilt",
+ jars: ["test/tools/jtidy-1.0.3.jar"],
+}
diff --git a/test/README.md b/test/README.md
new file mode 100644
index 0000000..cefe8b5
--- /dev/null
+++ b/test/README.md
@@ -0,0 +1,28 @@
+# Apache XML tests
+
+
+## The first version
+
+The apache XML version in AOSP is `2.7.1`. However, it's at least 16 years old.
+The `xalan-j_2_7_3-rc10` version of test sources is used because
+there wasn't a clear manual how to build the tests in 2.7.1,
+and many bugs are fixed.
+
+The first version was copied with the following command:
+
+```shell
+mkdir -p test/trace-src/org/apache/xalan/
+cp -R $REPO/xalan-java/src/org/apache/xalan/trace/ test/trace-src/org/apache/xalan/
+cp -R $REPO/xalan-test/java/ test/
+cp -R $REPO/xalan-test/tests/ test/
+cp -R $REPO/xalan-test/tools/ test/
+find test/java/ -type f -name "*.class" -delete # remove the unnecessary .class files
+```
+
+Note that org.apache.xalan.trace package in xalan-java
+has to be imported due to dependency from the tests.
+
+If the test sources needs to be updated from the upstream, try to
+1. Remove the test sources
+2. Re-run the above command.
+3. Re-apply all the patches found in the `git`. \ No newline at end of file
diff --git a/test/README.version b/test/README.version
new file mode 100644
index 0000000..28c2894
--- /dev/null
+++ b/test/README.version
@@ -0,0 +1,2 @@
+URL: https://github.com/apache/xalan-test
+version: xalan-j_2_7_3-rc10
diff --git a/test/android_src/org/apache/test/android/AndroidFileUtils.java b/test/android_src/org/apache/test/android/AndroidFileUtils.java
new file mode 100644
index 0000000..76c1ec2
--- /dev/null
+++ b/test/android_src/org/apache/test/android/AndroidFileUtils.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.test.android;
+
+import org.junit.Assert;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class AndroidFileUtils {
+
+ private static final Path TEMP_DIR;
+
+ static {
+ try {
+ TEMP_DIR = Files.createTempDirectory(AndroidFileUtils.class.getName());
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ /**
+ * Returns the URL string to the jar resource for a given input file path.
+ * @return null if the input file is not found.
+ */
+ public static URL getInputFileUrl(String path) {
+ Path p = Path.of(path);
+ // Ignore the parts for the current directory.
+ while (true) {
+ if (p.getNameCount() == 0) {
+ return null;
+ }
+ String first = p.getName(0).toString();
+ if (!first.isEmpty() && !first.equals(".")) {
+ break;
+ }
+ p = p.subpath(1, p.getNameCount());
+ }
+ String first = p.getName(0).toString();
+ if (!first.equals("inputs")) {
+ return null;
+ }
+ p = p.subpath(1, p.getNameCount());
+ p = Path.of("api", p.toString());
+ return AndroidFileUtils.class.getClassLoader().getResource(p.toString());
+ }
+
+ /**
+ * Returns the URL string to the jar resource for a given input file path.
+ * @return null if the input file is not found.
+ */
+ public static String getInputFileUrlString(String path) {
+ URL url = getInputFileUrl(path);
+ return url != null ? url.toExternalForm() : null;
+ }
+ /**
+ * Return a File object to the path, and created all directories along the path.
+ * @throws AssertionError if the directories can't be created.
+ */
+ public static File getOutputFile(String relativePath) {
+ File target = TEMP_DIR.resolve(relativePath).toAbsolutePath().toFile();
+ File parent = target.getParentFile();
+ if (!parent.exists()) {
+ Assert.assertTrue(parent.mkdirs());
+ }
+ return target;
+ }
+}
diff --git a/test/android_src/org/apache/test/android/TestLogger.java b/test/android_src/org/apache/test/android/TestLogger.java
new file mode 100644
index 0000000..a74bf9a
--- /dev/null
+++ b/test/android_src/org/apache/test/android/TestLogger.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.test.android;
+
+import java.util.Hashtable;
+import java.util.Properties;
+
+/**
+ * Logs messages into Android's logcat and throws any reported Throwable directly, because
+ * we run the tests as JUnit tests on Android.
+ */
+public class TestLogger implements org.apache.qetest.Logger {
+ private Properties prop = new Properties();
+
+ @Override
+ public String getDescription() {
+ return "Android test logger printing information into logcat.";
+ }
+
+ @Override
+ public String[][] getParameterInfo() {
+ return new String[0][];
+ }
+
+ @Override
+ public Properties getProperties() {
+ return prop;
+ }
+
+ @Override
+ public void setProperties(Properties p) {
+ prop = (Properties) p.clone();
+ }
+
+ @Override
+ public boolean initialize(Properties p) {
+ setProperties(p);
+
+ return true;
+ }
+
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
+ public void flush() {}
+
+ @Override
+ public void close() {}
+
+ @Override
+ public void testFileInit(String name, String comment) {
+ logMsg(INFOMSG, "testFileInit: " + name + " - comment: " + comment);
+ }
+
+ @Override
+ public void testFileClose(String msg, String result) {
+ logMsg(INFOMSG, "testFileClose" + msg + " - result: " + result);
+ }
+
+ @Override
+ public void testCaseInit(String comment) {
+ logMsg(INFOMSG, comment);
+ }
+
+ @Override
+ public void testCaseClose(String msg, String result) {
+ logMsg(CRITICALMSG, "testCaseClose" + msg + " - result: " + result);
+ }
+
+ @Override
+ public void logMsg(int level, String msg) {
+ switch (level) {
+ case ERRORMSG, FAILSONLY -> System.logE(msg);
+ case CRITICALMSG, WARNINGMSG -> System.logW(msg);
+ default -> System.logI(msg);
+ }
+ }
+
+ @Override
+ public void logArbitrary(int level, String msg) {
+ logMsg(level, msg);
+ }
+
+ @Override
+ public void logStatistic(int level, long lVal, double dVal, String msg) {
+ logMsg(level, "logStatistic(lVal: " + lVal + ", dVal:" + dVal + "): " + msg);
+ }
+
+ @Override
+ public void logThrowable(int level, Throwable throwable, String msg) {
+ logMsg(level, msg);
+ throw new AssertionError(msg, throwable);
+ }
+
+ @Override
+ public void logElement(int level, String element, Hashtable attrs, Object msg) {
+ logMsg(level, msg + " - element: " + element + "\nAttributes below:\n" + attrs);
+
+ }
+
+ @Override
+ public void logHashtable(int level, Hashtable hash, String msg) {
+ logMsg(level, msg + "\nTable below:\n" + hash);
+ }
+
+ @Override
+ public void checkPass(String comment) {
+ logMsg(INFOMSG, "checkPass: " + comment);
+ }
+
+ @Override
+ public void checkAmbiguous(String comment) {
+ logMsg(INFOMSG, "checkAmbiguous: " + comment);
+ }
+
+ @Override
+ public void checkFail(String comment) {
+ logMsg(FAILSONLY, "checkFail: " + comment);
+ }
+
+ @Override
+ public void checkErr(String comment) {
+ logMsg(ERRORMSG, "checkErr: " + comment);
+ }
+
+ @Override
+ public void checkPass(String comment, String id) {
+ logMsg(INFOMSG, "checkPass (" + id + "): " + comment);
+ }
+
+ @Override
+ public void checkAmbiguous(String comment, String id) {
+ logMsg(INFOMSG, "checkAmbiguous (" + id + "): " + comment);
+ }
+
+ @Override
+ public void checkFail(String comment, String id) {
+ logMsg(FAILSONLY, "checkFail (" + id + "): " + comment);
+ }
+
+ @Override
+ public void checkErr(String comment, String id) {
+ logMsg(ERRORMSG, "checkErr (" + id + "): " + comment);
+ }
+}
diff --git a/test/java/src/org/apache/qetest/FileBasedTest.java b/test/java/src/org/apache/qetest/FileBasedTest.java
index 8c4d911..368f5e3 100644
--- a/test/java/src/org/apache/qetest/FileBasedTest.java
+++ b/test/java/src/org/apache/qetest/FileBasedTest.java
@@ -26,6 +26,8 @@
*/
package org.apache.qetest;
+import org.apache.test.android.AndroidFileUtils;
+
import java.io.File;
import java.io.FileInputStream;
import java.util.Enumeration;
@@ -125,7 +127,10 @@ public class FileBasedTest extends TestImpl
public static final String OPT_OUTPUTDIR = "outputDir";
/** Field outputDir:holds String denoting local path for outputs. */
- protected String outputDir = "." + File.separator + "outputs";
+ // Android-changed: The original directory isn't writeable on Android.
+ // protected String outputDir = "." + File.separator + "outputs";
+ protected String outputDir = AndroidFileUtils.getOutputFile("." + File.separator + "outputs")
+ .getPath();
/**
* Parameter: Where should get "gold" pre-validated XML files?
diff --git a/test/java/src/org/apache/qetest/QetestUtils.java b/test/java/src/org/apache/qetest/QetestUtils.java
index cf42e22..b13bc17 100644
--- a/test/java/src/org/apache/qetest/QetestUtils.java
+++ b/test/java/src/org/apache/qetest/QetestUtils.java
@@ -21,6 +21,8 @@
package org.apache.qetest;
+import org.apache.test.android.AndroidFileUtils;
+
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -70,6 +72,12 @@ public abstract class QetestUtils
if (isCommonURL(filename))
return filename;
+ // Android-added: Look up the file in the java resources.
+ String androidUrl = AndroidFileUtils.getInputFileUrlString(filename);
+ if (androidUrl != null) {
+ return androidUrl;
+ }
+
File f = new File(filename);
String tmp = null;
try
diff --git a/test/java/src/org/apache/qetest/Reporter.java b/test/java/src/org/apache/qetest/Reporter.java
index 34efd06..2073726 100644
--- a/test/java/src/org/apache/qetest/Reporter.java
+++ b/test/java/src/org/apache/qetest/Reporter.java
@@ -26,6 +26,8 @@
*/
package org.apache.qetest;
+import org.apache.test.android.TestLogger;
+
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@@ -73,6 +75,9 @@ public class Reporter implements Logger
public Reporter(Properties p)
{
ready = initialize(p);
+
+ // Android-changed: Hard-coded AndroidLogger here. Otherwise, all test failures are silent.
+ addLogger(TestLogger.class.getName(), null);
}
/** If we're ready to start outputting yet. */
diff --git a/test/java/src/org/apache/qetest/dtm/TestDTMTrav.java b/test/java/src/org/apache/qetest/dtm/TestDTMTrav.java
index 3711c3d..f417403 100644
--- a/test/java/src/org/apache/qetest/dtm/TestDTMTrav.java
+++ b/test/java/src/org/apache/qetest/dtm/TestDTMTrav.java
@@ -307,9 +307,9 @@ public class TestDTMTrav extends FileBasedTest
// Traverse the axis and write node info to output file
for (int atNode = at.first(lastNode); DTM.NULL != atNode;
- atNode = at.next(lastNode, atNode))
- buf.append(getNodeInfo(dtm, atNode, " "));
-
+ atNode = at.next(lastNode, atNode)) {
+ buf.append(getNodeInfo(dtm, atNode, " "));
+ }
// Write results and close output file.
writeClose(fos, buf);
@@ -341,9 +341,9 @@ public class TestDTMTrav extends FileBasedTest
// Traverse the axis and write node info to output file
for (int atNode = at.first(lastNode); DTM.NULL != atNode;
- atNode = at.next(lastNode, atNode))
- buf.append(getNodeInfo(dtm, atNode, " "));
-
+ atNode = at.next(lastNode, atNode)) {
+ buf.append(getNodeInfo(dtm, atNode, " "));
+ }
// Write results and close output file.
writeClose(fos, buf);
@@ -376,9 +376,9 @@ public class TestDTMTrav extends FileBasedTest
// Traverse the axis and write node info to output file
for (int atNode = at.first(lastNode); DTM.NULL != atNode;
- atNode = at.next(lastNode, atNode))
- buf.append(getNodeInfo(dtm, atNode, " "));
-
+ atNode = at.next(lastNode, atNode)) {
+ buf.append(getNodeInfo(dtm, atNode, " "));
+ }
// Write results and close output file.
writeClose(fos, buf);
@@ -411,8 +411,9 @@ public class TestDTMTrav extends FileBasedTest
// Traverse the axis and write node info to output file
for (int atNode = at.first(lastNode); DTM.NULL != atNode;
- atNode = at.next(lastNode, atNode))
- buf.append(getNodeInfo(dtm, atNode, " "));
+ atNode = at.next(lastNode, atNode)) {
+ buf.append(getNodeInfo(dtm, atNode, " "));
+ }
// Write results and close output file.
writeClose(fos, buf);
@@ -446,9 +447,9 @@ public class TestDTMTrav extends FileBasedTest
// Traverse the axis and write node info to output file
for (int atNode = at.first(ANode); DTM.NULL != atNode;
- atNode = at.next(ANode, atNode))
- buf.append(getNodeInfo(dtm, atNode, " "));
-
+ atNode = at.next(ANode, atNode)) {
+ buf.append(getNodeInfo(dtm, atNode, " "));
+ }
// Write results and close output file.
writeClose(fos, buf);
@@ -515,9 +516,9 @@ public class TestDTMTrav extends FileBasedTest
// Traverse the axis and write node info to output file
for (int atNode = at.first(ANode); DTM.NULL != atNode;
- atNode = at.next(ANode, atNode))
- buf.append(getNodeInfo(dtm, atNode, " "));
-
+ atNode = at.next(ANode, atNode)) {
+ buf.append(getNodeInfo(dtm, atNode, " "));
+ }
// Write results and close output file.
writeClose(fos, buf);
diff --git a/test/java/src/org/apache/qetest/trax/ErrorListenerAPITest.java b/test/java/src/org/apache/qetest/trax/ErrorListenerAPITest.java
index 1476ef0..1c80f05 100644
--- a/test/java/src/org/apache/qetest/trax/ErrorListenerAPITest.java
+++ b/test/java/src/org/apache/qetest/trax/ErrorListenerAPITest.java
@@ -32,6 +32,7 @@ import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
import org.apache.qetest.FileBasedTest;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -177,4 +178,10 @@ public class ErrorListenerAPITest extends FileBasedTest
ErrorListenerAPITest app = new ErrorListenerAPITest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/trax/ErrorListenerTest.java b/test/java/src/org/apache/qetest/trax/ErrorListenerTest.java
index dfe40d8..e5a6789 100644
--- a/test/java/src/org/apache/qetest/trax/ErrorListenerTest.java
+++ b/test/java/src/org/apache/qetest/trax/ErrorListenerTest.java
@@ -49,6 +49,7 @@ import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.LoggingSAXErrorHandler;
import org.apache.qetest.xsl.XSLTestfileInfo;
+import org.junit.Test;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -433,4 +434,10 @@ public class ErrorListenerTest extends FileBasedTest
ErrorListenerTest app = new ErrorListenerTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/trax/ParameterTest.java b/test/java/src/org/apache/qetest/trax/ParameterTest.java
index 0283516..14d8a2f 100644
--- a/test/java/src/org/apache/qetest/trax/ParameterTest.java
+++ b/test/java/src/org/apache/qetest/trax/ParameterTest.java
@@ -46,6 +46,7 @@ import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.XSLTestfileInfo;
import org.apache.xml.utils.DefaultErrorHandler;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -577,4 +578,10 @@ public class ParameterTest extends FileBasedTest
ParameterTest app = new ParameterTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/trax/TemplatesAPITest.java b/test/java/src/org/apache/qetest/trax/TemplatesAPITest.java
index 61fc581..1e8d21c 100644
--- a/test/java/src/org/apache/qetest/trax/TemplatesAPITest.java
+++ b/test/java/src/org/apache/qetest/trax/TemplatesAPITest.java
@@ -41,6 +41,7 @@ import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.XSLTestfileInfo;
import org.apache.xml.utils.DefaultErrorHandler;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -265,4 +266,10 @@ public class TemplatesAPITest extends FileBasedTest
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/trax/TransformerAPITest.java b/test/java/src/org/apache/qetest/trax/TransformerAPITest.java
index fa0cf36..48acc0c 100644
--- a/test/java/src/org/apache/qetest/trax/TransformerAPITest.java
+++ b/test/java/src/org/apache/qetest/trax/TransformerAPITest.java
@@ -46,6 +46,7 @@ import org.apache.qetest.QetestUtils;
import org.apache.qetest.TestletImpl;
import org.apache.qetest.xsl.XSLTestfileInfo;
import org.apache.xml.utils.DefaultErrorHandler;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -1312,4 +1313,10 @@ public class TransformerAPITest extends FileBasedTest
TransformerAPITest app = new TransformerAPITest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/trax/URIResolverTest.java b/test/java/src/org/apache/qetest/trax/URIResolverTest.java
index fe4053d..be4d346 100644
--- a/test/java/src/org/apache/qetest/trax/URIResolverTest.java
+++ b/test/java/src/org/apache/qetest/trax/URIResolverTest.java
@@ -40,6 +40,7 @@ import org.apache.qetest.Logger;
import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.XSLTestfileInfo;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -215,4 +216,10 @@ public class URIResolverTest extends FileBasedTest
URIResolverTest app = new URIResolverTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/OutputSettingsTest.java b/test/java/src/org/apache/qetest/xalanj2/OutputSettingsTest.java
index 1c8bdbf..0f026f0 100644
--- a/test/java/src/org/apache/qetest/xalanj2/OutputSettingsTest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/OutputSettingsTest.java
@@ -41,6 +41,7 @@ import org.apache.qetest.Logger;
import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.XSLTestfileInfo;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -251,4 +252,10 @@ public class OutputSettingsTest extends FileBasedTest
OutputSettingsTest app = new OutputSettingsTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/PrefixResolverAPITest.java b/test/java/src/org/apache/qetest/xalanj2/PrefixResolverAPITest.java
index b1ced99..57b725e 100644
--- a/test/java/src/org/apache/qetest/xalanj2/PrefixResolverAPITest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/PrefixResolverAPITest.java
@@ -29,6 +29,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.qetest.FileBasedTest;
import org.apache.xml.utils.PrefixResolver;
import org.apache.xml.utils.PrefixResolverDefault;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -185,4 +186,10 @@ public class PrefixResolverAPITest extends FileBasedTest
PrefixResolverAPITest app = new PrefixResolverAPITest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/ProgrammaticDOMTest.java b/test/java/src/org/apache/qetest/xalanj2/ProgrammaticDOMTest.java
index 0d6e4d6..963040b 100644
--- a/test/java/src/org/apache/qetest/xalanj2/ProgrammaticDOMTest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/ProgrammaticDOMTest.java
@@ -43,6 +43,7 @@ import org.apache.qetest.Logger;
import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.XSLTestfileInfo;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
@@ -510,4 +511,10 @@ public class ProgrammaticDOMTest extends FileBasedTest
ProgrammaticDOMTest app = new ProgrammaticDOMTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/SerializedStylesheetTest.java b/test/java/src/org/apache/qetest/xalanj2/SerializedStylesheetTest.java
index 428d0e9..3594ffd 100644
--- a/test/java/src/org/apache/qetest/xalanj2/SerializedStylesheetTest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/SerializedStylesheetTest.java
@@ -44,6 +44,7 @@ import org.apache.qetest.Logger;
import org.apache.qetest.OutputNameManager;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.xsl.XSLTestfileInfo;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -222,4 +223,10 @@ public class SerializedStylesheetTest extends FileBasedTest
SerializedStylesheetTest app = new SerializedStylesheetTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/SystemIDResolverAPITest.java b/test/java/src/org/apache/qetest/xalanj2/SystemIDResolverAPITest.java
index f4b9d96..2a4ec78 100644
--- a/test/java/src/org/apache/qetest/xalanj2/SystemIDResolverAPITest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/SystemIDResolverAPITest.java
@@ -22,6 +22,8 @@ package org.apache.qetest.xalanj2;
import org.apache.qetest.FileBasedTest;
import org.apache.xml.utils.SystemIDResolver;
+import org.junit.Test;
+
import java.nio.file.Paths;
/**
@@ -179,4 +181,10 @@ public class SystemIDResolverAPITest extends FileBasedTest
SystemIDResolverAPITest app = new SystemIDResolverAPITest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/TestXPathAPI.java b/test/java/src/org/apache/qetest/xalanj2/TestXPathAPI.java
index ff9bd85..1901b26 100644
--- a/test/java/src/org/apache/qetest/xalanj2/TestXPathAPI.java
+++ b/test/java/src/org/apache/qetest/xalanj2/TestXPathAPI.java
@@ -42,12 +42,14 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.qetest.FileBasedTest;
import org.apache.qetest.OutputNameManager;
import org.apache.qetest.xsl.XSLTestfileInfo;
+import org.apache.test.android.AndroidFileUtils;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMManager;
import org.apache.xml.utils.PrefixResolverDefault;
import org.apache.xpath.XPathAPI;
import org.apache.xpath.objects.XObject;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Node;
@@ -355,7 +357,9 @@ public class TestXPathAPI extends FileBasedTest
// Set up a DOM tree to query.
reporter.logInfoMsg("Parsing input file "+filename);
- InputSource in = new InputSource(new FileInputStream(filename));
+ // Android-added: Look up the file in the java resources.
+ // InputSource in = new InputSource(new FileInputStream(filename));
+ InputSource in = new InputSource(AndroidFileUtils.getInputFileUrl(filename).openStream());
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
Document doc = dfactory.newDocumentBuilder().parse(in);
@@ -430,7 +434,9 @@ public class TestXPathAPI extends FileBasedTest
reporter.logInfoMsg("Parsing input file "+filename);
// Set up a DOM tree to query.
- InputSource in = new InputSource(new FileInputStream(filename));
+ // Android-added: Look up the file in the java resources.
+ // InputSource in = new InputSource(new FileInputStream(filename));
+ InputSource in = new InputSource(AndroidFileUtils.getInputFileUrl(filename).openStream());
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
Document doc = dfactory.newDocumentBuilder().parse(in);
return doc;
@@ -456,7 +462,12 @@ public class TestXPathAPI extends FileBasedTest
{
TestXPathAPI app = new TestXPathAPI();
app.doMain(args);
- }
-
+ }
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
} // end of class ApplyXPath
diff --git a/test/java/src/org/apache/qetest/xalanj2/TraceListenerTest.java b/test/java/src/org/apache/qetest/xalanj2/TraceListenerTest.java
index e8c88c7..b468e80 100644
--- a/test/java/src/org/apache/qetest/xalanj2/TraceListenerTest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/TraceListenerTest.java
@@ -41,6 +41,7 @@ import org.apache.xalan.trace.TraceListener;
import org.apache.xalan.trace.TraceManager;
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xalan.transformer.XalanProperties;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -478,4 +479,10 @@ public class TraceListenerTest extends FileBasedTest
TraceListenerTest app = new TraceListenerTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/TransformStateTest.java b/test/java/src/org/apache/qetest/xalanj2/TransformStateTest.java
index 9965373..3b6c31a 100644
--- a/test/java/src/org/apache/qetest/xalanj2/TransformStateTest.java
+++ b/test/java/src/org/apache/qetest/xalanj2/TransformStateTest.java
@@ -32,6 +32,7 @@ import java.util.Vector;
import org.apache.qetest.FileBasedTest;
import org.apache.qetest.Logger;
+import org.junit.Test;
//-------------------------------------------------------------------------
@@ -296,4 +297,10 @@ public class TransformStateTest extends FileBasedTest
TransformStateTest app = new TransformStateTest();
app.doMain(args);
}
+
+ // Android-added: Run main method as a JUnit test case.
+ @Test
+ public void main() {
+ main(new String[0]);
+ }
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/TransformStateTestlet.java b/test/java/src/org/apache/qetest/xalanj2/TransformStateTestlet.java
index 9a4e791..6c4aa73 100644
--- a/test/java/src/org/apache/qetest/xalanj2/TransformStateTestlet.java
+++ b/test/java/src/org/apache/qetest/xalanj2/TransformStateTestlet.java
@@ -306,9 +306,10 @@ public class TransformStateTestlet extends TestletImpl
else
{
// Just log error case if transformer is ever null
- if (null == transformer)
- buf.append("\n <transformer>"
- + "ERROR! Transformer was null!" + "</transformer>");
+ if (null == transformer) {
+ buf.append("\n <transformer>"
+ + "ERROR! Transformer was null!" + "</transformer>");
+ }
}
}
diff --git a/test/java/src/org/apache/qetest/xalanj2/XalanDumper.java b/test/java/src/org/apache/qetest/xalanj2/XalanDumper.java
index 8747fff..5046025 100644
--- a/test/java/src/org/apache/qetest/xalanj2/XalanDumper.java
+++ b/test/java/src/org/apache/qetest/xalanj2/XalanDumper.java
@@ -240,7 +240,9 @@ public abstract class XalanDumper
{
final TransformerImpl timpl = (TransformerImpl)trans;
// We have a Xalan-J 2.x basic transformer
- buf.append("getBaseURLOfSource=" + timpl.getBaseURLOfSource() + SEP);
+
+ // Android-changed: TransformerImpl in 2.7.1 doesn't have getBaseURLOfSource() method.
+ // buf.append("getBaseURLOfSource=" + timpl.getBaseURLOfSource() + SEP);
// Result getOutputTarget()
// ContentHandler getInputContentHandler(boolean doDocFrag)
// DeclHandler getInputDeclHandler()
diff --git a/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java b/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java
index 1b390e5..e64e586 100644
--- a/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java
+++ b/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java
@@ -258,7 +258,8 @@ public abstract class TraxWrapperUtils
}
else if (SET_TRACE_LISTENER.equals(key) && transformer instanceof TransformerImpl)
{
- TraceManager traceManager = ((TransformerImpl)transformer).getTraceManager();
+ // Android-changed: TransformerImpl in 2.7.1 doesn't have getTraceManager() method.
+ // TraceManager traceManager = ((TransformerImpl)transformer).getTraceManager();
try {
FileOutputStream writeStream = new FileOutputStream((String)value);
PrintWriter printWriter = new PrintWriter(writeStream, true);
@@ -267,7 +268,8 @@ public abstract class TraxWrapperUtils
traceListener.m_traceGeneration = true;
traceListener.m_traceSelection = true;
traceListener.m_traceTemplates = true;
- traceManager.addTraceListener(traceListener);
+ // Android-changed: TransformerImpl in 2.7.1 doesn't have getTraceManager() method.
+ // traceManager.addTraceListener(traceListener);
} catch (FileNotFoundException fnfe) {
System.out.println("File not found: " + fnfe);
} catch (Exception e) {
diff --git a/test/trace-src/org/apache/xalan/trace/TraceManager.java b/test/trace-src/org/apache/xalan/trace/TraceManager.java
index 8699487..5a5077f 100644
--- a/test/trace-src/org/apache/xalan/trace/TraceManager.java
+++ b/test/trace-src/org/apache/xalan/trace/TraceManager.java
@@ -66,7 +66,8 @@ public class TraceManager
throws TooManyListenersException
{
- m_transformer.setDebug(true);
+ // Android-changed: TransformerImpl in 2.7.1 doesn't have setDebug() method.
+ // m_transformer.setDebug(true);
if (null == m_traceListeners)
m_traceListeners = new Vector();