Author: rfeng Date: Mon Feb 11 17:22:44 2008 New Revision: 620684 URL: http://svn.apache.org/viewvc?rev=620684&view=rev Log: Add a list operation to show/run available test cases Removed: incubator/tuscany/java/sca/itest/services/src/main/webapp/ Modified: incubator/tuscany/java/sca/itest/pom.xml incubator/tuscany/java/sca/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitGeneratorMojo.java incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java Modified: incubator/tuscany/java/sca/itest/pom.xml URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/pom.xml?rev=620684&r1=620683&r2=620684&view=diff ============================================================================== --- incubator/tuscany/java/sca/itest/pom.xml (original) +++ incubator/tuscany/java/sca/itest/pom.xml Mon Feb 11 17:22:44 2008 @@ -298,7 +298,7 @@ web-junit-test - ${http.base}/${project.build.finalName}/junit + ${http.base}/${project.build.finalName}/junit?op=runAll integration-test @@ -345,7 +345,7 @@ ${project.build.directory}/${project.build.finalName}.war - ${http.base}/${project.build.finalName}/junit + ${http.base}/${project.build.finalName}/junit?op=list war @@ -392,7 +392,7 @@ web-junit-test - ${http.base}/${project.build.finalName}/junit + ${http.base}/${project.build.finalName}/junit?op=runAll integration-test @@ -439,7 +439,7 @@ ${project.build.directory}/${project.build.finalName}.war - ${http.base}/${project.build.finalName}/junit + ${http.base}/${project.build.finalName}/junit?op=list war @@ -488,7 +488,7 @@ web-junit-test - ${http.base}/${project.build.finalName}/junit + ${http.base}/${project.build.finalName}/junit?op=runAll integration-test @@ -586,7 +586,7 @@ test - ${http.base}/${project.build.finalName}/junit + ${http.base}/${project.build.finalName}/junit?op=runAll Modified: incubator/tuscany/java/sca/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java?rev=620684&r1=620683&r2=620684&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java (original) +++ incubator/tuscany/java/sca/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java Mon Feb 11 17:22:44 2008 @@ -172,15 +172,15 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - if(!junitEnabled) { + if (!junitEnabled) { chain.doFilter(request, response); return; } - + HttpServletRequest req = (HttpServletRequest)request; String path = req.getServletPath(); - - if(!"/junit".equals(path)) { + + if (!"/junit".equals(path)) { chain.doFilter(request, response); return; } @@ -190,11 +190,38 @@ Set testCases = null; // ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (query == null || "ALL".equals(query)) { - testCases = this.allTestCases; + String op = req.getParameter("op"); + if (query == null || op == null || "list".equalsIgnoreCase(op)) { + response.setContentType("text/html"); + ps.println(""); + ps.println("

Available Test Cases

"); + ps.println("

"); + ps.println(""); + for (String s : this.allTestCases) { + ps.print(""); + } + ps.println("
"); + ps.print("" + + s + + ""); + ps.println("
"); + ps.println("

"); + ps.println(""); + ps.println("

"); + return; } else { - String[] tests = query.split(","); - testCases = new HashSet(Arrays.asList(tests)); + if ("runAll".equalsIgnoreCase(op)) { + testCases = this.allTestCases; + } else { + String[] tests = req.getParameterValues("test"); + if (tests == null) { + tests = new String[0]; + } + testCases = new HashSet(Arrays.asList(tests)); + } } int errors = 0; Modified: incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java?rev=620684&r1=620683&r2=620684&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java (original) +++ incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java Mon Feb 11 17:22:44 2008 @@ -239,31 +239,22 @@ @SuppressWarnings("unchecked") public void initContextPath(ServletConfig config) { ServletContext context = config.getServletContext(); - int version = context.getMajorVersion() * 100 + context.getMinorVersion(); - + // The getContextPath() is introduced since Servlet 2.5 Method m; try { + // Try to get the method anyway since some ServletContext impl has this method even before 2.5 m = context.getClass().getMethod("getContextPath", new Class[] {}); - try { - contextPath = (String)m.invoke(context, new Object[] {}); - } catch (Exception e) { - throw new RuntimeException(e); + contextPath = (String)m.invoke(context, new Object[] {}); + } catch (Exception e) { + contextPath = config.getInitParameter("contextPath"); + if (contextPath == null) { + logger.warning("Servlet level is: " + context.getMajorVersion() + "." + context.getMinorVersion()); + throw new IllegalStateException( + "'contextPath' init parameter must be set for pre-2.5 servlet container"); } - } catch (NoSuchMethodException e) { - throw new IllegalStateException("'contextPath' init parameter must be set for pre-2.5 servlet container"); - } - - // Fall back for containers using old Servlet APIs - if (contextPath == null) { - contextPath = config.getInitParameter("contextPath"); } - - // contextPath == null => throw proper exception - if (contextPath == null) { - throw new IllegalArgumentException("Could not retrieve webapp contextPath either from servletContext or init Parameter"); - } - - logger.info("initContextPath: " + contextPath); + + logger.info("ContextPath: " + contextPath); } void destroy() { Modified: incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitGeneratorMojo.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitGeneratorMojo.java?rev=620684&r1=620683&r2=620684&view=diff ============================================================================== --- incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitGeneratorMojo.java (original) +++ incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitGeneratorMojo.java Mon Feb 11 17:22:44 2008 @@ -72,15 +72,11 @@ private final static String WEB_XML = ASL_HEADER + "\n" + "\n" - + "\n ${display-name}" + + "\n ${display-name}" + "\n " + "\n tuscany" + "\n org.apache.tuscany.sca.host.webapp.TuscanyServletFilter" + "\n " - + "\n " - + "\n tuscany" - + "\n /*" - + "\n " + "\n " + "\n junit" + "\n org.apache.tuscany.sca.host.webapp.junit.JUnitServletFilter" @@ -90,8 +86,12 @@ + "\n " + "\n " + "\n " + + "\n tuscany" + + "\n /*" + + "\n " + + "\n " + "\n junit" - + "\n /junit" + + "\n /junit/*" + "\n " + "\n\n"; Modified: incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java?rev=620684&r1=620683&r2=620684&view=diff ============================================================================== --- incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java (original) +++ incubator/tuscany/java/sca/tools/maven/maven-web-junit/src/main/java/org/apache/tuscany/tools/sca/web/junit/plugin/WebJUnitMojo.java Mon Feb 11 17:22:44 2008 @@ -84,7 +84,7 @@ reset(); if (url == null) { - url = "http://localhost:8080/" + project.getBuild().getFinalName() + "/junit"; + url = "http://localhost:8080/" + project.getBuild().getFinalName() + "/junit?op=runAll"; } if (testCases != null) { --------------------------------------------------------------------- To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org For additional commands, e-mail: tuscany-commits-help@ws.apache.org