You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/07/05 19:28:09 UTC

svn commit: r1500078 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck: ./ src/main/java/org/apache/chemistry/opencmis/tck/report/ src/main/java/org/apache/chemistry/opencmis/tck/runner/

Author: fmui
Date: Fri Jul  5 17:28:09 2013
New Revision: 1500078

URL: http://svn.apache.org/r1500078
Log:
TCK report improvements

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/pom.xml
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/CoreHtmlReport.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/pom.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/pom.xml?rev=1500078&r1=1500077&r2=1500078&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/pom.xml (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/pom.xml Fri Jul  5 17:28:09 2013
@@ -51,6 +51,7 @@
                                  
                                  <!-- build timestamp -->
                                  <echo file="${targetdir}/generated-resources/META-INF/build-timestamp.txt">Version: ${project.version} / Revision: ${revision} / Build: ${timestamp}</echo>
+                                 <echo file="${targetdir}/generated-resources/META-INF/tck-revision.txt">${revision}</echo>
                             </target>
                         </configuration>
                         <goals>

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/CoreHtmlReport.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/CoreHtmlReport.java?rev=1500078&r1=1500077&r2=1500078&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/CoreHtmlReport.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/CoreHtmlReport.java Fri Jul  5 17:28:09 2013
@@ -19,8 +19,6 @@
 package org.apache.chemistry.opencmis.tck.report;
 
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Date;
 import java.util.List;
@@ -33,17 +31,25 @@ import org.apache.chemistry.opencmis.tck
 import org.apache.chemistry.opencmis.tck.CmisTestGroup;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.CmisTestResultStatus;
+import org.apache.chemistry.opencmis.tck.runner.AbstractRunner;
 
 /**
  * HTML Report without header and footer.
  */
 public class CoreHtmlReport extends AbstractCmisTestReport {
+
+    private int stackTraceCounter;
+    private String revision;
+
     public CoreHtmlReport() {
     }
 
     @Override
     public void createReport(Map<String, String> parameters, List<CmisTestGroup> groups, Writer writer)
             throws IOException {
+        stackTraceCounter = 0;
+        revision = parameters.get(AbstractRunner.TCK_REVISION_PARAMETER);
+
         writer.write("<h1>OpenCMIS TCK Report</h1>\n");
         writer.write((new Date()) + "\n");
 
@@ -74,14 +80,25 @@ public class CoreHtmlReport extends Abst
     }
 
     public static void printStyle(Writer writer) throws IOException {
-        writer.write("<style TYPE=\"text/css\">\n");
-        writer.write(".tckResultINFO { margin-left: 5px; margin-right: 5px; }\n");
-        writer.write(".tckResultSKIPPED { margin-left: 5px; margin-right: 5px; background-color: #FFFFFF; }\n");
-        writer.write(".tckResultOK { margin-left: 5px; margin-right: 5px; background-color: #00FF00; }\n");
-        writer.write(".tckResultWARNING { margin-left: 5px; margin-right: 5px; background-color: #FFFF00; }\n");
-        writer.write(".tckResultFAILURE { margin-left: 5px; margin-right: 5px; background-color: #FF6000; }\n");
-        writer.write(".tckResultUNEXPECTED_EXCEPTION { margin-left: 5px; margin-right: 5px; background-color: #FF0000; }\n");
-        writer.write("</style>");
+        writer.write("<style type=\"text/css\">\n");
+        writer.write("body { font-family: sans-serif; }\n");
+        writer.write(".tckResultINFO { margin-left: 10px; margin-right: 10px; padding: 2px; }\n");
+        writer.write(".tckResultSKIPPED { margin-left: 10px; margin-right: 10px; padding: 2px; background-color: #FFFFFF; }\n");
+        writer.write(".tckResultOK { margin-left: 10px; margin-right: 5px; padding: 2px; background-color: #00FF00; }\n");
+        writer.write(".tckResultWARNING { margin-left: 10px; margin-right: 10px; padding: 2px; background-color: #FFFF00; }\n");
+        writer.write(".tckResultFAILURE { margin-left: 10px; margin-right: 10px; padding: 2px; background-color: #FF6000; }\n");
+        writer.write(".tckResultUNEXPECTED_EXCEPTION { margin-left: 10px; margin-right: 10px; padding: 2px; background-color: #FF0000; }\n");
+        writer.write(".tckTraceLink { cursor: pointer; text-decoration: underline; }\n");
+        writer.write(".tckTrace { margin-left: 10px; margin-right: 10px; padding: 2px; border:2px solid #777777; background-color: #DDDDDD; }\n");
+        writer.write("</style>\n");
+    }
+
+    public static void printJavaScript(Writer writer) throws IOException {
+        writer.write("<script type=\"text/javascript\">\n");
+        writer.write("function tckToggleDisplay(id) {\n");
+        writer.write("(function(style) { style.display = style.display === 'none' ? '' : 'none'; })(document.getElementById(id).style);\n");
+        writer.write("}\n");
+        writer.write("</script>\n");
     }
 
     private void printGroupResults(CmisTestGroup group, Writer writer) throws IOException {
@@ -99,7 +116,7 @@ public class CoreHtmlReport extends Abst
             for (CmisTest test : group.getTests()) {
                 printTestResults(test, writer);
             }
-        }        
+        }
     }
 
     private void printTestResults(CmisTest test, Writer writer) throws IOException {
@@ -123,30 +140,66 @@ public class CoreHtmlReport extends Abst
     }
 
     private void printResult(CmisTestResult result, Writer writer) throws IOException {
+        stackTraceCounter++;
+        String stackTraceId = "tckTrace" + stackTraceCounter;
+        String exceptionId = "tckException" + stackTraceCounter;
+
+        boolean hasStackTrace = result.getStackTrace() != null && result.getStackTrace().length > 0;
+        boolean hasException = result.getStatus() == CmisTestResultStatus.UNEXPECTED_EXCEPTION
+                && result.getException() != null;
+
         writer.write("<div class=\"tckResult" + result.getStatus().name() + "\">\n");
 
         writer.write("<b>" + result.getStatus() + "</b>: " + escape(result.getMessage()));
 
-        if ((result.getStackTrace() != null) && (result.getStackTrace().length > 0)) {
-            writer.write(" (" + escape(result.getStackTrace()[0].getFileName()) + ":"
-                    + result.getStackTrace()[0].getLineNumber() + ")");
+        if (hasStackTrace) {
+            writer.write(" (" + getSourceCodeLink(result.getStackTrace()[0], revision) + ")");
+            writer.write(" [<span class=\"tckTraceLink\" onClick=\"tckToggleDisplay('" + stackTraceId
+                    + "');\">stacktrace</span>]");
+        }
+
+        if (hasException) {
+            writer.write(" [<span class=\"tckTraceLink\" onClick=\"tckToggleDisplay('" + exceptionId
+                    + "');\">exception details</span>]");
         }
 
         writer.write("<br/>\n");
 
-        if (result.getStatus() == CmisTestResultStatus.UNEXPECTED_EXCEPTION && result.getException() != null) {
-            final Writer sw = new StringWriter();
-            final PrintWriter pw = new PrintWriter(sw);
-            result.getException().printStackTrace(pw);
+        if (hasStackTrace) {
+            writer.write("<div class=\"tckTrace\" id=\"" + stackTraceId + "\" style=\"display:none\">\n");
 
-            writer.write("\n<!--\nStacktrace:\n\n" + escape(sw.toString()) + "-->\n");
+            for (StackTraceElement ste : result.getStackTrace()) {
+                if (AbstractRunner.class.getName().equals(ste.getClassName())) {
+                    break;
+                }
+                writer.write(ste.getClassName() + "." + ste.getMethodName() + "(" + getSourceCodeLink(ste, revision)
+                        + ")<br/>\n");
+            }
+
+            writer.write("</div>\n");
+        }
+
+        if (hasException) {
+            writer.write("<div class=\"tckTrace\" id=\"" + exceptionId + "\" style=\"display:none\">\n");
+            writer.write("<b>Exception stack trace:</b><br/><br/>\n");
+
+            for (StackTraceElement ste : result.getException().getStackTrace()) {
+                if (AbstractRunner.class.getName().equals(ste.getClassName())) {
+                    break;
+                }
+                writer.write(ste.getClassName() + "." + ste.getMethodName() + "(" + getSourceCodeLink(ste, revision)
+                        + ")<br/>\n");
+            }
 
             if (result.getException() instanceof CmisBaseException) {
                 CmisBaseException cbe = (CmisBaseException) result.getException();
                 if (cbe.getErrorContent() != null) {
-                    writer.write("\n<!--\nError Content:\n\n" + escape(cbe.getErrorContent()) + "-->\n");
+                    writer.write("<br/>\n<b>Error content:</b><br/><br/><pre>\n");
+                    writer.write(escape(cbe.getErrorContent()) + "</pre>\n");
                 }
             }
+
+            writer.write("</div>\n");
         }
 
         for (CmisTestResult child : result.getChildren()) {
@@ -156,6 +209,42 @@ public class CoreHtmlReport extends Abst
         writer.write("</div>\n");
     }
 
+    protected String getSourceCodeLink(StackTraceElement ste, String revision) {
+        StringBuilder result = new StringBuilder();
+
+        if (!ste.getClassName().startsWith("org.apache.chemistry.opencmis.tck.")) {
+            result.append(escape(ste.getFileName()));
+            if (ste.getLineNumber() > 0) {
+                result.append(":");
+                result.append(ste.getLineNumber());
+            }
+        } else {
+            result.append("<a href=\"https://svn.apache.org/viewvc/chemistry/opencmis/trunk/"
+                    + "chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/");
+            result.append(ste.getClassName().replaceAll("\\.", "/"));
+            result.append(".java?view=markup");
+            if (revision != null) {
+                result.append("&revision=");
+                result.append(revision);
+            }
+            if (ste.getLineNumber() > 0) {
+                result.append("#l");
+                result.append(ste.getLineNumber());
+            }
+
+            result.append("\" target=\"_blank\">");
+
+            result.append(escape(ste.getFileName()));
+            if (ste.getLineNumber() > 0) {
+                result.append(":");
+                result.append(ste.getLineNumber());
+            }
+
+            result.append("</a>");
+        }
+        return result.toString();
+    }
+
     protected String escape(String s) {
         if (s == null) {
             return "";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java?rev=1500078&r1=1500077&r2=1500078&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java Fri Jul  5 17:28:09 2013
@@ -38,6 +38,7 @@ public class HtmlReport extends CoreHtml
         writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
         writer.write("<html><head>\n<title>OpenCMIS TCK Report</title>\n");
         printStyle(writer);
+        printJavaScript(writer);
         writer.write("</head><body>\n");
 
         super.createReport(parameters, groups, writer);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java?rev=1500078&r1=1500077&r2=1500078&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java Fri Jul  5 17:28:09 2013
@@ -44,6 +44,8 @@ public abstract class AbstractRunner {
     public static final String DEFAULT_TCK_GROUPS = "/cmis-tck-groups.txt";
     public static final String TCK_BUILD_TIMESTAMP = "/META-INF/build-timestamp.txt";
     public static final String TCK_BUILD_TIMESTAMP_PARAMETER = "org.apache.chemistry.opencmis.tck.timestamp";
+    public static final String TCK_REVISION = "/META-INF/tck-revision.txt";
+    public static final String TCK_REVISION_PARAMETER = "org.apache.chemistry.opencmis.tck.revision";
 
     private Map<String, String> parameters;
     private final List<CmisTestGroup> groups = new ArrayList<CmisTestGroup>();
@@ -66,8 +68,12 @@ public abstract class AbstractRunner {
             parameters.put(key.toString(), System.getProperties().getProperty(key.toString()));
         }
 
-        // set TCK build timestamp
+        // set TCK build timestamp and revision
         parameters.put(TCK_BUILD_TIMESTAMP_PARAMETER, loadTCKTimestamp());
+        String revision = loadTCKRevision();
+        if (revision != null) {
+            parameters.put(TCK_REVISION_PARAMETER, revision);
+        }
     }
 
     public void loadParameters(File file) throws IOException {
@@ -140,6 +146,30 @@ public abstract class AbstractRunner {
         return result.toString();
     }
 
+    private String loadTCKRevision() {
+        String result = null;
+
+        InputStream stream = getClass().getResourceAsStream(TCK_REVISION);
+        if (stream != null) {
+            try {
+                BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+                result = br.readLine();
+                br.close();
+            } catch (Exception e) {
+            }
+
+            if (result != null) {
+                try {
+                    result = String.valueOf(Integer.parseInt(result.trim()));
+                } catch (NumberFormatException nfe) {
+                    result = null;
+                }
+            }
+        }
+
+        return result;
+    }
+
     // --- groups ---
 
     public void loadDefaultTckGroups() throws Exception {