openfuture.bugbase.test.common
Class BusinessTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--junit.log4j.LoggedTestCase
                    |
                    +--openfuture.bugbase.test.common.BusinessTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AddUserErrorsTestCase, ClientAddBugReportTestCase, JspAccessTestCase, JspAddBugReportTestCase, NewUserTestCase, ViewBugReportsTestCase

public abstract class BusinessTestCase
extends LoggedTestCase

Abstract base class for Bug Base business test cases.

Created: Sun Oct 28 19:16:03 2001

Version:
$Revision: 1.11 $
Author:
Wolfgang Reissenberger

Fields inherited from class junit.log4j.LoggedTestCase
category, isLog4jInClasspath
 
Constructor Summary
BusinessTestCase(java.lang.String name)
          Creates a new BusinessTestCase instance.
 
Method Summary
protected  com.meterware.httpunit.WebResponse callPage(com.meterware.httpunit.WebConversation wc, java.lang.String jsp)
          Call a page.
static User createAdminUser(java.util.LinkedList users)
          Create a new user with password "test".
 BugReport createCompleteBugReport(java.lang.String groupid)
          Creates a complete bug report.
static BugReport createCompleteBugReport(java.lang.String title, java.lang.String description, java.lang.String packageName, java.lang.String groupid, java.lang.String errorLevel)
          Create a bug report with all required attributes:
static User createDoctorUser(java.util.LinkedList users)
          Create a new user with password "test".
static User createNormalUser(java.util.LinkedList users)
          Create a unique normal user with initial name "test_user".
static User createNormalUser(java.lang.String userid, java.util.LinkedList users)
          Create a new user with password "test".
static java.lang.String createUniqueUserId(java.lang.String initial, java.util.LinkedList users)
          Create a unique user ID
protected  com.meterware.httpunit.WebRequest fillReportForm(com.meterware.httpunit.WebForm form, java.lang.String title, java.lang.String description, java.lang.String packageName, java.lang.String groupid, java.lang.String errorLevel)
          Fill the bug report form with the given parameters
static com.meterware.httpunit.WebForm findForm(com.meterware.httpunit.WebForm[] forms, java.lang.String action)
          Find a certain form.
static com.meterware.httpunit.WebLink findLink(com.meterware.httpunit.WebLink[] links, java.lang.String reference)
          Find a certain link.
static com.meterware.httpunit.WebLink findLinkByText(com.meterware.httpunit.WebLink[] links, java.lang.String reference)
          Find a certain link.
 User getAdminUser()
          Get the value of adminUser.
 BugBaseServletClient getClient()
          Get the value of client.
 User getDoctorUser()
          Get the value of doctorUser.
 User getNormalUser()
          Get the value of normalUser.
 java.util.ResourceBundle getResourceBundle()
          Get the value of resourceBundle.
static java.io.File getUniqueFilename(java.lang.String prefix, java.lang.String suffix, java.io.File currentDirectory)
          Create a new filename in the given directory.
static boolean hasReasonKey(I18NException ex, java.lang.String reasonKey)
          Search in the reasons of the given exceptions if there is a reason with the given key.
static boolean isUniqueUserId(java.lang.String userid, java.util.LinkedList users)
          Check, if the list of users contains a user with user ID userid.
static User login(BugBaseServletClient client, java.lang.String userid, java.lang.String password)
          Tries to establish a new connection to Bug Base.
protected  com.meterware.httpunit.WebResponse login(User user, com.meterware.httpunit.WebConversation wc, com.meterware.httpunit.WebResponse resp, boolean searchLogin)
          Login into Bug Base using HttpUnit.
 com.meterware.httpunit.WebResponse loginPage(User user, com.meterware.httpunit.WebConversation wc, java.lang.String jsp, boolean searchLogin)
          Call a page, that requires a login first.
 com.meterware.httpunit.WebResponse loginPage(com.meterware.httpunit.WebConversation wc, java.lang.String jsp, boolean searchLogin)
          Executes loginPage() with normal user
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, java.lang.String jsp)
          Call a page and logoff directly.
