2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Clover coverage report - Cactus 1.8dev for J2EE API 1.3
Coverage timestamp: Sun Mar 26 2006 18:50:18 BRT
file stats: LOC: 109   Methods: 3
NCLOC: 46   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
FilterTestCaller.java 50% 93.8% 100% 90.5%
coverage coverage
 1   
 /* 
 2   
  * ========================================================================
 3   
  * 
 4   
  * Copyright 2001-2004 The Apache Software Foundation.
 5   
  *
 6   
  * Licensed under the Apache License, Version 2.0 (the "License");
 7   
  * you may not use this file except in compliance with the License.
 8   
  * You may obtain a copy of the License at
 9   
  * 
 10   
  *   http://www.apache.org/licenses/LICENSE-2.0
 11   
  * 
 12   
  * Unless required by applicable law or agreed to in writing, software
 13   
  * distributed under the License is distributed on an "AS IS" BASIS,
 14   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   
  * See the License for the specific language governing permissions and
 16   
  * limitations under the License.
 17   
  * 
 18   
  * ========================================================================
 19   
  */
 20   
 package org.apache.cactus.internal.server;
 21   
 
 22   
 import java.io.IOException;
 23   
 import java.io.Writer;
 24   
 
 25   
 import java.lang.reflect.Field;
 26   
 
 27   
 import javax.servlet.http.HttpServletRequest;
 28   
 
 29   
 import junit.framework.TestCase;
 30   
 
 31   
 import org.apache.cactus.FilterTestCase;
 32   
 import org.apache.cactus.ServletURL;
 33   
 import org.apache.cactus.server.FilterConfigWrapper;
 34   
 import org.apache.cactus.server.HttpServletRequestWrapper;
 35   
 
 36   
 /**
 37   
  * Responsible for instanciating the <code>TestCase</code> class on the server
 38   
  * side, set up the implicit objects and call the test method.
 39   
  *
 40   
  * @version $Id: FilterTestCaller.java 238991 2004-05-22 11:34:50Z vmassol $
 41   
  */
 42   
 public class FilterTestCaller extends AbstractWebTestCaller
 43   
 {
 44   
     /**
 45   
      * @param theObjects the implicit objects coming from the redirector
 46   
      */
 47  10
     public FilterTestCaller(FilterImplicitObjects theObjects)
 48   
     {
 49  10
         super(theObjects);
 50   
     }
 51   
 
 52   
     /**
 53   
      * @see AbstractWebTestCaller#setTestCaseFields(TestCase)
 54   
      */
 55  5
     protected void setTestCaseFields(TestCase theTestInstance)
 56   
         throws Exception
 57   
     {
 58  5
         if (!(theTestInstance instanceof FilterTestCase))
 59   
         {
 60  0
             return; 
 61   
         }
 62   
 
 63  5
         FilterTestCase filterInstance = (FilterTestCase) theTestInstance;
 64  5
         FilterImplicitObjects filterImplicitObjects = 
 65   
             (FilterImplicitObjects) this.webImplicitObjects;
 66   
 
 67   
         // Sets the request field of the test case class
 68   
         // ---------------------------------------------
 69   
         // Extract from the HTTP request the URL to simulate (if any)
 70  5
         HttpServletRequest request = 
 71   
             filterImplicitObjects.getHttpServletRequest();
 72   
 
 73  5
         ServletURL url = ServletURL.loadFromRequest(request);
 74   
 
 75  5
         Field requestField = filterInstance.getClass().getField("request");
 76   
 
 77  5
         requestField.set(filterInstance, 
 78   
             new HttpServletRequestWrapper(request, url));
 79   
 
 80   
         // Set the response field of the test case class
 81   
         // ---------------------------------------------
 82  5
         Field responseField = filterInstance.getClass().getField("response");
 83   
 
 84  5
         responseField.set(filterInstance, 
 85   
             filterImplicitObjects.getHttpServletResponse());
 86   
 
 87   
         // Set the config field of the test case class
 88   
         // -------------------------------------------
 89  5
         Field configField = filterInstance.getClass().getField("config");
 90   
 
 91  5
         configField.set(filterInstance, 
 92   
             new FilterConfigWrapper(filterImplicitObjects.getFilterConfig()));
 93   
 
 94   
         // Set the filter chain of the test case class
 95   
         // -------------------------------------------
 96  5
         Field chainField = filterInstance.getClass().getField("filterChain");
 97   
 
 98  5
         chainField.set(filterInstance, filterImplicitObjects.getFilterChain());
 99   
     }
 100   
 
 101   
     /**
 102   
      * @see AbstractWebTestCaller#getResponseWriter()
 103   
      */
 104  5
     protected Writer getResponseWriter() throws IOException
 105   
     {
 106  5
         return this.webImplicitObjects.getHttpServletResponse().getWriter();
 107   
     }
 108   
 }
 109