|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectTestSuite
public class TestSuite
The suite of every tests defined in the GeoAPI conformance module. The test cases included in this test suite are:
NameTestObjectFactoryTestAffineTransformTestParameterizedTransformTestAuthorityFactoryTestSeries2000Test
All tests use Factory instances that are specific to the implementation being tested.
By default TestSuite fetches the factory implementations with ServiceLoader,
which will scan every META-INF/services/org.opengis.TheFactory files
on the classpath. However implementors can override this default mechanism with explicit calls
to the setFactories(Class, Factory[]) method.
Implementors can have some control on the tests (factories to use, features to test, tolerance
thresholds) by registering their FactoryFilter or ImplementationDetails in the
META-INF/services/ directory. As an alternative, implementors can also extend directly
the various TestCase subclasses.
Example: The test suite below declares that the tolerance threshold for MyProjection
needs to be relaxed by a factor 10 during inverse projections.
package org.myproject;
import org.opengis.test.TestSuite;
import org.opengis.test.CalculationType;
import org.opengis.test.ToleranceModifier;
import org.opengis.test.ToleranceModifiers;
import org.opengis.test.ImplementationDetails;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.util.Factory;
import java.util.Properties;
public class GeoapiTest extends TestSuite implements ImplementationDetails {
@Override
public Properties configuration(Factory... factories) {
return null;
}
@Override
public ToleranceModifier tolerance(MathTransform transform) {
if (transform instanceof MyProjection) {
return ToleranceModifiers.scale(EnumSet.of(CalculationType.INVERSE_TRANSFORM), 1, 10);
}
return null;
}
}
The above AllTests class needs to be registered in the META-INF/services/
directory if the implementation details shall be honored (otherwise the tests will be run,
but the implementation details will be ignored).
ImplementationDetails,
TestCase,
Factory| Constructor Summary | |
|---|---|
protected |
TestSuite()
Constructor provided for allowing subclassing. |
| Method Summary | ||
|---|---|---|
static void |
clear()
Clears all factories specified to the setFactories(Class, Factory[]) method, and clears
all service loader caches. |
|
static
|
getFactories(Class<T> type)
Returns the factory implementations explicitely given by the last call to setFactories(Class, Factory[]) for the given interface. |
|
static void |
setClassLoader(ClassLoader loader)
Sets the class loader to use for loading implementations. |
|
static
|
setFactories(Class<T> type,
T... factory)
Specifies the factory implementations to use for the given factory interface. |
|
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected TestSuite()
| Method Detail |
|---|
public static <T extends Factory> void setFactories(Class<T> type,
T... factory)
T - The compile-time type of the type class argument.type - The factory interface for which an implementation is specified.factory - The implementations to use for the given interface.public static <T extends Factory> T[] getFactories(Class<T> type)
setFactories(Class, Factory[]) for the given interface. This method does
not scan the META-INF/services/<T> entries.
T - The compile-time type of the type class argument.type - The factory interface for which an implementations is desired.
null if none.public static void setClassLoader(ClassLoader loader)
null value restores
the default context class loader.
loader - The class loader to use, or null for the default.public static void clear()
setFactories(Class, Factory[]) method, and clears
all service loader caches. After this method call, all factories
will be reloaded when first needed. This method is intended for use in situations in which
new factories can be installed or removed into a running Java virtual machine.
ServiceLoader.reload()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||