static User searchUser(java.lang.String userid, java.util.LinkedList users)
          Search the user in the list with the given user ID.
 void setAdminUser(User v)
          Set the value of adminUser.
 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 setDoctorUser(User v)
          Set the value of doctorUser.
 void setNormalUser(User v)
          Set the value of normalUser.
 void setResourceBundle(java.util.ResourceBundle v)
          Set the value of resourceBundle.
 void setUp()
          Set Up for the test case: Create a Bug Base Servlet Proxy.
 void tearDown()
          Remove the test users from Bug Base.
 
Methods inherited from class junit.log4j.LoggedTestCase
debug, debug, error, error, fatal, fatal, getProperties, info, info, setProperties, warn, warn
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

BusinessTestCase

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

Finally, the resource bundle is loaded from openfuture.bugbase.BugBaseRes_txt.

Parameters:
name - a String value
Method Detail

setUp

public void setUp()
           throws java.lang.Exception
Set Up for the test case:
Overrides:
setUp in class LoggedTestCase
Throws:
java.lang.Exception - if an error occurs

tearDown

public void tearDown()
              throws java.lang.Exception
Remove the test users from Bug Base.
Overrides:
tearDown in class LoggedTestCase
Throws:
java.lang.Exception - if an error occurs

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

hasReasonKey

public static boolean hasReasonKey(I18NException ex,
                                   java.lang.String reasonKey)
Search in the reasons of the given exceptions if there is a reason with the given key.
Parameters:
ex - an I18NException value
reasonKey - reason key to be found
Returns:
true, if the reason key is contained in the key of the reasons why the exception occured.

getUniqueFilename

public static java.io.File getUniqueFilename(java.lang.String prefix,
                                             java.lang.String suffix,
                                             java.io.File currentDirectory)
Create a new filename in the given directory. The name is constructed following the scheme <prefix>-yyyy-MM-dd-nr<suffix>.
Parameters:
prefix - a String value
suffix - a String value
currentDirectory - the current directory
Returns:
a file that does not exist in the given directory

createNormalUser

public static User createNormalUser(java.lang.String userid,
                                    java.util.LinkedList users)
Create a new user with password "test". This user belongs only to the group "users".
Parameters:
userid - initial userid where the search for a unique one starts.
users - list of current users
Returns:
new user

createNormalUser

public static User createNormalUser(java.util.LinkedList users)
Create a unique normal user with initial name "test_user".
Parameters:
users - list of current users
Returns:
unique normal user

createDoctorUser

public static User createDoctorUser(java.util.LinkedList users)
Create a new user with password "test". This user belongs to the groups "users" and "doctors". The initial user ID is "test_doctor".
Parameters:
users - list of current users
Returns:
unique doctor user
See Also:
createNormalUser(String, LinkedList)

createAdminUser

public static User createAdminUser(java.util.LinkedList users)
Create a new user with password "test". This user belongs to the groups "users", "doctors" and "admin". The initial user ID is "test_admin".
Parameters:
users - list of current users
Returns:
unique admin user
See Also:
createNormalUser(String, LinkedList)

login

public static User login(BugBaseServletClient client,
                         java.lang.String userid,
                         java.lang.String password)
                  throws I18NException
Tries to establish a new connection to Bug Base.
Parameters:
client - proxy to the BugBaseServlet.
userid - user ID
password - user password
Returns:
user data, if succeeded, null otherwise.
Throws:
I18NException - if an error occurs

searchUser

public static User searchUser(java.lang.String userid,
                              java.util.LinkedList users)
Search the user in the list with the given user ID.
Parameters:
userid - user ID to be found
users - list of users
Returns:
user with the given user ID. If none is found, null is returned.

createUniqueUserId

public static java.lang.String createUniqueUserId(java.lang.String initial,
                                                  java.util.LinkedList users)
Create a unique user ID
Parameters:
initial - start at this user ID
users - list of users.
Returns:
a unique user ID

isUniqueUserId

public static boolean isUniqueUserId(java.lang.String userid,
                                     java.util.LinkedList users)
Check, if the list of users contains a user with user ID userid.
Parameters:
userid - user ID to be checked
users - list of users.
Returns:
true, if the list does not contain a user with the given user ID.

