Expresso 5-5-0

com.jcorporate.expresso.services.test
Class ControllerTestCase

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.apache.cactus.AbstractTestCase
              extended byorg.apache.cactus.AbstractWebTestCase
                  extended byorg.apache.cactus.ServletTestCase
                      extended bycom.jcorporate.expresso.services.test.ControllerTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
DBMaintTests, DBSecurityMatrixTests, LoginControllerTest, RegistrationControllerTests

public class ControllerTestCase
extends org.apache.cactus.ServletTestCase

Base class for testing controllers. Provides an integration with Expresso, JUnit and Cactus

Version:
$Revision: 1.13 $ $Date: 2004/02/18 23:51:40 $
Author:
Michael Rimov

Field Summary
 
Fields inherited from class org.apache.cactus.ServletTestCase
config, request, response, session
 
Fields inherited from class org.apache.cactus.AbstractTestCase
BEGIN_METHOD_PREFIX, END_METHOD_PREFIX, LOG_CLIENT_CONFIG, TEST_METHOD_PREFIX
 
Constructor Summary
ControllerTestCase(String testName, Class controllerClass)
          Instantiates a Controller Test Case
ControllerTestCase(String testName, String controllerName)
          Instantiates the ControllerTestCase.
 
Method Summary
 ControllerResponse buildControllerResponse(org.w3c.dom.Document d)
          Deprecated.  
 ControllerResponse buildControllerResponse(org.apache.cactus.WebResponse theConnection)
          Deprecated.  
 ControllerResponse controllerProcess()
          Run the target controller.
protected  org.apache.log4j.Category getLog()
          returns a controller test case Log4j Category for your own easy logging without having to do special initialization etc.
 org.w3c.dom.NodeList getNodes(org.w3c.dom.Document d, String xpath)
          Deprecated.  
 void logIn(org.apache.cactus.WebRequest theRequest)
          Uses the default setup that a blank database has the security of Admin User = Admin Admin Password = Blank
 void logIn(org.apache.cactus.WebRequest theRequest, String userName, String password)
          Allows special capabilities of logging in using a specially defined username and password.
 org.w3c.dom.Document parseResponse(org.apache.cactus.WebResponse response)
          Deprecated.  
 void setupParameters(String state, org.apache.cactus.WebRequest request)
          Called to set the appropriate states for the controller Also makes sure that parameters are set up so that the controller responds in unprocessed XML, and not standard HTML
 
Methods inherited from class org.apache.cactus.ServletTestCase
runTest
 
Methods inherited from class org.apache.cactus.AbstractWebTestCase
callEndMethod, runGenericTest
 
Methods inherited from class org.apache.cactus.AbstractTestCase
callBeginMethod, getBeginMethodName, getCurrentTestMethod, getEndMethodName, getLogger, runBare, runBareServerTest, runServerTest
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, 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
 

Constructor Detail

ControllerTestCase

public ControllerTestCase(String testName,
                          String controllerName)
                   throws Exception
Instantiates the ControllerTestCase.

Parameters:
testName - the name of the test. Usually handed down by the framework
controllerName - The classname of the controller that we're testing.
Throws:
Exception - if something happens in the system initialization or potentially if the controller name passed doesn't map to a real class

ControllerTestCase

public ControllerTestCase(String testName,
                          Class controllerClass)
                   throws Exception
Instantiates a Controller Test Case

Parameters:
testName - the name of the test. Usually handed down by the framework
controllerClass - The class of the controller to test
Method Detail

getLog

protected org.apache.log4j.Category getLog()
returns a controller test case Log4j Category for your own easy logging without having to do special initialization etc.

Returns:
a log4j category that you can log to.

logIn

public void logIn(org.apache.cactus.WebRequest theRequest)
           throws Exception
Uses the default setup that a blank database has the security of Admin User = Admin Admin Password = Blank

Throws:
Exception

logIn

public void logIn(org.apache.cactus.WebRequest theRequest,
                  String userName,
                  String password)
           throws Exception
Allows special capabilities of logging in using a specially defined username and password.

Throws:
Exception

setupParameters

public void setupParameters(String state,
                            org.apache.cactus.WebRequest request)
Called to set the appropriate states for the controller Also makes sure that parameters are set up so that the controller responds in unprocessed XML, and not standard HTML


parseResponse

public org.w3c.dom.Document parseResponse(org.apache.cactus.WebResponse response)
                                   throws Exception
Deprecated.  

parses the xml into an appropriate DOM document

Throws:
Exception

buildControllerResponse

public ControllerResponse buildControllerResponse(org.w3c.dom.Document d)
Deprecated.  

Build a ControllerResponse given an XML DOM document

Parameters:
d - The DOM document to parse. Root node must be controller-response

buildControllerResponse

public ControllerResponse buildControllerResponse(org.apache.cactus.WebResponse theConnection)
                                           throws Exception
Deprecated.  

Takes the connection handed out by the framework in the endXXXX() methods and builds a full Controller Response document out of it.

Throws:
Exception

controllerProcess

public ControllerResponse controllerProcess()
                                     throws ServletException,
                                            IOException,
                                            Exception
Run the target controller. Requires querying the struts framework to find out the controller, runs the controller, and then forwards the results to the XML servlet for formatting.

Throws:
ServletException
IOException
Exception
Since:
Expresso 3.1

getNodes

public org.w3c.dom.NodeList getNodes(org.w3c.dom.Document d,
                                     String xpath)
Deprecated.  

Returns a DOM NodeList given the xpath expression and the document given. Simply wrapper


Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.