net.sourceforge.groboutils.junit.v1.iftc
Class CxFactory

java.lang.Object
  extended bynet.sourceforge.groboutils.junit.v1.iftc.CxFactory
All Implemented Interfaces:
ICxFactory, ImplFactory

public abstract class CxFactory
extends java.lang.Object
implements ICxFactory

Helper abstract class that aids in the setting of a unique and distinguishable name for a test case's factory.

As of 08-Dec-2002, the original constructor will NOT add the owning class's name to the factory toString() output. Since the Ant JUnit report is setup such that the concrete class's tests are organized under it, this is redundant information, and clutters the report.

Since:
October 30, 2002
Version:
$Date: 2003/05/24 16:42:13 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Constructor Summary
CxFactory(java.lang.String name)
          Specify a unique identifier for this specific factory within the context of the concrete test that is providing the factory.
CxFactory(java.lang.String name, boolean addClassName)
          Specify a unique identifier for this specific factory within the context of the concrete test that is providing the factory.
 
Method Summary
abstract  java.lang.Object createImplObject()
          Create a new instance of the interface type for testing through an InterfaceTest.
 void tearDown(java.lang.Object implObject)
          Most factories have no need for a tearDown method, so a default (do-nothing) implementation has been provided here.
 java.lang.String toString()
          Override the Java-default toString, and provide our distinguishable name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CxFactory

public CxFactory(java.lang.String name)
Specify a unique identifier for this specific factory within the context of the concrete test that is providing the factory. The CxFactory constructor will not add the test's class name to this string to create a distinguishable string to help debug the source of any errors caused by a factory's particular setup. If you want the owning class's name to appear in the id, use the alternate constructor.

Parameters:
name - the unique identifier within the context of the factory's owning test class. This cannot be null.
Throws:
java.lang.IllegalArgumentException - thrown if name is null.

CxFactory

public CxFactory(java.lang.String name,
                 boolean addClassName)
Specify a unique identifier for this specific factory within the context of the concrete test that is providing the factory. The CxFactory constructor may add the test's class name to this string to create a distinguishable string to help debug the source of any errors caused by a factory's particular setup, depending on the value of addClassName.

Parameters:
name - the unique identifier within the context of the factory's owning test class. This cannot be null.
addClassName - true if the owning class's name should be added to the id, and false if the name should be the ID itself.
Throws:
java.lang.IllegalArgumentException - thrown if name is null.
Since:
07-Dec-2002
Method Detail

toString

public java.lang.String toString()
Override the Java-default toString, and provide our distinguishable name.

Specified by:
toString in interface ImplFactory
Returns:
the generated distinguishable name.

tearDown

public void tearDown(java.lang.Object implObject)
              throws java.lang.Exception
Most factories have no need for a tearDown method, so a default (do-nothing) implementation has been provided here.

Specified by:
tearDown in interface ICxFactory
Parameters:
implObject - one of the objects created by this factory.
Throws:
java.lang.Exception - can be thrown when the deconstruction fails. This will not disrupt the remaining objects' tear down call.

createImplObject

public abstract java.lang.Object createImplObject()
                                           throws java.lang.Exception
Description copied from interface: ImplFactory
Create a new instance of the interface type for testing through an InterfaceTest.

As of 21-Oct-2002, this method can raise any exception, and it will be correctly caught and reported as a failure by the InterfaceTestCase.createImplObject() method, so that the creation method can simplify its logic, and add any kind of initialization without having to worry about the correct way to handle exceptions.

Specified by:
createImplObject in interface ImplFactory
Returns:
a new instance of the expected type that the corresponding InterfaceTestCase(s) cover.
Throws:
java.lang.Exception - thrown under any unexpected condition that results in the failure to properly create the instance.


Copyright © 2001-2003 by The GroboUtils Project