org.infoglue.cms.util
Class InfoGlueTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.infoglue.cms.util.InfoGlueTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
CategoryControllerTest, ContentCategoryControllerTest, ContentDeliveryControllerTest, ContentStateControllerTest, ContentTypeDefinitionControllerTest, MysqlJDBCServiceTest, OwnerStepFilterTest, PublicationControllerTest, SiteNodeVersionControllerTest, WebWorkTestCase, WorkflowTestCase, WorkflowVOTest

public abstract class InfoGlueTestCase
extends junit.framework.TestCase

The base class of all InfoGlue tests cases will setup the things that need to be setup in order to fake out certain services and facilities that may not be running in the environment that they expect. Things like this FakeServletContext can generally be gotten rid of with a few key refactorings of the system to not rely on being run as a web app, etc.

Author:
Frank Febbraro (frank@phase2technology.com)

Constructor Summary
InfoGlueTestCase()
           
 
Method Summary
protected  java.util.Date changeDate(java.util.Date current, int unit, int amount)
          Changes from the given date the supplied unit by the provided amount
protected  java.util.Date changeDate(int unit, int amount)
          Changes from todays date the supplied unit by the provided amount
protected static java.util.List createRole(java.lang.String name)
          Creates a role with the given name to use for testing
static InfoGluePrincipal getAdminPrincipal()
          Returns the administrator principal
static InfoGluePrincipal getAnonPrincipal()
          Returns the anonymous principal
static InfoGluePrincipal getCmsUserPrincipal()
          Returns the cmsUser principal
static java.lang.Integer getLanguageId()
          Returns a Language Id.
static java.lang.Integer getLanguageId(java.lang.Integer repoId)
          Returns a Language Id for the given Repository.
static java.lang.Integer getRepoId()
          Returns a Repository Id to use for testing.
static java.lang.Integer getSiteNodeId()
          Returns a SiteNode id.
static java.lang.Integer getSiteNodeId(java.lang.Integer repoId)
          Returns a SiteNode id for the given Repository.
static void initializeInfoGlue()
          For testing we dont care about the nofitications that take place, especially notifications to remote servers and such that will fail under a normal slimmed down test environment.
protected  void setUp()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

InfoGlueTestCase

public InfoGlueTestCase()
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

initializeInfoGlue

public static void initializeInfoGlue()
                               throws SystemException
For testing we dont care about the nofitications that take place, especially notifications to remote servers and such that will fail under a normal slimmed down test environment. We can test the Notifiers individually, so lets make our lives easier now.

Throws:
SystemException

changeDate

protected java.util.Date changeDate(int unit,
                                    int amount)
Changes from todays date the supplied unit by the provided amount

Parameters:
unit - A value from Calendar
amount - the amount to change the unit, can be positive or negative
Returns:
The newly modified date

changeDate

protected java.util.Date changeDate(java.util.Date current,
                                    int unit,
                                    int amount)
Changes from the given date the supplied unit by the provided amount

Parameters:
current - The date to change
unit - A value from Calendar
amount - the amount to change the unit, can be positive or negative
Returns:
THe newly modified date

createRole

protected static java.util.List createRole(java.lang.String name)
Creates a role with the given name to use for testing

Parameters:
name - the name of the role
Returns:
a list containing only the desired role.

getAdminPrincipal

public static InfoGluePrincipal getAdminPrincipal()
Returns the administrator principal

Returns:
an InfoGluePrincipal representing an administrator

getCmsUserPrincipal

public static InfoGluePrincipal getCmsUserPrincipal()
Returns the cmsUser principal

Returns:
an InfoGluePrincipal representing a cmsUser

getAnonPrincipal

public static InfoGluePrincipal getAnonPrincipal()
Returns the anonymous principal

Returns:
an InfoGluePrincipal representing an anonymous user

getRepoId

public static java.lang.Integer getRepoId()
Returns a Repository Id to use for testing. It will get the first Repository and return it's id, or 1 if there is an error finding any repositories.

Returns:
An Integer Repository Id

getLanguageId

public static java.lang.Integer getLanguageId()
Returns a Language Id. It will use the master language for the first repository, or 1 if there is some kind of error.

Returns:
An Integer Language Id, or 1 is there is some sort of error

getLanguageId

public static java.lang.Integer getLanguageId(java.lang.Integer repoId)
Returns a Language Id for the given Repository. It will use the master language for the given repository, or 1 if there is some kind of error.

Parameters:
repoId - The id of the Repository to get the Master Language.
Returns:
An Integer Language Id, or 1 is there is some sort of error

getSiteNodeId

public static java.lang.Integer getSiteNodeId()
Returns a SiteNode id. It will use the first repository, or return 1 if there is some kind of error.

Returns:
An Integer SiteNode Id, or 1 is there is some sort of error

getSiteNodeId

public static java.lang.Integer getSiteNodeId(java.lang.Integer repoId)
Returns a SiteNode id for the given Repository. It will use the root site node for the given repository, or 1 if there is some kind of error.

Parameters:
repoId - The id of the Repository to get the Master Language.
Returns:
An Integer SiteNode Id, or 1 is there is some sort of error


Copyright © 2005 InfoGlue.org All Rights Reserved.