You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/02/18 12:55:20 UTC

cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/modules ActionLoaderTest.java

epugh       2004/02/18 03:55:20

  Modified:    src/test/org/apache/turbine/test
                        EnhancedMockHttpSession.java BaseTestCase.java
               src/test/org/apache/turbine/modules ActionLoaderTest.java
  Log:
  Update test case infrastructure
  
  Revision  Changes    Path
  1.2       +14 -2     jakarta-turbine-2/src/test/org/apache/turbine/test/EnhancedMockHttpSession.java
  
  Index: EnhancedMockHttpSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/test/org/apache/turbine/test/EnhancedMockHttpSession.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EnhancedMockHttpSession.java	11 Sep 2003 15:00:08 -0000	1.1
  +++ EnhancedMockHttpSession.java	18 Feb 2004 11:55:20 -0000	1.2
  @@ -62,6 +62,9 @@
    */
   public class EnhancedMockHttpSession extends MockHttpSession
   {
  +    private boolean isNew = true;
  +    private int maxInactiveInterval =0;
  +    
       /**
        *
        */
  @@ -75,8 +78,17 @@
        */
       public boolean isNew()
       {
  -        return true;
  +        return isNew;
       }
  +    
  +    public void setMaxInactiveInterval(int maxInactiveInterval){
  +        this.maxInactiveInterval =maxInactiveInterval;
  +    }
  +    
  +    public int getMaxInactiveInterval(){
  +        return maxInactiveInterval;
  +    }
  +    
       /**
        * The underlying mock objects throws an Assert failure if we don't have
        * an attribute.  However, in Turbine, getting a null is okay, it just 
  
  
  
  1.4       +18 -11    jakarta-turbine-2/src/test/org/apache/turbine/test/BaseTestCase.java
  
  Index: BaseTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/test/org/apache/turbine/test/BaseTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BaseTestCase.java	7 Jun 2003 11:46:11 -0000	1.3
  +++ BaseTestCase.java	18 Feb 2004 11:55:20 -0000	1.4
  @@ -59,14 +59,17 @@
   import java.io.FileNotFoundException;
   import java.util.Properties;
   
  -import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.logging.impl.Log4jFactory;
  +import javax.servlet.ServletConfig;
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletResponse;
   
  -import org.apache.log4j.PropertyConfigurator;
  +import junit.framework.TestCase;
   
  +import org.apache.log4j.PropertyConfigurator;
   import org.apache.turbine.Turbine;
  -
  -import junit.framework.TestCase;
  +import org.apache.turbine.services.TurbineServices;
  +import org.apache.turbine.services.rundata.RunDataService;
  +import org.apache.turbine.util.RunData;
   
   /**
    * Base functionality to be extended by all Apache Turbine test cases.  Test
  @@ -100,11 +103,15 @@
                       + log4jFile);
           }
   
  -        //
  -        // Set up Commons Logging to use the Log4J Logging
  -        //
  -        System.getProperties().setProperty(LogFactory.class.getName(),
  -                Log4jFactory.class.getName());
  +
  +    }
  +    
  +    protected RunData getRunData(HttpServletRequest request,HttpServletResponse response,ServletConfig config) throws Exception {
  +        RunDataService rds =
  +            (RunDataService) TurbineServices.getInstance().getService(
  +                    RunDataService.SERVICE_NAME);
  +        RunData runData = rds.getRunData(request, response, config);        
  +        return runData;
       }
   }
   
  
  
  
  1.3       +12 -19    jakarta-turbine-2/src/test/org/apache/turbine/modules/ActionLoaderTest.java
  
  Index: ActionLoaderTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/test/org/apache/turbine/modules/ActionLoaderTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ActionLoaderTest.java	26 Sep 2003 17:49:46 -0000	1.2
  +++ ActionLoaderTest.java	18 Feb 2004 11:55:20 -0000	1.3
  @@ -54,19 +54,19 @@
    */
   
   import java.util.Vector;
  +
   import javax.servlet.ServletConfig;
   import javax.servlet.http.HttpServletResponse;
   
   import org.apache.turbine.Turbine;
   import org.apache.turbine.om.security.User;
  -import org.apache.turbine.services.TurbineServices;
  -import org.apache.turbine.services.rundata.RunDataService;
   import org.apache.turbine.services.template.TemplateService;
   import org.apache.turbine.test.BaseTestCase;
   import org.apache.turbine.test.EnhancedMockHttpServletRequest;
   import org.apache.turbine.test.EnhancedMockHttpSession;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.TurbineConfig;
  +
   import com.mockobjects.servlet.MockHttpServletResponse;
   import com.mockobjects.servlet.MockServletConfig;
   /**
  @@ -138,9 +138,9 @@
   	 * @throws Exception If something goes wrong with the unit test
   	 */
   	public void testDoPerformBubblesException() throws Exception {
  -		RunData data = getRunData();
  +		RunData data = getRunData(request,response,config);
  +		data.setAction("VelocityActionThrowsException");
   		try {
  -			String defaultPage = "VelocityPage";
   			ActionLoader.getInstance().exec(data, data.getAction());
   			fail("Should have thrown an exception");
   		} catch (Exception e) {
  @@ -156,12 +156,12 @@
   	public void testActionEventBubblesException() throws Exception {
   		// can't seem to figure out how to setup the Mock Request with the right parameters...
   		request.setupAddParameter("eventSubmit_doCauseexception", "foo");
  -		RunData data = getRunData();
  +		RunData data = getRunData(request,response,config);
  +		data.setAction("VelocityActionThrowsException");
   		data.getParameters().add("eventSubmit_doCauseexception", "foo");
   		assertTrue(
   			data.getParameters().containsKey("eventSubmit_doCauseexception"));
   		try {
  -			String defaultPage = "VelocityPage";
   			ActionLoader.getInstance().exec(data, data.getAction());
   			fail("Should have bubbled out an exception thrown by the action.");
   		} catch (Exception e) {
  @@ -179,9 +179,9 @@
   	public void testDoPerformDoesntBubbleException() throws Exception {
   		Turbine.getConfiguration().setProperty("action.event.bubbleexception",Boolean.FALSE);
   		assertFalse(Turbine.getConfiguration().getBoolean("action.event.bubbleexception"));
  -		RunData data = getRunData();
  +		RunData data = getRunData(request,response,config);
  +		data.setAction("VelocityActionThrowsException");
   		try {
  -			String defaultPage = "VelocityPage";
   			ActionLoader.getInstance().exec(data, data.getAction());
   		
   		} catch (Exception e) {
  @@ -199,20 +199,20 @@
   		// can't seem to figure out how to setup the Mock Request with the right parameters...
   		Turbine.getConfiguration().setProperty("action.event.bubbleexception",Boolean.FALSE);
   		request.setupAddParameter("eventSubmit_doCauseexception", "foo");
  -		RunData data = getRunData();
  +		RunData data = getRunData(request,response,config);
  +		data.setAction("VelocityActionThrowsException");
   		data.getParameters().add("eventSubmit_doCauseexception", "foo");
   		assertTrue(
   			data.getParameters().containsKey("eventSubmit_doCauseexception"));
   		
   		try {
  -			String defaultPage = "VelocityPage";
   			ActionLoader.getInstance().exec(data, data.getAction());			
   		} catch (Exception e) {
   			fail("Should NOT have thrown an exception:" + e.getMessage());
   		}
   	}
   	public void testNonexistentActionCausesError() throws Exception {
  -		RunData data = getRunData();
  +	    RunData data = getRunData(request,response,config);
   		data.setAction("ImaginaryAction");
   		try {
   			PageLoader.getInstance().exec(data, "boo");
  @@ -221,12 +221,5 @@
   			//good
   		}
   	}
  -	private RunData getRunData() throws Exception {
  -		RunDataService rds =
  -			(RunDataService) TurbineServices.getInstance().getService(
  -				RunDataService.SERVICE_NAME);
  -		RunData runData = rds.getRunData(request, response, config);
  -		runData.setAction("VelocityActionThrowsException");
  -		return runData;
  -	}
  +	
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org