incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1067200 - in /sling/whiteboard/bdelacretaz/junit/core/src/main: java/org/apache/sling/junit/impl/ java/org/apache/sling/junit/impl/servlet/ resources/
Date Fri, 04 Feb 2011 15:42:28 GMT
Author: bdelacretaz
Date: Fri Feb  4 15:42:27 2011
New Revision: 1067200

URL: http://svn.apache.org/viewvc?rev=1067200&view=rev
Log:
SLING-1963 - basic HTML rendering for test servlet

Added:
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java
  (with props)
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java
  (with props)
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/JUnitServlet.java
      - copied, changed from r1067179, sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/JUnitServlet.java
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/PlainTextRenderer.java
      - copied, changed from r1067118, sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/PlainTextRunListener.java
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java
  (with props)
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java
  (with props)
    sling/whiteboard/bdelacretaz/junit/core/src/main/resources/
    sling/whiteboard/bdelacretaz/junit/core/src/main/resources/junit.css   (with props)
Removed:
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/JUnitServlet.java
    sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/PlainTextRunListener.java

Added: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java?rev=1067200&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java
(added)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java
Fri Feb  4 15:42:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.junit.impl.servlet;
+
+import java.io.PrintWriter;
+
+/** Simple HTML output filtering */
+public class HtmlFilter {
+    static void escape(PrintWriter w, String str) {
+        for(int i=0 ; i < str.length(); i++) {
+            final char c = str.charAt(i);
+            if(c == '<') {
+                w.write("&lt;");
+            } else if (c == '>') {
+                w.write("&gt;");
+            } else if(c == '&') {
+                w.write("&amp;");
+            } else {
+                w.write(c);
+            }
+        }
+    }
+}

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlFilter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java?rev=1067200&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java
(added)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java
Fri Feb  4 15:42:27 2011
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.junit.impl.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+class HtmlRenderer extends Renderer {
+
+    private PrintWriter output;
+    
+    public void info(String cssClass, String str) {
+        output.println("<p class='" + cssClass + "'>");
+        HtmlFilter.escape(output, str);
+        output.println("</p>");
+    }
+    
+    public void list(String cssClass, List<String> data) {
+        output.println("<ul class='testNames'>");
+        for(String str : data) {
+            output.println("<li>");
+            HtmlFilter.escape(output, str);
+            output.println("</li>");
+        }
+        output.println("</ul>");
+    }
+    
+    public void title(int level, String title) {
+        output.print("<h" + level + ">");
+        HtmlFilter.escape(output, title);
+        output.print("</h" + level + ">");
+    }
+
+    public void setup(HttpServletResponse response, String pageTitle) throws IOException,
UnsupportedEncodingException {
+        response.setContentType("text/html");
+        response.setCharacterEncoding("UTF-8");
+        output = response.getWriter();
+        output.println("<html><head>");
+        output.println("<link rel='stylesheet' type='text/css' href='" + JUnitServlet.CSS
+ "'/>");
+        output.print("<title>");
+        HtmlFilter.escape(output, pageTitle);
+        output.println("</title>");
+        output.println("</head><body><h1>");
+        HtmlFilter.escape(output, pageTitle);
+        output.println("</h1>");
+    }
+    
+    public void cleanup() {
+        output.println("</body>");
+        output.println("</html>");
+    }
+    
+    @Override
+    public void testFailure(Failure failure) throws Exception {
+        super.testFailure(failure);
+        output.print("<div class='failure'><h3>");
+        output.print("TEST FAILED: ");
+        HtmlFilter.escape(output, failure.getTestHeader());
+        output.print("</h3><div class='failureDetails'>");
+        HtmlFilter.escape(output, failure.toString());
+        output.println("</div></div>");
+    }
+
+    @Override
+    public void testFinished(Description description) throws Exception {
+        super.testFinished(description);
+        output.print("<p class='finished'>Test finished: ");
+        HtmlFilter.escape(output, description.toString());
+        output.println("</p>");
+    }
+
+    @Override
+    public void testIgnored(Description description) throws Exception {
+        super.testIgnored(description);
+        output.print("<p class='ignored'><h3>TEST IGNORED</h3><b>");
+        HtmlFilter.escape(output, description.toString());
+        output.println("</b></p>");
+    }
+
+    private void counter(String name, String cssName, int value) {
+        final String cssClass = cssName + (value > 0 ? "NonZero" : "Zero");
+        output.print("<span class='");
+        output.print(cssClass);
+        output.print("'>");
+        HtmlFilter.escape(output, name);
+        output.print(":");
+        HtmlFilter.escape(output, String.valueOf(value));
+        output.println("</span>");
+    }
+    
+    @Override
+    public void testRunFinished(Result result) throws Exception {
+        super.testRunFinished(result);
+        String cssClass = "testRun ";
+        if(result.getFailureCount() > 0) {
+            cssClass += "failure";
+        } else if(result.getIgnoreCount() > 0) {
+            cssClass += "ignored";
+        } else {
+            cssClass += "success";
+        }
+        
+        output.println("<p class='testRun'>");
+        output.print("TEST RUN FINISHED: ");
+        counter("tests", "testCount", result.getRunCount());
+        output.print(", ");
+        counter("failures", "failureCount", result.getFailureCount());
+        output.print(", ");
+        counter("ignored", "ignoredCount", result.getIgnoreCount());
+        output.println("</p>");
+    }
+
+    @Override
+    public void testRunStarted(Description description)
+            throws Exception {
+        super.testRunStarted(description);
+    }
+
+    @Override
+    public void testStarted(Description description) throws Exception {
+        super.testStarted(description);
+        output.println("<div class='test'>");
+    }
+}

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/HtmlRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Copied: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/JUnitServlet.java
(from r1067179, sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/JUnitServlet.java)
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/JUnitServlet.java?p2=sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/JUnitServlet.java&p1=sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/JUnitServlet.java&r1=1067179&r2=1067200&rev=1067200&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/JUnitServlet.java
(original)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/JUnitServlet.java
Fri Feb  4 15:42:27 2011
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.junit.impl;
+package org.apache.sling.junit.impl.servlet;
 
 import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -47,6 +48,8 @@ public class JUnitServlet extends HttpSe
     
     private final Logger log = LoggerFactory.getLogger(getClass());
     
