|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectTestCase
public abstract class TestCase
Base class of all GeoAPI tests. All concrete subclasses need at least one factory for instantiating the objects to test. The factories must be specified at subclasses
construction time either directly by the implementor, or indirectly by calls to the
factories(Class[]) method.
TestSuite| Field Summary | |
|---|---|
protected Configuration.Key<Boolean> |
configurationTip
A tip set by subclasses during the execution of optional tests. |
TestWatcher |
listener
A JUnit rule for listening to test execution events. |
protected static Factory[] |
NO_FACTORY
An empty array of factories, as a convenience for no-argument constructors. |
protected ValidatorContainer |
validators
The set of Validator instances to use for verifying objects conformance
(never null). |
| Constructor Summary | |
|---|---|
protected |
TestCase()
Creates a new test without factory. |
protected |
TestCase(Factory... factories)
Creates a new test which will use the given factories to execute. |
| Method Summary | |
|---|---|
static void |
addTestListener(TestListener listener)
Adds a listener to be informed every time a test begin or finish, either on success or failure. |
Configuration |
configuration()
Returns information about the configuration of the test which has been run. |
protected static List<Factory[]> |
factories(Class<? extends Factory>... types)
Returns factory instances for given factory interfaces. |
protected static List<Factory[]> |
factories(FactoryFilter filter,
Class<? extends Factory>... types)
Returns factory instances for given factory interfaces, excluding the factories filtered by the given filter. |
protected boolean[] |
getEnabledFlags(Configuration.Key<Boolean>... properties)
Returns booleans indicating whether the given operations are enabled. |
static void |
removeTestListener(TestListener listener)
Removes a previously added listener. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Factory[] NO_FACTORY
public final TestWatcher listener
This field is public because JUnit requires us to do so, but should be considered as an implementation details (it should have been a private field).
protected final ValidatorContainer validators
Validator instances to use for verifying objects conformance
(never null). If no validators were explicitely specified, then the
default validators are used.
protected transient Configuration.Key<Boolean> configurationTip
Example
@Test
public void myTest() {
if (isDerivativeSupported) {
configurationTip = Configuration.Key.isDerivativeSupported;
// Do some tests the require support of math transform derivatives.
}
configurationTip = null;
}
| Constructor Detail |
|---|
protected TestCase()
protected TestCase(Factory... factories)
factories - The factories to be used by the test. Those factories will be given to
ImplementationDetails.configuration(Factory[]) in order to decide which
validators to use.| Method Detail |
|---|
protected static List<Factory[]> factories(Class<? extends Factory>... types)
This method is used by static methods having the Parameterized.Parameters
annotation in subclasses. For example if a subclass constructor expects 3 factories of kind
CRSFactory, CSFactory
and DatumFactory in that order, then that subclass
contain the following method:
@Parameterized.Parameters
public static List<Factory[]> factories() {
return factories(CRSFactory.class, CSFactory.class, DatumFactory.class);
}
Note that the arrays may contain null elements if no factory implementation were found
for a given interface. All GeoAPI test cases use Assume checks in order
to disable any tests that require a missing factory.
If many factory implementations were found for a given interface, then this method
returns all possible combinations of those factories. For example if two instances
of interface A are found (named A1 and A2), and two instances
of interface B are also found (named B1 and B2), then this
method returns a list containing:
{A1, B1}
{A2, B1}
{A1, B2}
{A2, B2}
The current implementation first checks the factories explicitely specified by calls to the
TestSuite.setFactories(Class, Factory[]) method. In no factories were explicitely
specified, then this method searches the classpath using ServiceLoader.
types - The kind of factories to fetch.
types.NameTest.factories(),
ObjectFactoryTest.factories(),
AuthorityFactoryTest.factories(),
AffineTransformTest.factories(),
ParameterizedTransformTest.factories()
protected static List<Factory[]> factories(FactoryFilter filter,
Class<? extends Factory>... types)
factories(Class[])
except that the given filter is applied in addition to any filter found on the classpath.
The main purpose of this method is to get AuthorityFactory
instances for a given authority name.
filter - An optional factory filter to use in addition to any filter declared in
the classpath, or null if none.types - The kind of factories to fetch.
types.protected final boolean[] getEnabledFlags(Configuration.Key<Boolean>... properties)
ImplementationDetails instance found on the
classpath returns a configuration map
having the value Boolean.FALSE for a given key, then the boolean value corresponding
to that key is set to false.
properties - The key for which the flags are wanted.
properties in which each element at
index i indicates whether the properties[i] test should
be enabled.public Configuration configuration()
TestCase subclass and on the
values returned by the ImplementationDetails.configuration(Factory[])
method for the factories being tested. For a description of the map content,
see any of the following subclasses:
AffineTransformTest.configuration()ParameterizedTransformTest.configuration()AuthorityFactoryTest.configuration()Series2000Test.configuration()
ImplementationDetails.configuration(Factory[])public static void addTestListener(TestListener listener)
listener - The listener to add. null values are silently ignored.public static void removeTestListener(TestListener listener)
listener - The listener to remove. null values are silently ignored.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||