openfuture.bugbase.test.common
Class JspBaseTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--org.apache.cactus.AbstractTestCase
                    |
                    +--org.apache.cactus.AbstractWebTestCase
                          |
                          +--org.apache.cactus.ServletTestCase
                                |
                                +--org.apache.cactus.JspTestCase
                                      |
                                      +--openfuture.bugbase.test.common.JspBaseTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
JspLoginTestCase

public abstract class JspBaseTestCase
extends org.apache.cactus.JspTestCase

Base test case for JSP tests using the Cactus framework.

Created: Wed Oct 31 14:33:23 2001

Version:
$Revision: 1.5 $
Author:
Wolfgang Reissenberger

Fields inherited from class org.apache.cactus.JspTestCase
out, pageContext
 
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
JspBaseTestCase(java.lang.String name)
          Creates a new JspLoginTestCase instance.
 
Method Summary
 void clientSetUp()
          Setup before executing a test case: Create a Bug Base Servlet Proxy.
 void clientTearDown()
          Currently does nothing.
 void copyCookies(com.meterware.httpunit.WebResponse from, org.apache.cactus.WebRequest to)
          copy the new cookies received by the response to the new request.
 com.meterware.httpunit.WebForm findForm(com.meterware.httpunit.WebForm[] forms, java.lang.String action)
          Find a certain form.
 BugBaseServletClient getClient()
          Get the value of client.
 org.apache.commons.logging.Log getLog()
          Convenience method accessing the Cactus LogService Log.
 java.util.Properties getProperties()
          Get the value of properties.
protected  com.meterware.httpunit.WebResponse login(com.meterware.httpunit.WebConversation wc, com.meterware.httpunit.WebResponse resp, boolean searchLogin)
          Login into Bug Base using HttpUnit.
 com.meterware.httpunit.WebResponse loginPage(com.meterware.httpunit.WebConversation wc, org.apache.cactus.WebRequest request, java.lang.String jsp, boolean searchLogin)
          Call a page, that requires a login first.
protected  com.meterware.httpunit.WebResponse logoff(com.meterware.httpunit.WebConversation wc, com.meterware.httpunit.WebResponse resp)
          Logoff from Bug Base.
 com.meterware.httpunit.WebResponse logoffPage(com.meterware.httpunit.WebConversation wc, org.apache.cactus.WebRequest request, java.lang.String jsp)
          Call a page and logoff directly.
 void setClient(BugBaseServletClient v)
          Set the value of client.
protected  void setDefault(java.lang.String key, java.lang.String value)
          Set a property to a default value, if the property is NOT already set.
 void setProperties(java.util.Properties v)
          Set the value of properties.
protected  void setUrl(java.net.URL url, org.apache.cactus.WebRequest request)
          Set the URL in the Cactus request
 
Methods inherited from class org.apache.cactus.JspTestCase
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

JspBaseTestCase

public JspBaseTestCase(java.lang.String name)
Creates a new JspLoginTestCase instance. Read the property file "bugbase.properties" from the classpath. The following properties are recognized:

Parameters:
name - test case name
Method Detail

clientSetUp

public void clientSetUp()
                 throws java.lang.Exception
Setup before executing a test case:
Throws:
java.lang.Exception - if an error occurs

clientTearDown

public void clientTearDown()
                    throws java.lang.Exception
Currently does nothing.
Throws:
java.lang.Exception - if an error occurs

loginPage

public com.meterware.httpunit.WebResponse loginPage(com.meterware.httpunit.WebConversation wc,
                                                    org.apache.cactus.WebRequest request,
                                                    java.lang.String jsp,
                                                    boolean searchLogin)
                                             throws java.lang.Exception
Call a page, that requires a login first. If the login screen does not come first, a logoff is tried and the page is called again.
Parameters:
wc - the web conversation
request - Cactus request object
jsp - the JSP that requires a login
searchLogin - if true, the result page will be searched for a login form. The login form is recognized by its action. The action must contain "login.do" as substring.
Returns:
the response receive
Throws:
java.lang.Exception - if an error occurs

logoffPage

public com.meterware.httpunit.WebResponse logoffPage(com.meterware.httpunit.WebConversation wc,
                                                     org.apache.cactus.WebRequest request,
                                                     java.lang.String jsp)
                                              throws java.lang.Exception
Call a page and logoff directly. It is assumed, that no intermediatary login is required.
Parameters:
wc - the web conversation
request - Cactus request object
jsp - the JSP from where the logoff will be processed
Returns:
the response receive
Throws:
java.lang.Exception - if an error occurs

login

protected com.meterware.httpunit.WebResponse login(com.meterware.httpunit.WebConversation wc,
                                                   com.meterware.httpunit.WebResponse resp,
                                                   boolean searchLogin)
                                            throws java.lang.Exception
Login into Bug Base using HttpUnit. The current page must contain a login form.
Parameters:
wc - the current web conversation
resp - the web response, where the input form will be searched
searchLogin - if true, the result page will be searched for a login form. The login form is recognized by its action. The action must contain "login.do" as substring.
Returns:
the HTTPUnit response object
Throws:
java.lang.Exception - if an error occurs

logoff

protected com.meterware.httpunit.WebResponse logoff(com.meterware.httpunit.WebConversation wc,
                                                    com.meterware.httpunit.WebResponse resp)
                                             throws java.lang.Exception
Logoff from Bug Base. If the current page must contain a logoff form, it will be called.
Parameters:
wc - the current web conversation
resp - the web response, where the input form will be searched
Returns:
the HTTPUnit response object
Throws:
java.lang.Exception - if an error occurs

copyCookies

public void copyCookies(com.meterware.httpunit.WebResponse from,
                        org.apache.cactus.WebRequest to)
copy the new cookies received by the response to the new request.
Parameters:
from - received response
to - target request

findForm

public com.meterware.httpunit.WebForm findForm(com.meterware.httpunit.WebForm[] forms,
                                               java.lang.String action)
Find a certain form. The form is recognized by the action which should contain the given action string.
Parameters:
forms - array of form objects
action - action string that must be contained in the action string.
Returns:
form or null, if the desired form cannot be found.

setDefault

protected void setDefault(java.lang.String key,
                          java.lang.String value)
Set a property to a default value, if the property is NOT already set.
Parameters:
key - property key
value - property value

setUrl

protected void setUrl(java.net.URL url,
                      org.apache.cactus.WebRequest request)
Set the URL in the Cactus request
Parameters:
url - URL to be set
request - Cactus request the URL should be set
See Also:
WebRequest.setURL(String, String, String, String, String)

getProperties

public java.util.Properties getProperties()
Get the value of properties.
Returns:
value of properties.

setProperties

public void setProperties(java.util.Properties v)
Set the value of properties.
Parameters:
v - Value to assign to properties.

getClient

public BugBaseServletClient getClient()
Get the value of client.
Returns:
value of client.

setClient

public void setClient(BugBaseServletClient v)
Set the value of client.
Parameters:
v - Value to assign to client.

getLog

public org.apache.commons.logging.Log getLog()
Convenience method accessing the Cactus LogService Log.
Returns:
the current Log instance


Copyright © 2000 -- 2003 openfuture.de. All Rights Reserved.