test.util
Class MakumbaJspTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.cactus.internal.AbstractCactusTestCase
              extended by org.apache.cactus.ServletTestCase
                  extended by org.apache.cactus.JspTestCase
                      extended by test.util.MakumbaJspTestCase
All Implemented Interfaces:
junit.framework.Test, org.apache.cactus.internal.CactusTestCase
Direct Known Subclasses:
ExceptionTest, FormsHQLTest, FormsOQLTest, ListHQLTest, ListOQLTest, MakumbaCommonTagsTest

public class MakumbaJspTestCase
extends org.apache.cactus.JspTestCase

Utility class which enables it to quickly write tests based on the execution of a JSP. Since we know the expected result, we can fetch this result and store it into a file, and then compare the next executions of the test against this file.

Version:
$Id: MakumbaJSPTest.java,v 1.1 25.09.2007 16:08:26 Manuel Exp $
Author:
Manuel Gay

Field Summary
 
Fields inherited from class org.apache.cactus.JspTestCase
out, pageContext
 
Fields inherited from class org.apache.cactus.ServletTestCase
config, request, response, session
 
Constructor Summary
MakumbaJspTestCase()
           
 
Method Summary
protected  boolean compareTest(String result)
          Compares a test output to its stored (expected) result.
protected  void fetchValidTestResult(String output, boolean record)
          Method that helps to fetch the result of a test, on the first run.
 
Methods inherited from class org.apache.cactus.JspTestCase
createProtocolHandler
 
Methods inherited from class org.apache.cactus.internal.AbstractCactusTestCase
runBare, runBareServer
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cactus.internal.CactusTestCase
runBareServer
 

Constructor Detail

MakumbaJspTestCase

public MakumbaJspTestCase()
Method Detail

compareTest

protected boolean compareTest(String result)
                       throws Exception
Compares a test output to its stored (expected) result. The method detects automatically the name of the test based on the invoking method, so all there's to do is to pass it the new result.
TODO this should be much more verbose

Parameters:
result - the new result, from the currently running test
Returns:
true if this worked out, false otherwise.
Throws:
FileNotFoundException - in case the comparison basis file is not found, this indicates it
Exception

fetchValidTestResult

protected void fetchValidTestResult(String output,
                                    boolean record)
Method that helps to fetch the result of a test, on the first run. Just pass it the expected result, it will store it automatically. Don't forget to remove it after the first time!

Parameters:
output - the result (HTML code) of the page that was ran correctly.
record - TODO