Class BaseFitNesseFixture
java.lang.Object
com.reallifedeveloper.tools.test.fitnesse.BaseFitNesseFixture
Base class for all FitNesse fixtures.
- Author:
- RealLifeDeveloper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The date format used byparseDate(String)
("yyyy-MM-dd"). -
Constructor Summary
ConstructorsConstructorDescriptionBaseFitNesseFixture
(String springConfigurationResourceName) Creates a newBaseFitNesseFixture
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 newBaseFitNesseFixture
object using the given Spring application context. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
finalize()
Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).protected org.springframework.context.ApplicationContext
Gives the SpringApplicationContext
associated with this thread.protected <T> T
Looks up a Spring bean of a given class in theApplicationContext
.@Nullable String
A comment that is useful as documentation in most FitNesse tests.protected org.slf4j.Logger
logger()
Gives anorg.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 correspondingjava.util.Date
object.static void
Sets the SpringApplicationContext
tonull
.void
setComment
(String comment) Specifies a comment for the current test case.protected @Nullable String
A null-safe toString method.
-
Field Details
-
DATE_FORMAT
The date format used byparseDate(String)
("yyyy-MM-dd").- See Also:
-
-
Constructor Details
-
BaseFitNesseFixture
public BaseFitNesseFixture(org.springframework.context.ApplicationContext applicationContext) Creates a newBaseFitNesseFixture
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 benull
-
BaseFitNesseFixture
Creates a newBaseFitNesseFixture
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 benull
-
-
Method Details
-
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
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 SpringApplicationContext
associated with this thread.This method never returns
null
; if it is not possible to create anApplicationContext
, 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 methodresetApplicationContext()
to reset the context and force a reload.- Returns:
- the Spring
ApplicationContext
, nevernull
-
resetApplicationContext
public static void resetApplicationContext()Sets the SpringApplicationContext
tonull
. This can be used to force a reload of the context the next time the methodgetApplicationContext()
is called. -
getBean
Looks up a Spring bean of a given class in theApplicationContext
. This method never returnsnull
; 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 anorg.slf4j.Logger
that can be used by the concrete fixture classes for logging.- Returns:
- an
org.slf4j.Logger
-
parseDate
Parses a date string on the form "yyyy-MM-dd" and returns the correspondingjava.util.Date
object.- Parameters:
date
- the date string to parse, should be on the form "yyyy-MM-dd"- Returns:
- the
java.util.Date
corresponding todate
- Throws:
IllegalArgumentException
- ifdate
cannot be parsed
-
toString
A null-safe toString method.- Parameters:
o
- the object to be converted to string, can benull
- Returns:
null
ifo
isnull
, otherwiseo.toString()
-
finalize
Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
-