You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ab...@apache.org on 2007/10/26 18:13:25 UTC
svn commit: r588698 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java
Author: abrown
Date: Fri Oct 26 09:13:25 2007
New Revision: 588698
URL: http://svn.apache.org/viewvc?rev=588698&view=rev
Log:
DERBY-3148: Fix JUnit test code that searches for Xalan version to
avoid "Malformed \uxxxx encoding" errors when the user's classpath
has "\u.." in it.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java?rev=588698&r1=588697&r2=588698&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java Fri Oct 26 09:13:25 2007
@@ -34,7 +34,6 @@
import java.sql.SQLException;
import java.util.StringTokenizer;
-import java.util.Properties;
import junit.framework.Assert;
@@ -324,13 +323,35 @@
*/
if (boolObj.booleanValue())
{
- // Load the properties gathered from checkEnvironment().
- Properties props = new Properties();
- props.load(new ByteArrayInputStream(bos.toByteArray()));
+ /* We wrote the byte array using the platform's default
+ * encodinging (that's what we get with the call to
+ * "new PrintWriter(bos)" above), so read it in using
+ * the default encoding, as well (i.e. don't pass an
+ * encoding into toString()).
+ */
+ String checkEnvOutput = bos.toString();
bos.close();
+ /* The property we're looking for is on a single line
+ * of the output, and that line starts with the name
+ * of the property. So extract that line out now. If
+ * we can't find it, just return "false" to say that
+ * we could not find the minimum version. Note: it's
+ * possible (though admittedly unlikely) that the
+ * string "version.xalan2_2" appears in the user's
+ * classpath. Adding an equals sign ("=") at the end
+ * of our search pattern reduces the chance of the
+ * search string appearing in the classpath, but does
+ * not eliminate it...
+ */
+ int pos = checkEnvOutput.indexOf("version.xalan2_2=");
+ if (pos < 0)
+ return false;
+
+ String ver = checkEnvOutput.substring(
+ pos, checkEnvOutput.indexOf("\n", pos));
+
// Now pull out the one we need.
- String ver = props.getProperty("version.xalan2_2");
haveMinXalanVersion = (ver != null);
if (haveMinXalanVersion)
{