BEA Systems, Inc.

com.compoze.collab.test
Class CollabTestCase


java.lang.Object

  |

  +--junit.framework.Assert

        |

        +--junit.framework.TestCase

              |

              +--com.compoze.collab.test.CollabTestCase

All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
ContainerUt, SessionUt

public abstract class CollabTestCase
extends junit.framework.TestCase

A common superclass for all collab test cases. To write a test case that utilizes the framework:

  1. Extend CollabTestCase and add constructors that take (String) and (String, UtInstance).
  2. Add a static suite method that calls CollabTestCase.suite(TestCase.class) where TestCase.class is replaced by the class of your test case class
  3. Implement methods whose names begin with the String test to create your test methods.


Constructor Summary
CollabTestCase(java.lang.String sName)
          Constructor.
CollabTestCase(java.lang.String sName, UtInstance test)
          Constructor.
 
Method Summary
protected  void debug(java.lang.Object o)
          Prints a debug message.
static void deleteAllItems(IContainer container)
          Deletes all items in a container.
 java.lang.String getAccountProperty(int iAccountNumber, java.lang.String sKey)
          Gets a property on an account.
 TestContext getContext()
          Gets the test context.
 java.lang.String getName()
          Gets the name of the test case (overridden to add additional configuration information).
 java.lang.String getProperty(java.lang.String sKey)
          Gets a property from the configuration file.
 ISession getSession()
          Gets the first session.
 ISession getSession(int iSessionNumber)
          Gets a session by instantiating it using the properties for the given session number.
 java.util.Map getSessionProperties(int iSessionNumber)
          Gets a session by instantiating it using the properties for the given session number.
 UtInstance getTest()
          Gets the unit test instance.
static boolean isIdInContainer(java.lang.String sID, IContainer cont)
          Verifies that an item with the specified ID is in the specified container.
static void safeClose(ISession session)
          Closes a possibly null session and ignores any exceptions.
static void safeDelete(IItem item)
          Deletes a possibly null item and ignores any exceptions.
 void setUp()
          Sets up the test case.
static junit.framework.TestSuite suite(java.lang.Class testClass)
          Creates a test suite out of the test class that contains only this test class.
static junit.framework.TestSuite suite(java.lang.Class testClass, TestContext context)
          Creates a test suite out of the test class that contains all classes specified by the test context.
 void tearDown()
          Tears down the test case.
static IGroupwareItem waitForItemWithSubject(IContainer container, FetchProfile fp, java.lang.String sSubjectSubstring)
          Waits for an item with a subject that contains the specified text to show up in a container.
protected  void warn(java.lang.Object o)
          Prints a warning message.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, 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

CollabTestCase


public CollabTestCase(java.lang.String sName)
Constructor.
Parameters:
sName - the test case name (not null)

CollabTestCase


public CollabTestCase(java.lang.String sName,
                      UtInstance test)
Constructor.
Parameters:
sName - the test case name (not null)
test - the test instance (not null)
Method Detail

setUp


public void setUp()
           throws TestException
Sets up the test case. Subclasses should call super.
Overrides:
setUp in class junit.framework.TestCase
Throws:
TestException - if the test case could not be set up

getContext


public TestContext getContext()
Gets the test context.
Returns:
the test context

getTest


public UtInstance getTest()
Gets the unit test instance.
Returns:
the test instance

tearDown


public void tearDown()
Tears down the test case. Subclasses should call super.
Overrides:
tearDown in class junit.framework.TestCase

suite


public static junit.framework.TestSuite suite(java.lang.Class testClass)
                                       throws TestException
Creates a test suite out of the test class that contains only this test class.
Parameters:
testClass - the class of the JUnit test class
Returns:
the test suite
Throws:
TestException - if the test suite could not be created

suite


public static junit.framework.TestSuite suite(java.lang.Class testClass,
                                              TestContext context)
                                       throws TestException
Creates a test suite out of the test class that contains all classes specified by the test context.
Parameters:
testClass - the class of the JUnit test class
context - the test context
Returns:
the test suite
Throws:
TestException - if the test suite could not be created

debug


protected void debug(java.lang.Object o)
Prints a debug message.
Parameters:
o - the message (not null)

warn


protected void warn(java.lang.Object o)
Prints a warning message.
Parameters:
o - the message (not null)

getProperty


public java.lang.String getProperty(java.lang.String sKey)
Gets a property from the configuration file.
Parameters:
sKey - the key (not null)
Returns:
the value (or null if not found)

getAccountProperty


public java.lang.String getAccountProperty(int iAccountNumber,
                                           java.lang.String sKey)
Gets a property on an account.
Parameters:
iAccountNumber - the account number
sKey - the property key
Returns:
the value (or null if not found)

getSession


public ISession getSession()
                    throws CollaborationException
Gets the first session.
Returns:
the session (not null)
Throws:
CollaborationException - if something went wrong when creating the session

getSession


public ISession getSession(int iSessionNumber)
                    throws CollaborationException
Gets a session by instantiating it using the properties for the given session number.
Parameters:
iSessionNumber - the session number
Returns:
the session (not null)
Throws:
CollaborationException - if something went wrong when creating the session

getSessionProperties


public java.util.Map getSessionProperties(int iSessionNumber)
                                   throws CollaborationException
Gets a session by instantiating it using the properties for the given session number.
Parameters:
iSessionNumber - the session number
Returns:
the session properties map (not null)
Throws:
CollaborationException - if something went wrong when creating the session

safeClose


public static void safeClose(ISession session)
Closes a possibly null session and ignores any exceptions.
Parameters:
session - the session

safeDelete


public static void safeDelete(IItem item)
Deletes a possibly null item and ignores any exceptions.
Parameters:
item - the item

isIdInContainer


public static boolean isIdInContainer(java.lang.String sID,
                                      IContainer cont)
                               throws CollaborationException
Verifies that an item with the specified ID is in the specified container.
Parameters:
sID - the ID (not null)
cont - the container to check (not null)
Returns:
true if the ID is in the specified container
Throws:
CollaborationException - if something went wrong when getting the item

waitForItemWithSubject


public static IGroupwareItem waitForItemWithSubject(IContainer container,
                                                    FetchProfile fp,
                                                    java.lang.String sSubjectSubstring)
                                             throws CollaborationException
Waits for an item with a subject that contains the specified text to show up in a container.
Parameters:
container - the container
fp - the fetch profile to get the item with
sSubjectSubstring - the substring of the subject to look for
Returns:
the item, or null if the item could not be found within the timeout
Throws:
CollaborationException - if something went wrong when looking for the item

deleteAllItems


public static void deleteAllItems(IContainer container)
                           throws CollaborationException
Deletes all items in a container.
Parameters:
container - the container to delete items from
Throws:
CollaborationException - if something went wrong when deleting the items

getName


public java.lang.String getName()
Gets the name of the test case (overridden to add additional configuration information).
Overrides:
getName in class junit.framework.TestCase
Returns:
the name (not null)

BEA Systems, Inc.

Copyright ©1999-2006 BEA Systems, Inc. All rights reserved.