Clover coverage report - Cactus 1.4b1 for J2EE API 12
Coverage timestamp: Mon Jul 29 2002 00:33:16 BST
file stats: LOC: 122   Methods: 3
NCLOC: 59   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractWebTestController.java 0% 0% 0% 0%
 1   
 /*   Generated by AspectJ version 1.0.5 */
 2   
 package org.apache.cactus.server;
 3   
 import javax.servlet.ServletException;
 4   
 import javax.servlet.http.HttpServletRequest;
 5   
 import org.apache.cactus.HttpServiceDefinition;
 6   
 import org.apache.cactus.ServiceEnumeration;
 7   
 import org.apache.commons.logging.Log;
 8   
 import org.apache.commons.logging.LogFactory;
 9   
 
 10   
 /** 
 11   
  * Controller that extracts the requested service from the HTTP request and 
 12   
  * executes the request by calling a <code>WebTestCaller</code>. There 
 13   
  * are 2 services available : one for executing the test and one for returning 
 14   
  * the test result. 
 15   
  * 
 16   
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 17   
  * 
 18   
  * @version $Id: AbstractWebTestController.java,v 1.4 2002/07/22 12:26:04 vmassol Exp $ 
 19   
  */
 20   
 public abstract class AbstractWebTestController implements TestController {
 21   
   /** 
 22   
        * The logger 
 23   
        */
 24   
   private static Log LOGGER;
 25   
   /** 
 26   
        * @param theObjects the implicit objects coming from the redirector 
 27   
        * @return the test caller that will be used to execute the test 
 28   
        */
 29   
   protected abstract AbstractWebTestCaller getTestCaller(WebImplicitObjects theObjects);
 30   
 
 31   
   /** 
 32   
        * Handles the incoming request by extracting the requested service and 
 33   
        * calling the correct method on a <code>WebTestCaller</code>. 
 34   
        * 
 35   
        * @param theObjects the implicit objects (they are different for the 
 36   
        *                   different redirectors) 
 37   
        * @exception ServletException if an error occurs when servicing the 
 38   
        *            request 
 39   
        */
 40  0
   public void handleRequest(ImplicitObjects theObjects) throws ServletException {
 41  0
     WebImplicitObjects webImplicitObjects = (WebImplicitObjects)theObjects;
 42  0
     try {
 43  0
       String serviceName = this.getServiceName(webImplicitObjects.getHttpServletRequest());
 44  0
       AbstractWebTestCaller caller = this.getTestCaller(webImplicitObjects);
 45  0
       if (ServiceEnumeration.CALL_TEST_SERVICE.equals(serviceName)) {
 46  0
         caller.doTest();
 47  0
       } else if (ServiceEnumeration.GET_RESULTS_SERVICE.equals(serviceName)) {
 48  0
         caller.doGetResults();
 49  0
       } else if (ServiceEnumeration.RUN_TEST_SERVICE.equals(serviceName)) {
 50  0
         caller.doRunTest();
 51   
       } else {
 52  0
         String message = "Unknown service [" + serviceName + "] in HTTP request.";
 53  0
         AbstractWebTestController.LOGGER.error(message);
 54  0
         throw new ServletException(message);
 55   
       } 
 56   
     } catch (NoClassDefFoundError e) {
 57  0
       if (e.getMessage().startsWith("junit/framework")) {
 58  0
         String message = 
 59   
             "You must put the JUnit jar in your server classpath (in WEB-INF/lib for example)";
 60  0
         AbstractWebTestController.LOGGER.error(message, e);
 61  0
         throw new ServletException(message, e);
 62   
       } else {
 63  0
         String message = "You are missing a jar in your classpath (class [" + e.getMessage() + 
 64   
             "] could not " + "be found";
 65  0
         AbstractWebTestController.LOGGER.error(message, e);
 66  0
         throw new ServletException(message, e);
 67   
       } 
 68   
     } 
 69   
   } 
 70   
 
 71   
   /** 
 72   
        * @param theRequest the HTTP request 
 73   
        * @return the service name of the service to call (there are 2 services 
 74   
        *         "do test" and "get results"), extracted from the HTTP request 
 75   
        * @exception ServletException if the service to execute is missing from 
 76   
        *            the HTTP request 
 77   
        */
 78  0
   private String getServiceName(HttpServletRequest theRequest) throws ServletException {
 79  0
     String queryString = theRequest.getQueryString();
 80  0
     String serviceName = ServletUtil.getQueryStringParameter(queryString, "Cactus_Service");
 81  0
     if (serviceName == null) {
 82  0
       String message = 
 83   
           "Missing service name parameter [Cactus_Service] in HTTP request. Received query string is [" 
 84   
           + queryString + "].";
 85  0
       AbstractWebTestController.LOGGER.debug(message);
 86  0
       throw new ServletException(message);
 87   
     } 
 88  0
     AbstractWebTestController.LOGGER.debug("Service to call = " + serviceName);
 89  0
     return serviceName;
 90   
   } 
 91   
 
 92   
   /** 
 93   
    * Controller that extracts the requested service from the HTTP request and 
 94   
    * executes the request by calling a <code>WebTestCaller</code>. There 
 95   
    * are 2 services available : one for executing the test and one for returning 
 96   
    * the test result. 
 97   
    * 
 98   
    * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 99   
    * 
 100   
    * @version $Id: AbstractWebTestController.java,v 1.4 2002/07/22 12:26:04 vmassol Exp $ 
 101   
    */
 102  0
   public AbstractWebTestController() {
 103  0
     super();
 104   
   } 
 105   
   /** 
 106   
    * Controller that extracts the requested service from the HTTP request and 
 107   
    * executes the request by calling a <code>WebTestCaller</code>. There 
 108   
    * are 2 services available : one for executing the test and one for returning 
 109   
    * the test result. 
 110   
    * 
 111   
    * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 112   
    * 
 113   
    * @version $Id: AbstractWebTestController.java,v 1.4 2002/07/22 12:26:04 vmassol Exp $ 
 114   
    */
 115   
   static {
 116   
     /** 
 117   
          * The logger 
 118   
          */
 119  0
     AbstractWebTestController.LOGGER = LogFactory.getLog(AbstractWebTestController.class);
 120   
   } 
 121   
 
 122   
 }