createCompleteBugReport

public BugReport createCompleteBugReport(java.lang.String groupid)
Creates a complete bug report. The following attributes are set:
Parameters:
groupid - bug reporter group ID
Returns:
a BugReport value

createCompleteBugReport

public static BugReport createCompleteBugReport(java.lang.String title,
                                                java.lang.String description,
                                                java.lang.String packageName,
                                                java.lang.String groupid,
                                                java.lang.String errorLevel)
Create a bug report with all required attributes:
Parameters:
title - see bug report title
description - bug report description
packageName - see see bug report package name
groupid - see bug report group id
errorLevel - see bug report error level
Returns:
a complete bug report

loginPage

public com.meterware.httpunit.WebResponse loginPage(User user,
                                                    com.meterware.httpunit.WebConversation wc,
                                                    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:
user - user the login should be executed for
wc - the web conversation
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 received
Throws:
java.lang.Exception - if an error occurs

loginPage

public com.meterware.httpunit.WebResponse loginPage(com.meterware.httpunit.WebConversation wc,
                                                    java.lang.String jsp,
                                                    boolean searchLogin)
                                             throws java.lang.Exception
Executes loginPage() with normal user
Parameters:
wc - the web conversation
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 received
Throws:
java.lang.Exception - if an error occurs

callPage

protected com.meterware.httpunit.WebResponse callPage(com.meterware.httpunit.WebConversation wc,
                                                      java.lang.String jsp)
                                               throws java.lang.Exception
Call a page. If a login is required, it is executed first.
Parameters:
wc - the web conversation
jsp - the JSP that requires a login
Returns:
the response receive
Throws:
java.lang.Exception - if an error occurs

logoffPage

public com.meterware.httpunit.WebResponse logoffPage(com.meterware.httpunit.WebConversation wc,
                                                     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
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(User user,
                                                   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:
user - user the login should be executed for
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

fillReportForm

protected com.meterware.httpunit.WebRequest fillReportForm(com.meterware.httpunit.WebForm form,
                                                           java.lang.String title,
                                                           java.lang.String description,
                                                           java.lang.String packageName,
                                                           java.lang.String groupid,
                                                           java.lang.String errorLevel)
Fill the bug report form with the given parameters
Parameters:
form - the HTML form
title - bug report title
description - bug report description
packageName - bug report package name
groupid - bug report group ID
errorLevel - bug report error level
Returns:
the web request belonging to the form's submit button

findForm

public static 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.

findLink

public static com.meterware.httpunit.WebLink findLink(com.meterware.httpunit.WebLink[] links,
                                                      java.lang.String reference)
Find a certain link. The link is recognized by the referenced URL which must contain the given reference string.
Parameters:
links - array of link objects
reference - string that must be contained in the reference string.
Returns:
link or null, if the desired link cannot be found.

findLinkByText

public static com.meterware.httpunit.WebLink findLinkByText(com.meterware.httpunit.WebLink[] links,
                                                            java.lang.String reference)
Find a certain link. The link is recognized by the text representing the link which must contain the given reference string.
Parameters:
links - array of link objects
reference - string that must be contained in the reference string.
Returns:
link or null, if the desired link cannot be found.

getNormalUser

public User getNormalUser()
Get the value of normalUser.
Returns:
value of normalUser.

setNormalUser

public void setNormalUser(User v)
Set the value of normalUser.
Parameters:
v - Value to assign to normalUser.

getDoctorUser

public User getDoctorUser()
Get the value of doctorUser.
Returns:
value of doctorUser.

setDoctorUser

public void setDoctorUser(User v)
Set the value of doctorUser.
Parameters:
v - Value to assign to doctorUser.

getAdminUser

public User getAdminUser()
Get the value of adminUser.
Returns:
value of adminUser.

setAdminUser

public void setAdminUser(User v)
Set the value of adminUser.
Parameters:
v - Value to assign to adminUser.

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Get the value of resourceBundle.
Returns:
value of resourceBundle.

setResourceBundle

public void setResourceBundle(java.util.ResourceBundle v)
Set the value of resourceBundle.
Parameters:
v - Value to assign to resourceBundle.

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.


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