[rfc] [icedtea-web] cleaning XML logging from wrong character
Adam Domurad
adomurad at redhat.com
Mon Dec 3 06:54:57 PST 2012
On 12/03/2012 09:35 AM, Jiri Vanek wrote:
> Epiphany is littel bit confuse dby JS<->applet tests and is returning
> negative, zero or to high retyped chars.
> Those chars break xml processing, so I would like to get them out from
> xml by this patch (kept in plain text).
>
> Also I have realised I have broken unittest logging some tie ago.
> Fixed also:(
>
> J.
> diff -r eedc15145aa6 ChangeLog
> --- a/ChangeLog Mon Dec 03 14:43:18 2012 +0100
> +++ b/ChangeLog Mon Dec 03 15:31:47 2012 +0100
> @@ -1,3 +1,13 @@
> +2012-11-03 Jiri Vanek <jvanek at redhat.com>
> +
> + Fixed logging bottleneck
> + * tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java:
> + added and used function (clearChars) which filter characters
> going to xml
> + from invalid ones.
> + * tests/test-extensions/net/sourceforge/jnlp/ServerAccess:
> getting test
> + method id by (getTestMethod) now relay on physical way to the
> class as
> + the only real thing differing test class and framework class.
> +
> 2012-12-03 Pavel Tisnovsky <ptisnovs at redhat.com>
>
> * Makefile.am: Added new target for compiling softkiller.
> diff -r eedc15145aa6
> tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java
> ---
> a/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java
> Mon Dec 03 14:43:18 2012 +0100
> +++
> b/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java
> Mon Dec 03 15:31:47 2012 +0100
> @@ -117,7 +117,7 @@
> String testName = testLog.getKey();
> String testLogs = testLog.getValue().toString();
> w.write("<" + TESTLOG_ELEMENT + " " +
> TESTMETHOD_ATTRIBUTE + "=\"" + testName + "\" " + FULLID_ATTRIBUTE +
> "=\"" + className + "." + testName + "\" >");
> - w.write(testLogs);
> + w.write(clearChars(testLogs));
> w.write("</" + TESTLOG_ELEMENT + ">");
> }
> w.write("</" + CLASSLOG_ELEMENT + ">");
> @@ -215,4 +215,24 @@
> DEFAULT_STDLOGS_WRITER.newLine();
> DEFAULT_STDLOGS_WRITER.flush();
> }
> +
> + public static String clearChars(String ss) {
> + StringBuilder s = new StringBuilder(ss);
> + for (int i = 0; i < s.length(); i++) {
> + char q = s.charAt(i);
> + if (q == '\n') {
> + continue;
> + }
> + int iq = (int) q;
> + if (iq == 9) {
> + continue;
> + }
> + if (iq <= 31 || iq > 65533) {
> + s.setCharAt(i, 'I');
> + s.insert(i + 1, "NVALID_CHAR_" + iq);
> + i -= 1;
> + }
> + }
> + return s.toString();
> + }
> }
> diff -r eedc15145aa6
> tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java
> --- a/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java
> Mon Dec 03 14:43:18 2012 +0100
> +++ b/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java
> Mon Dec 03 15:31:47 2012 +0100
> @@ -783,8 +783,27 @@
> //probablky it is necessary to get out of
> net.sourceforge.jnlp.
> //package where are right now all test-extensions
> //for now keeping exactly the three clases helping yo
> acces the log
> - if
> (!stack[i].getClassName().startsWith("net.sourceforge.jnlp.")) {
> - break;
> + try {
> + Class clazz = Class.forName(stack[i].getClassName());
> + String path = null;
> + try {
> + path =
> clazz.getProtectionDomain().getCodeSource().getLocation().getPath();
> + } catch (NullPointerException ex) {
> + //silently ignoring and continuing with null path
> + }
> + if (path != null && path.contains("/tests.build/")) {
> + if (!path.contains("/test-extensions/")) {
> + break;
> + }
> + } else {
> + //running from ide
> + if
> (!stack[i].getClassName().startsWith("net.sourceforge.jnlp.")) {
> + break;
> + }
> + }
> + } catch (ClassNotFoundException ex) {
> + ///should not happen, laoding only loaded
laoding->loading
> + ex.printStackTrace();
> }
> }
> //if nothing left in stack then we have been in ServerAccess
> already
> @@ -793,7 +812,7 @@
> if (i >= stack.length) {
> return result;
> }
> - //now we are out of net.sourceforge.jnlp.*
> + //now we are out of test-extensions
> //method we need (the test) is highest from following class
> baseClass = stack[i].getClassName();
> for (; i < stack.length; i++) {
OK for HEAD/1.3 if applicable.
Happy hacking,
-Adam
More information about the distro-pkg-dev
mailing list