+    public static final String CSS = "junit.css";
+    
     /** TODO make this configurable */
     public static final String SERVLET_PATH = "/system/sling/junit";
     
@@ -55,7 +58,7 @@ public class JUnitServlet extends HttpSe
     
     @Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY)
     private HttpService httpService;
-
+    
     protected void bindHttpService(HttpService h) throws ServletException, NamespaceException
{
         httpService = h;
         httpService.registerServlet(SERVLET_PATH, this, null, null);
@@ -68,47 +71,97 @@ public class JUnitServlet extends HttpSe
         log.info("Servlet unregistered from path {}", SERVLET_PATH);
     }
     
+    /** Return the list of available tests
+     * @param prefix optionally select only names that match this prefix
+     */
+    private List<String> getTestNames(String prefix) {
+        final Collection<String> testClassesCollection = testsManager.getTestNames();
+        final List<String> testClasses = new LinkedList<String>();
+        if(prefix == null || prefix.length() == 0) {
+            testClasses.addAll(testClassesCollection);
+        } else {
+            for(String name : testClassesCollection) {
+                if(name.startsWith(prefix)) {
+                    testClasses.add(name);
+                }
+            }
+        }
+        Collections.sort(testClasses);
+        return testClasses;
+    }
+    
+    private Renderer getRenderer(RequestInfo requestInfo) {
+        if(".txt".equals(requestInfo.extension)) {
+            return new PlainTextRenderer();
+        } else {
+            return new HtmlRenderer();
+        }
+    }
+    
+    private void sendCss(HttpServletResponse response) throws IOException {
+        final InputStream str = getClass().getResourceAsStream("/" + CSS);
+        if(str == null) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, CSS);
+        } else {
+            response.setContentType("text/css");
+            final OutputStream out = response.getOutputStream();
+            final byte[] buffer = new byte[16384];
+            int count = 0;
+            while( (count = str.read(buffer)) > 0) {
+                out.write(buffer, 0, count);
+            }
+            out.flush();
+        }
+    }
+    
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) 
     throws ServletException, IOException {
+        {
+            final String pi = request.getPathInfo();
+            if(pi != null && pi.endsWith(CSS)) {
+                sendCss(response);
+                return;
+            }
+        }
         
-        response.setContentType("text/plain");
-        response.setCharacterEncoding("UTF-8");
-        final PrintWriter pw = response.getWriter();
-        pw.println("This is " + getClass().getName());
-        pw.println();
+        final RequestInfo requestInfo = new RequestInfo(request);
+        final Renderer renderer = getRenderer(requestInfo);
+        log.debug("GET request: {}", requestInfo);
+
+        renderer.setup(response, getClass().getSimpleName());
+        
+        if(requestInfo.testSelector.length() > 0) {
+            renderer.info("info", "Test selector: " + requestInfo.testSelector); 
+        } else {
+            renderer.info("info", "Test selector is empty: " 
+                    + "add class name prefix + extension at the end of the URL to select
a subset of tests"); 
+        }
         
         // Any test classes?
-        final Collection<String> testClassesCollection = testsManager.getTestNames();
-        final List<String> testClasses = new LinkedList<String>();
-        testClasses.addAll(testClassesCollection);
-        Collections.sort(testClasses);
-        if(testClasses.isEmpty()) {
-            pw.println(
-                    "No test classes found, check the requirements of the active " +
+        final List<String> testNames = getTestNames(requestInfo.testSelector); 
+        if(testNames.isEmpty()) {
+            renderer.info(
+                    "warning",
+                    "No test classes found with prefix=" + requestInfo.testSelector
+                    + ", check the requirements of the active " +
                     "TestsProvider services for how to supply tests." 
                     );
-            return;
-        }
-        
-        // List test classes
-        pw.println("TEST CLASSES");
-        for(String className : testClasses) {
-            pw.println(className);
-        }
-        pw.println();
-
-        // Run tests
-        final JUnitCore junit = new JUnitCore();
-        junit.addListener(new PlainTextRunListener(pw));
-        try {
-            for(String className : testClasses) {
-                pw.println("**** RUNNING TESTS: " + className);
-                junit.run(testsManager.getTestClass(className));
-                pw.println();
+        } else {
+            renderer.title(2, "Test classes");
+            renderer.list("testNames", testNames);
+            
+            renderer.title(2, "Running tests");
+            final JUnitCore junit = new JUnitCore();
+            junit.addListener(renderer);
+            try {
+                for(String className : testNames) {
+                    renderer.title(3, className);
+                    junit.run(testsManager.getTestClass(className));
+                }
+            } catch(ClassNotFoundException cnfe) {
+                throw new ServletException("Test class not found", cnfe);
             }
-        } catch(ClassNotFoundException cnfe) {
-            throw new ServletException("Test class not found", cnfe);
         }
     }
 }
\ No newline at end of file

Copied: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/PlainTextRenderer.java
(from r1067118, sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/PlainTextRunListener.java)
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/PlainTextRenderer.java?p2=sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/PlainTextRenderer.java&p1=sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/PlainTextRunListener.java&r1=1067118&r2=1067200&rev=1067200&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/PlainTextRunListener.java
(original)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/PlainTextRenderer.java
Fri Feb  4 15:42:27 2011
@@ -14,44 +14,69 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.junit.impl;
+package org.apache.sling.junit.impl.servlet;
 
+import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
 
 import org.junit.runner.Description;
 import org.junit.runner.Result;
 import org.junit.runner.notification.Failure;
-import org.junit.runner.notification.RunListener;
 
-class PlainTextRunListener extends RunListener {
-    final PrintWriter pw;
+class PlainTextRenderer extends Renderer {
+    private PrintWriter output;
+    
+    public void setup(HttpServletResponse response, String pageTitle) throws IOException,
UnsupportedEncodingException {
+        response.setContentType("text/plain");
+        response.setCharacterEncoding("UTF-8");
+        output = response.getWriter();
+        title(1, pageTitle);
+    }
     
-    PlainTextRunListener(PrintWriter w) {
-        pw = w;
+    public void cleanup() {
+    }
+
+    public void info(String cssClass, String str) {
+        output.println(str);
     }
     
+    public void list(String cssClass, List<String> data) {
+        for(String str : data) {
+            output.println(str);
+        }
+    }
+    
+    public void title(int level, String title) {
+        output.print(title);
+        output.println(" ****");
+    }
+
     @Override
     public void testFailure(Failure failure) throws Exception {
         super.testFailure(failure);
-        pw.println("FAILURE " + failure);
+        output.println("FAILURE " + failure);
     }
 
     @Override
     public void testFinished(Description description) throws Exception {
         super.testFinished(description);
-        pw.println("FINISHED " + description);
+        output.println("FINISHED " + description);
     }
 
     @Override
     public void testIgnored(Description description) throws Exception {
         super.testIgnored(description);
-        pw.println("IGNORED " + description);
+        output.println("IGNORED " + description);
     }
 
     @Override
     public void testRunFinished(Result result) throws Exception {
         super.testRunFinished(result);
-        pw.println("TEST RUN FINISHED: "
+        output.println("TEST RUN FINISHED: "
                 + "tests:" + result.getRunCount()
                 + ", failures:" + result.getFailureCount()
                 + ", ignored:" + result.getIgnoreCount()

Added: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java?rev=1067200&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java
(added)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java
Fri Feb  4 15:42:27 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.junit.impl.servlet;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.runner.notification.RunListener;
+
+/** Renderer for our servlet output */
+abstract class Renderer extends RunListener {
+    abstract void setup(HttpServletResponse response, String pageTitle) throws IOException,
UnsupportedEncodingException;
+    abstract void cleanup();
+    abstract void list(String cssClass, List<String> data);
+    abstract void info(String cssClass, String info);
+    abstract void title(int level, String title);
+}

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/Renderer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java?rev=1067200&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java
(added)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java
Fri Feb  4 15:42:27 2011
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.junit.impl.servlet;
+
+import javax.servlet.http.HttpServletRequest;
+
+/** Parse information from a request */
+public class RequestInfo {
+    final String testSelector;
+    final String extension;
+
+    RequestInfo(HttpServletRequest request) {
+        String pathinfo = request.getPathInfo();
+        if (pathinfo == null) {
+            pathinfo = "";
+        } else if (pathinfo.startsWith("/")) {
+            pathinfo = pathinfo.substring(1);
+        }
+
+        final int pos = pathinfo.lastIndexOf('.');
+        if (pos >= 0) {
+            testSelector = pathinfo.substring(0, pos);
+            extension = pathinfo.substring(pos);
+        } else {
+            testSelector = pathinfo;
+            extension = "";
+        }
+    }
+
+    public String toString() {
+        return getClass().getSimpleName() + ", testSelector=[" + testSelector
+                + "], extension=[" + extension + "]";
+    }
+}

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/java/org/apache/sling/junit/impl/servlet/RequestInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/whiteboard/bdelacretaz/junit/core/src/main/resources/junit.css
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/junit/core/src/main/resources/junit.css?rev=1067200&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/junit/core/src/main/resources/junit.css (added)
+++ sling/whiteboard/bdelacretaz/junit/core/src/main/resources/junit.css Fri Feb  4 15:42:27
2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+body {
+  font-family: Verdana, Arial, sans-serif;
+}
+
+h1 {
+  border-bottom: solid red 1px;
+}
+
+h2,h3,h4 {
+  border-bottom: solid grey 1px;
+}
+
+.failureCountNonZero {
+  color:red;
+  font-weight:bold;
+}
+
+.ignoredCountNonZero {
+  color:red;
+}
+
+.failureDetails {
+  font-family: Courier New, Courier, monospaced;
+  margin-left: 1em;
+  margin-right: 1em;
+  padding: 1em;
+  border: solid red 1px;
+  background-color: #FFFFCC;
+}
+
+.failure h3 {
+  color:red;
+}
\ No newline at end of file

Propchange: sling/whiteboard/bdelacretaz/junit/core/src/main/resources/junit.css
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message