Class BaseFitNesseFixture

java.lang.Object
com.reallifedeveloper.tools.test.fitnesse.BaseFitNesseFixture

public class BaseFitNesseFixture extends Object
Base class for all FitNesse fixtures.
Author:
RealLifeDeveloper
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The date format used by parseDate(String) ("yyyy-MM-dd").
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseFitNesseFixture(String springConfigurationResourceName)
    Creates a new BaseFitNesseFixture object reading the Spring application context from the given classpath resource, which should be a Spring XML configuration file.
    BaseFitNesseFixture(org.springframework.context.ApplicationContext applicationContext)
    Creates a new BaseFitNesseFixture object using the given Spring application context.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
    protected org.springframework.context.ApplicationContext
    Gives the Spring ApplicationContext associated with this thread.
    protected <T> T
    getBean(Class<T> beanClass)
    Looks up a Spring bean of a given class in the ApplicationContext.
    @Nullable String
    A comment that is useful as documentation in most FitNesse tests.
    protected org.slf4j.Logger
    Gives an org.slf4j.Logger that can be used by the concrete fixture classes for logging.
    protected Date
    Parses a date string on the form "yyyy-MM-dd" and returns the corresponding java.util.Date object.
    static void
    Sets the Spring ApplicationContext to null.
    void
    setComment(String comment)
    Specifies a comment for the current test case.
    protected @Nullable String
    A null-safe toString method.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • BaseFitNesseFixture

      public BaseFitNesseFixture(org.springframework.context.ApplicationContext applicationContext)
      Creates a new BaseFitNesseFixture object using the given Spring application context. The application context is associated with the current thread, so this fixture instance is assumed to be used by a single thread.
      Parameters:
      applicationContext - the Spring application context to use, must not be null
    • BaseFitNesseFixture

      public BaseFitNesseFixture(String springConfigurationResourceName)
      Creates a new BaseFitNesseFixture object reading the Spring application context from the given classpath resource, which should be a Spring XML configuration file.
      Parameters:
      springConfigurationResourceName - name of the classpath resource containing Spring XML configuration, must not be null
  • Method Details

    • getComment

      public @Nullable String getComment()
      A comment that is useful as documentation in most FitNesse tests.

      Any FitNesse test that uses this base class can add the column "Comment", which in most cases is not used by the test, but is useful as documentation of the test case.

      Returns:
      the comment that was written for the test case
    • setComment

      public void setComment(String comment)
      Specifies a comment for the current test case.
      Parameters:
      comment - the comment that belongs to the test case
    • getApplicationContext

      protected org.springframework.context.ApplicationContext getApplicationContext()
      Gives the Spring ApplicationContext associated with this thread.

      This method never returns null; if it is not possible to create an ApplicationContext, an exception is thrown.

      Note that the ApplicationContext is managed statically, so if a class already has loaded a context using this method, and another class is later used that wants to use a different configuration, no reload will happen automatically. In this case, you can use the method resetApplicationContext() to reset the context and force a reload.

      Returns:
      the Spring ApplicationContext, never null
    • resetApplicationContext

      public static void resetApplicationContext()
      Sets the Spring ApplicationContext to null. This can be used to force a reload of the context the next time the method getApplicationContext() is called.
    • getBean

      protected <T> T getBean(Class<T> beanClass)
      Looks up a Spring bean of a given class in the ApplicationContext. This method never returns null; if the bean does not exist, an exception is thrown.
      Type Parameters:
      T - the type of the Spring bean
      Parameters:
      beanClass - the class of the Spring bean
      Returns:
      the Spring bean, never null
    • logger

      protected org.slf4j.Logger logger()
      Gives an org.slf4j.Logger that can be used by the concrete fixture classes for logging.
      Returns:
      an org.slf4j.Logger
    • parseDate

      protected Date parseDate(String date)
      Parses a date string on the form "yyyy-MM-dd" and returns the corresponding java.util.Date object.
      Parameters:
      date - the date string to parse, should be on the form "yyyy-MM-dd"
      Returns:
      the java.util.Date corresponding to date
      Throws:
      IllegalArgumentException - if date cannot be parsed
    • toString

      protected @Nullable String toString(Object o)
      A null-safe toString method.
      Parameters:
      o - the object to be converted to string, can be null
      Returns:
      null if o is null, otherwise o.toString()
    • finalize

      protected final void finalize() throws Throwable
      Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
      Overrides:
      finalize in class Object
      Throws:
      Throwable
      See Also: