diff options
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | Makefile.am | 19 | ||||
-rw-r--r-- | tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java | 2 | ||||
-rw-r--r-- | tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java | 20 | ||||
-rw-r--r-- | tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java | 255 | ||||
-rw-r--r-- | tests/report-styles/index.js | 82 | ||||
-rw-r--r-- | tests/report-styles/jreport.xsl | 24 | ||||
-rw-r--r-- | tests/report-styles/logs.xsl | 153 | ||||
-rw-r--r-- | tests/report-styles/output.css | 7 | ||||
-rw-r--r-- | tests/report-styles/report.css | 5 |
10 files changed, 554 insertions, 48 deletions
@@ -1,3 +1,38 @@ +2012-06-11 Jiri Vanek <[email protected]> + + Implemented xml logging backend + * Makefile.am: (stamps/run-netx-unit-tests.stamp) and + (stamps/run-netx-dist-tests.stamp) removed redirection of streams as + logging is now done in ServerAccess tests extensions + added xsltproc execution above generated xml log + xsltproc generating results html files is now receiving result of above + as parameter + * tests/report-styles/jreport.xsl: log parameter is now accepted, and + if set, then all tests are linking into specified file to show the log + * tests/report-styles/report.css: added styles for new links + * tests/report-styles/index.js: new functions to work for result of below sheet + * tests/report-styles/logs.xsl: new file, sheet to convert xml log to html file + * tests/report-styles/output.css: new file, styles of above html file + * tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java: + * tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java: + * tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java: + Tests', server's and ProcessAssasin's logs are now redirected to bottleneck + * tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java: + (LOGS_REPRINT) flag for debugging purposes, will enable reprinting to + stdout/err again + (DEFAULT_LOG_FILE ) default name of xml output + (DEFAULT_STDERR_FILE)(DEFAULT_STDOUT_FILE)(DEFAULT_STDLOGS_FILE) default + values of plain text output files + (*ELEMENT) and( (*ATTRIBUTE) variables keeping repeated names of xml + output parts + (writeXmlLog) method called from Sytsem.hook to save xml log + (addToXmlLog) method to record item to xml structure + (TestsLogs) and (LogItem) inner classes to keep logging information + (log) is now reprinting message with id to std out/err dependently on + (LOGS_REPRINT) but always to internal streams, possilbe exception is thrown + (logException) new method, shortcut to log exception in same way as message + (getTestMethod) now can handle methods inside ServerAccess class too + 2012-06-11 Adam Domurad <[email protected]> * NEWS: Added mention of fixing PR518 diff --git a/Makefile.am b/Makefile.am index 6754c44..c09a4c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -679,12 +679,11 @@ stamps/run-netx-dist-tests.stamp: stamps/netx-dist.stamp extra-lib/about.jar sta class_names=`cat $(REPRODUCERS_CLASS_NAMES)` ; \ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):. \ $(BOOT_DIR)/bin/java $(REPRODUCERS_DPARAMETERS) \ - -Xbootclasspath:$(RUNTIME) CommandLine $$class_names \ - > stdout.log 2> stderr.log ; \ - cat stdout.log ; \ - cat stderr.log >&2 + -Xbootclasspath:$(RUNTIME) CommandLine $$class_names + if WITH_XSLTPROC - $(XSLTPROC) $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(JNLP_TESTS_ENGINE_DIR)/tests-output.xml > $(TESTS_DIR)/index_reproducers.html + $(XSLTPROC) $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/logs.xsl $(JNLP_TESTS_ENGINE_DIR)/ServerAccess-logs.xml > $(TESTS_DIR)/logs_reproducers.html + $(XSLTPROC) --stringparam logs logs_reproducers.html $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(JNLP_TESTS_ENGINE_DIR)/tests-output.xml > $(TESTS_DIR)/index_reproducers.html endif touch $@ @@ -833,12 +832,10 @@ stamps/run-netx-unit-tests.stamp: stamps/netx-unit-tests-compile.stamp $(JUNIT_R cd $(NETX_UNIT_TEST_DIR) ; \ class_names=`cat $(UNIT_CLASS_NAMES)` ; \ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(JNLP_TESTS_ENGINE_DIR):. \ - $(BOOT_DIR)/bin/java -Xbootclasspath:$(RUNTIME) CommandLine $$class_names \ - > stdout.log 2> stderr.log ; \ - cat stdout.log ; \ - cat stderr.log >&2 + $(BOOT_DIR)/bin/java -Xbootclasspath:$(RUNTIME) CommandLine $$class_names if WITH_XSLTPROC - $(XSLTPROC) $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(NETX_UNIT_TEST_DIR)/tests-output.xml > $(TESTS_DIR)/index_unit.html + $(XSLTPROC) $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/logs.xsl $(NETX_UNIT_TEST_DIR)/ServerAccess-logs.xml > $(TESTS_DIR)/logs_unit.html + $(XSLTPROC) --stringparam logs logs_unit.html $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(NETX_UNIT_TEST_DIR)/tests-output.xml > $(TESTS_DIR)/index_unit.html endif touch $@ @@ -1016,7 +1013,7 @@ clean-netx-unit-tests: clean_tests_reports clean_tests_reports: rm -rf $(TESTS_DIR)/$(REPORT_STYLES_DIRNAME)/ - rm -f $(TESTS_DIR)/index*.html + rm -f $(TESTS_DIR)/*.html clean-netx-dist-tests: clean_tests_reports netx-dist-tests-remove-cert-from-public rm -f netx-dist-tests-source-files.txt diff --git a/tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java b/tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java index b3d8fdb..79020e6 100644 --- a/tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java +++ b/tests/jnlp_tests/simple/deadlocktest/testcases/DeadLockTestTest.java @@ -225,7 +225,7 @@ public class DeadLockTestTest { try { pr = server.executeJavawsHeadless(args, jnlp); } catch (Exception ex) { - ex.printStackTrace(); + ServerAccess.logException(ex); } finally { finished = true; } diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java index 63d6210..89e2825 100644 --- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ResourcesTest.java @@ -64,12 +64,12 @@ public class ResourcesTest { for (int i = 0; i < simpleContent.length; i++) { File file = simpleContent[i]; - System.err.print(file.getName()); + ServerAccess.logOutputReprint(file.getName()); //server port have in fact no usage in converting filename to uri-like-filename. //But if there is null, instead if some number, then nullpointer exception is thrown (Integer->int). //So I'm using "real" currently used port, instead of some random value. URI u = new URI((String)null,(String)null,(String)null,server.getPort(),file.getName(),(String)null,null); - System.err.println(" ("+u.toString()+")"); + ServerAccess.logOutputReprint(" ("+u.toString()+")"); String fname=u.toString(); if (file.getName().toLowerCase().endsWith(".jnlp")) { String c = server.getResourceAsString("/" + fname); @@ -98,13 +98,13 @@ public class ResourcesTest { @Override public void charReaded(char ch) { - //System.out.println("OO recieved char: "+ch); + //ServerAccess.logOutputReprint("OO recieved char: "+ch); o1.append(ch); } @Override public void lineReaded(String s) { - //System.out.println("OO recieved line: "+s); + //ServerAccess.logOutputReprint("OO recieved line: "+s); o2.append(s).append("\n"); } }; @@ -112,22 +112,22 @@ public class ResourcesTest { @Override public void charReaded(char ch) { - //System.out.println("EE recieved char: "+ch); + //ServerAccess.logOutputReprint("EE recieved char: "+ch); e1.append(ch); } @Override public void lineReaded(String s) { - //System.out.println("EE recieved line: "+s); + //ServerAccess.logOutputReprint("EE recieved line: "+s); e2.append(s).append("\n"); } }; ServerAccess.ProcessResult pr=server.executeBrowser("simpletest1.jnlp",le,lo); pr.process.destroy(); -// System.out.println("total o"); -// System.out.println(pr.stdout); -// System.out.println("total e"); -// System.out.println(pr.stderr); +// ServerAccess.logOutputReprint("total o"); +// ServerAccess.logOutputReprint(pr.stdout); +// ServerAccess.logOutputReprint("total e"); +// ServerAccess.logOutputReprint(pr.stderr); Assert.assertEquals(pr.stdout, o1.toString()); Assert.assertEquals(pr.stderr, e1.toString()); //the last \n is mandatory as las tline is flushed also when proces dies diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java index 267d230..db95a0a 100644 --- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java @@ -42,12 +42,17 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; import java.io.Reader; +import java.io.StringWriter; import java.io.Writer; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -57,8 +62,13 @@ import java.net.SocketException; import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.StringTokenizer; import org.junit.Assert; @@ -120,8 +130,166 @@ public class ServerAccess { * this flag is indicating whether output of executeProcess should be logged. By default true. */ public static boolean PROCESS_LOG = true; + public static boolean LOGS_REPRINT = false; /** + * map of classes, each have map of methods, each have errorlist, outLIst, and allList (allist contains also not std or err messages) + * class.testMethod.logs + */ + private static final Map<String, Map<String, TestsLogs>> processLogs = new HashMap<String, Map<String, TestsLogs>>(100); + private static final File DEFAULT_LOG_FILE = new File("ServerAccess-logs.xml"); + private static final File DEFAULT_STDERR_FILE = new File("stderr.log"); + private static final File DEFAULT_STDOUT_FILE = new File("stdout.log"); + private static final File DEFAULT_STDLOGS_FILE = new File("all.log"); + private static BufferedWriter DEFAULT_STDERR_WRITER; + private static BufferedWriter DEFAULT_STDOUT_WRITER; + private static BufferedWriter DEFAULT_STDLOGS_WRITER; + + static{ + try{ + DEFAULT_STDOUT_WRITER=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DEFAULT_STDOUT_FILE))); + DEFAULT_STDERR_WRITER=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DEFAULT_STDERR_FILE))); + DEFAULT_STDLOGS_WRITER=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DEFAULT_STDLOGS_FILE))); + }catch(Throwable t){ + t.printStackTrace(); + } + } + private static final String LOGS_ELEMENT = "logs"; + private static final String CLASSLOG_ELEMENT = "classlog"; + private static final String CLASSNAME_ATTRIBUTE = "className"; + private static final String TESTLOG_ELEMENT = "testLog"; + private static final String TESTMETHOD_ATTRIBUTE = "testMethod"; + private static final String FULLID_ATTRIBUTE = "fullId"; + private static final String LOG_ELEMENT = "log"; + private static final String LOG_ID_ATTRIBUTE = "id"; + private static final String ITEM_ELEMENT = "item"; + private static final String ITEM_ID_ATTRIBUTE = "id"; + private static final String STAMP_ELEMENT = "stamp"; + private static final String TEXT_ELEMENT = "text"; + private static final String FULLTRACE_ELEMENT = "fulltrace"; + + private static void writeXmlLog() throws FileNotFoundException, IOException { + writeXmlLog(DEFAULT_LOG_FILE); + } + + private static void writeXmlLog(File f) throws FileNotFoundException, IOException { + Writer w = new OutputStreamWriter(new FileOutputStream(f)); + Set<Entry<String, Map<String, TestsLogs>>> classes = processLogs.entrySet(); + w.write("<" + LOGS_ELEMENT + ">"); + for (Entry<String, Map<String, TestsLogs>> classLog : classes) { + String className = classLog.getKey(); + w.write("<" + CLASSLOG_ELEMENT + " " + CLASSNAME_ATTRIBUTE + "=\"" + className + "\">"); + Set<Entry<String, TestsLogs>> testsLogs = classLog.getValue().entrySet(); + for (Entry<String, TestsLogs> testLog : testsLogs) { + 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("</" + TESTLOG_ELEMENT + ">"); + } + w.write("</" + CLASSLOG_ELEMENT + ">"); + } + w.write("</" + LOGS_ELEMENT + ">"); + w.flush(); + w.close(); + } + + private static void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) { + Map<String, TestsLogs> classLog = processLogs.get(ste.getClassName()); + if (classLog == null) { + classLog = new HashMap<String, TestsLogs>(50); + processLogs.put(ste.getClassName(), classLog); + } + TestsLogs methodLog = classLog.get(ste.getMethodName()); + if (methodLog == null) { + methodLog = new TestsLogs(); + classLog.put(ste.getMethodName(), methodLog); + } + methodLog.add(printToErr, printToOut, message); + } + + private static class TestsLogs { + + public final List<LogItem> outs = new LinkedList<LogItem>(); + public final List<LogItem> errs = new LinkedList<LogItem>(); + public final List<LogItem> all = new LinkedList<LogItem>(); + private static boolean added = false; + + public synchronized void add(boolean err, boolean out, String text) { + if (text == null) { + text = "null"; + } + LogItem li = new LogItem(text); + if (out) { + outs.add(li); + } + if (err) { + errs.add(li); + } + all.add(li); + if (!added) { + Runtime.getRuntime().addShutdownHook(new Thread() { + + @Override + public void run() { + try { + writeXmlLog(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + added = true; + } + } + + @Override + public String toString() { + StringBuilder sb = listToStringBuilder(outs, "out"); + sb.append(listToStringBuilder(errs, "err")); + sb.append(listToStringBuilder(all, "all")); + return sb.toString(); + } + + private StringBuilder listToStringBuilder(List<LogItem> l, String id) { + StringBuilder sb = new StringBuilder(); + sb.append("<" + LOG_ELEMENT + " " + LOG_ID_ATTRIBUTE + "=\"").append(id).append("\">\n"); + int i = 0; + for (LogItem logItem : l) { + i++; + sb.append(logItem.toStringBuilder(i)); + } + sb.append("</" + LOG_ELEMENT + ">\n"); + return sb; + } + }; + + private static class LogItem { + + public final Date timeStamp = new Date(); + public final StackTraceElement[] fullTrace = Thread.currentThread().getStackTrace(); + public final String text; + + public LogItem(String text) { + this.text = text; + } + + public StringBuilder toStringBuilder(int id) { + StringBuilder sb = new StringBuilder(); + sb.append(" <" + ITEM_ELEMENT + " " + ITEM_ID_ATTRIBUTE + "=\"").append(id).append("\">\n"); + sb.append(" <" + STAMP_ELEMENT + "><![CDATA[").append(timeStamp.toString()).append("]]></" + STAMP_ELEMENT + ">\n"); + sb.append(" <" + TEXT_ELEMENT + "><![CDATA[\n").append(text).append("\n]]></" + TEXT_ELEMENT + ">\n"); + sb.append(" <" + FULLTRACE_ELEMENT + "><![CDATA[\n"); + //five methods since call in log methods + getStacktrace method + for (int i = 6; i < fullTrace.length; i++) { + sb.append(fullTrace[i].toString()).append("\n"); + } + sb.append("\n]]> </" + FULLTRACE_ELEMENT + ">\n"); + sb.append(" </" + ITEM_ELEMENT + ">\n"); + return sb; + } + } + /** * main method of this class prints out random free port * or runs server * param "port" prints out the port @@ -562,7 +730,10 @@ public class ServerAccess { * @throws IOException */ public static void saveFile(String content, File f) throws IOException { - Writer output = new BufferedWriter(new FileWriter(f)); + saveFile(content, f, "utf-8"); + } + public static void saveFile(String content, File f,String encoding) throws IOException { + Writer output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f),encoding)); output.write(content); output.flush(); output.close(); @@ -762,11 +933,45 @@ public class ServerAccess { idded = fullId + ": " + message; } + if (LOGS_REPRINT) { + if (printToOut) { + System.out.println(idded); + } + if (printToErr) { + System.err.println(idded); + } + } + try{ if (printToOut) { - System.out.println(idded); + DEFAULT_STDOUT_WRITER.write(idded); + DEFAULT_STDOUT_WRITER.newLine(); } if (printToErr) { - System.err.println(idded); + DEFAULT_STDERR_WRITER.write(idded); + DEFAULT_STDERR_WRITER.newLine(); + } + DEFAULT_STDLOGS_WRITER.write(idded); + DEFAULT_STDLOGS_WRITER.newLine(); + }catch (Throwable t){ + t.printStackTrace(); + } + + addToXmlLog(message,printToOut,printToErr,ste); + } + + public static void logException(Throwable t){ + logException(t, true); + } + public static void logException(Throwable t, boolean print){ + try{ + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + log(sw.toString(), false, print); + pw.close(); + sw.close(); + }catch(Exception ex){ + throw new RuntimeException(ex); } } @@ -789,6 +994,12 @@ public class ServerAccess { break; } } + //if nothing left in stack then we have been in ServerAccess already + //so the target method is the highest form it and better to return it + //rather then die to ArrayOutOfBounds + if(i >= stack.length){ + return result; + } //now we are out of net.sourceforge.jnlp.ServerAccess //method we need (the test) is highest from following class baseClass = stack[i].getClassName(); @@ -1073,9 +1284,9 @@ public class ServerAccess { String op = t.nextToken(); String p = op; if (p.startsWith(XSX))p=p.replace(XSX, "/"); - System.err.println("Getting: "+p); + logNoReprint("Getting: "+p); p=URLDecoder.decode(p, "UTF-8"); - System.err.println("Serving: "+p); + logNoReprint("Serving: "+p); p = (".".concat(((p.endsWith("/")) ? p.concat( "index.html") : p))).replace('/', File.separatorChar); File pp = new File(dir, p); @@ -1107,14 +1318,14 @@ public class ServerAccess { } } }catch (SocketException e) { - e.printStackTrace(); + logException(e, false); } catch (Exception e) { o.writeBytes("HTTP/1.0 404 ERROR\n\n\n"); - e.printStackTrace(); + logException(e, false); } o.close(); } catch (Exception e) { - e.printStackTrace(); + logException(e, false); } } } @@ -1248,14 +1459,13 @@ public class ServerAccess { this.canRun = canRun; if (p != null) { if (p.getP() != null) { - System.err.println("Stopping assassin for" + p.toString() + " " + p.getP().toString() + " " + p.getCommandLine() + ": "); + logNoReprint("Stopping assassin for" + p.toString() + " " + p.getP().toString() + " " + p.getCommandLine() + ": "); } else { - System.err.println("Stopping assassin for" + p.toString() + " " + p.getCommandLine() + ": "); + logNoReprint("Stopping assassin for" + p.toString() + " " + p.getCommandLine() + ": "); } } else { - System.err.println("Stopping assassin for null job: "); + logNoReprint("Stopping assassin for null job: "); } - System.err.flush(); } public boolean isCanRun() { @@ -1288,11 +1498,10 @@ public class ServerAccess { try { if (p != null) { if (p.getP() != null) { - System.err.println("Timed out " + p.toString() + " " + p.getP().toString() + " .. killing " + p.getCommandLine() + ": "); + logErrorReprint("Timed out " + p.toString() + " " + p.getP().toString() + " .. killing " + p.getCommandLine() + ": "); } else { - System.err.println("Timed out " + p.toString() + " " + "null .. killing " + p.getCommandLine() + ": "); + logErrorReprint("Timed out " + p.toString() + " " + "null .. killing " + p.getCommandLine() + ": "); } - System.err.flush(); wasTerminated = true; p.interrupt(); while (!terminated.contains(p)) { @@ -1311,13 +1520,12 @@ public class ServerAccess { } } if (p.getP() != null) { - System.err.println("Timed out " + p.toString() + " " + p.getP().toString() + " .. killed " + p.getCommandLine()); + logErrorReprint("Timed out " + p.toString() + " " + p.getP().toString() + " .. killed " + p.getCommandLine()); } else { - System.err.println("Timed out " + p.toString() + " null .. killed " + p.getCommandLine()); + logErrorReprint("Timed out " + p.toString() + " null .. killed " + p.getCommandLine()); } - System.err.flush(); } else { - System.err.println("Timed out null job"); + logErrorReprint("Timed out null job"); } break; } finally { @@ -1333,14 +1541,13 @@ public class ServerAccess { } if (p != null) { if (p.getP() != null) { - System.err.println("assassin for" + p.toString() + " " + p.getP().toString() + " .. done " + p.getCommandLine() + " termination " + wasTerminated); + logNoReprint("assassin for" + p.toString() + " " + p.getP().toString() + " .. done " + p.getCommandLine() + " termination " + wasTerminated); } else { - System.err.println("assassin for" + p.toString() + " null .. done " + p.getCommandLine() + " termination " + wasTerminated); + logNoReprint("assassin for" + p.toString() + " null .. done " + p.getCommandLine() + " termination " + wasTerminated); } } else { - System.err.println("assassin for non exisitng job termination " + wasTerminated); + logNoReprint("assassin for non existing job termination " + wasTerminated); } - System.err.flush(); } } @@ -1418,7 +1625,7 @@ public class ServerAccess { } if (interrupted) { - System.out.println("Stream copier: throwing InterruptedException"); + logNoReprint("Stream copier: throwing InterruptedException"); //throw new InterruptedException(); } } diff --git a/tests/report-styles/index.js b/tests/report-styles/index.js index 27b6ed5..75158c2 100644 --- a/tests/report-styles/index.js +++ b/tests/report-styles/index.js @@ -1,3 +1,20 @@ +function showhideMethods(inElement,toValue) { + var e = document.getElementById(inElement); + methods=e.getElementsByClassName("method"); + for ( var i = 0; i < methods.length; i++ ) { + methods[i].style.display=toValue + } +} +function openAnchor() { + anchor=self.document.location.hash; + if (anchor==null || anchor=="") return; + stub=anchor.substring(1); + var logs=getLogsArray(stub); + logs[0].style.display="inline"; + logs[1].style.display="inline"; + recalcArraysWidth(logs); + window.location.hash=stub; +} function negateIdDisplay(which) { var e = document.getElementById(which); @@ -8,6 +25,14 @@ function negateIdDisplay(which) { } } +function negateIdDisplayInline(which) { + var e = document.getElementById(which); + if (e.style.display=="inline") { + e.style.display="none" + } else { + e.style.display="inline" + } +} function setClassDisplay(which,what) { var e = document.getElementsByClassName(which); @@ -16,5 +41,62 @@ function setClassDisplay(which,what) { } } +function negateClassBlocDisplay(which) { + var e = document.getElementsByClassName(which); + for ( var i = 0; i < e.length; i++ ) { + if (e[i].style.display=="block") { + e[i].style.display="none" + } else { + e[i].style.display="block" + } + } +} +function negateClassBlocDisplayIn(where,which) { + var parent = document.getElementById(where); + var e = parent.getElementsByClassName(which); + for ( var i = 0; i < e.length; i++ ) { + if (e[i].style.display=="block") { + e[i].style.display="none" + } else { + e[i].style.display="block" + } + } +} + +function getLogsArray(stub) { + return new Array(document.getElementById(stub+".out"),document.getElementById(stub+".err"),document.getElementById(stub+".all")); +} + +function recalcLogsWidth(stub) { + var logs=getLogsArray(stub) + recalcArraysWidth(logs); +} +function showAllLogs() { + var e = document.getElementsByClassName("method"); + for ( var i = 0; i < e.length; i++ ) { + stub=e[i].id; + var logs=getLogsArray(stub) + logs[0].style.display="none"; + logs[1].style.display="none" + logs[2].style.display="inline" + recalcArraysWidth(logs); + + } +} +function recalcArraysWidth(logs) { + visible=0; + for ( var i = 0; i < logs.length; i++ ) { + if (logs[i].style.display!="none"){ + visible++; + } + } + if (visible==0) return; + nwWidth=90/visible; + for ( var i = 0; i < logs.length; i++ ) { + if (logs[i].style.display!="none"){ + logs[i].style.width=nwWidth+"%"; + } + } +} diff --git a/tests/report-styles/jreport.xsl b/tests/report-styles/jreport.xsl index c83972c..a54d0f9 100644 --- a/tests/report-styles/jreport.xsl +++ b/tests/report-styles/jreport.xsl @@ -38,6 +38,14 @@ exception statement from your version. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> +<!-- +when parameter is mentioned (no matter of value) eg: +<xsl:param name="logs">none</xsl:param> +then xsltproc is not able to change its value since 2008 +This parameter is providing relative path to file with logs which is then linked from this index +Bad luck that xsltproc is not able to use default values. +If there is no need for linking, please use value "none" for this variable +--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> @@ -208,8 +216,20 @@ exception statement from your version. </a> <div class="lineHeader"> <div class="clazz"> - <xsl:value-of select="@classname"/> - </div> + <xsl:choose> + <xsl:when test="$logs!='none'"> + <a class="logLink" target="new"> + <xsl:attribute name="href"> + <xsl:value-of select="$logs"/>#<xsl:value-of select="@classname"/>.<xsl:value-of select="@name"/> + </xsl:attribute> + <xsl:value-of select="@classname"/> + </a> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@classname"/> + </xsl:otherwise> + </xsl:choose> + </div> <xsl:text disable-output-escaping="no"> - </xsl:text> <div class="method"> <xsl:value-of select="@name"/> diff --git a/tests/report-styles/logs.xsl b/tests/report-styles/logs.xsl new file mode 100644 index 0000000..e139614 --- /dev/null +++ b/tests/report-styles/logs.xsl @@ -0,0 +1,153 @@ +<?xml version="1.0"?> +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + + --> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + <xsl:template match="/"> + <html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <script src="report-styles/index.js"/> + <link href="report-styles/output.css" rel="stylesheet" type="text/css"/> + </head> + <body onload="setClassDisplay("fulltrace","none");setClassDisplay("stamp","none");setClassDisplay("output","none");openAnchor();"> + <div id="wholePage"> + <button onclick="showAllLogs()">show all</button> + <button onclick="setClassDisplay('output','none')">hide all</button> + <button onclick="showAllLogs()">show all logs</button> + <button onclick="setClassDisplay('output','none')">hide all logs</button> + <button onclick="setClassDisplay('method','block')">show all methods</button> + <button onclick="setClassDisplay('method','none')">hide all methods</button> + <xsl:for-each select="/logs/classlog"> + <div class="classa"> + <xsl:attribute name="id"> + <xsl:value-of select="@className"/> + </xsl:attribute> + <h1> + <a> + <xsl:attribute name="name"> + <xsl:value-of select="@className"/> + </xsl:attribute> + </a> + <xsl:value-of select="@className"/> + </h1> + <button><xsl:attribute name="onclick"> + showhideMethods('<xsl:value-of select="@className"/>','none') + </xsl:attribute> +hide methods</button> + <button><xsl:attribute name="onclick"> + showhideMethods('<xsl:value-of select="@className"/>','block') + </xsl:attribute> +show methods</button> + <xsl:for-each select="testLog"> + <div class="method"> + <xsl:attribute name="id"> + <xsl:value-of select="@fullId"/> + </xsl:attribute> + <h2> + <a> + <xsl:attribute name="name"> + <xsl:value-of select="@fullId"/> + </xsl:attribute> + <xsl:value-of select="@testMethod"/> + </a> + </h2> + <button><xsl:attribute name="onclick"> + negateIdDisplayInline('<xsl:value-of select="@fullId"/>.out'); + recalcLogsWidth('<xsl:value-of select="@fullId"/>'); + </xsl:attribute> +show/hide stdout</button> + <button><xsl:attribute name="onclick"> + negateIdDisplayInline('<xsl:value-of select="@fullId"/>.err'); + recalcLogsWidth('<xsl:value-of select="@fullId"/>'); + </xsl:attribute> +show/hide stderr</button> + <button><xsl:attribute name="onclick"> + negateIdDisplayInline('<xsl:value-of select="@fullId"/>.all'); + recalcLogsWidth('<xsl:value-of select="@fullId"/>'); + </xsl:attribute> +show/hide alllog</button> + <button><xsl:attribute name="onclick"> + negateClassBlocDisplayIn('<xsl:value-of select="@fullId"/>','fulltrace'); + </xsl:attribute> +show/hide fulltraces</button> + <button><xsl:attribute name="onclick"> + negateClassBlocDisplayIn('<xsl:value-of select="@fullId"/>','stamp'); + </xsl:attribute> +show/hide stamps</button> + <div class="space-line"> + <!-- --> + </div> + <xsl:for-each select="log"> + <div class="output"> + <xsl:attribute name="id"><xsl:value-of select="../@fullId"/>.<xsl:value-of select="@id"/></xsl:attribute> + <h3> + <xsl:value-of select="@id"/> + </h3> + <xsl:for-each select="item"> + <div class="item"> + <xsl:attribute name="id"><xsl:value-of select="../../@fullId"/>.<xsl:value-of select="../@id"/>.<xsl:value-of select="@id"/></xsl:attribute> + <div class="stamp"><xsl:value-of select="stamp"/></div> + <div class="fulltrace"> + <pre> + <xsl:value-of select="fulltrace"/> + </pre> + </div> + <pre> + <xsl:value-of select="text"/> + </pre> + <!--item--> + </div> + </xsl:for-each> + <!--output--> + </div> + </xsl:for-each> + <div class="space-line"> + <!-- --> + </div> + <!--method--> + </div> + </xsl:for-each> + <!--classa--> + </div> + </xsl:for-each> + <!--wholePage--> + </div> + </body> + </html> + </xsl:template> +</xsl:stylesheet> diff --git a/tests/report-styles/output.css b/tests/report-styles/output.css new file mode 100644 index 0000000..3da997c --- /dev/null +++ b/tests/report-styles/output.css @@ -0,0 +1,7 @@ +div.space-line { clear: both; margin: 0; padding: 0; width: auto;} +div.classa { border: thin solid black; padding: 5px; margin: 5px;} +div.method {border: thin solid black; padding: 5px; margin: 5px;} +div.output { border: thin solid black; padding: 5px; margin: 5px; float: left; display: inline; width:30%; overflow-x: scroll} +div.item {border-bottom: thin solid black; border-top: thin solid black; border-left: thin solid black; padding: 5px; margin: 5px;} +div.stamp { border: thin solid black; padding: 5px; margin: 5px;} +div.fulltrace {border-bottom: thin solid black; border-top: thin solid black; border-left: thin solid black; padding: 5px; margin: 5px;} diff --git a/tests/report-styles/report.css b/tests/report-styles/report.css index e0a59c3..0afbf56 100644 --- a/tests/report-styles/report.css +++ b/tests/report-styles/report.css @@ -19,3 +19,8 @@ div.cell1 {display:inline; float: left;height:auto} div.cell2 {display:inline; float: right;height:auto} a.classSumaryName{font-weight:bold} + +a.logLink:link {color: black} +a.logLink:active {color: black; } +a.logLink:visited {color: black;} +a.logLink:hover {color: black;font-weight: bolder;} |