public class TCK
extends java.lang.Object
Objenesis
s.
This TCK accepts a set of candidate classes (class it attempts to instantiate) and a set of
Objenesis implementations. It then tries instantiating every candidate with every Objenesis
implementations, reporting the results to a Reporter
.
TCK tck = new TCK(); // register candidate classes. tck.registerCandidate(SomeClass.class, "A basic class"); tck.registerCandidate(SomeEvil.class, "Something evil"); tck.registerCandidate(NotEvil.class, "Something nice"); // register Objenesis instances. tck.registerObjenesisInstance(new ObjenesisStd(), "Objenesis"); tck.registerObjenesisInstance(new ObjenesisSerializaer(), "Objenesis for serialization"); // go! Reporter reporter = new TextReporter(System.out, System.err); tck.runTests(reporter);
ObjectInstantiator
,
Reporter
,
Main
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.Class<?>> |
candidates |
private java.util.Map<java.lang.Object,java.lang.String> |
descriptions |
private java.util.List<Objenesis> |
objenesisInstances |
Constructor and Description |
---|
TCK() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
describePlatform()
Describes the platform.
|
private java.util.Map<java.lang.String,java.lang.Object> |
findAllDescriptions(java.util.List<?> keys,
java.util.Map<?,java.lang.String> descriptions)
Return the human readable description for list of TCK items (Objenesis instances or test
candidates)
|
void |
registerCandidate(java.lang.Class<?> candidateClass,
java.lang.String description)
Register a candidate class to attempt to instantiate.
|
void |
registerObjenesisInstance(Objenesis objenesis,
java.lang.String description)
Register an Objenesis instance to use when attempting to instantiate a class.
|
private void |
runTest(Reporter reporter,
java.lang.Class<?> candidate,
Objenesis objenesis) |
void |
runTests(Reporter reporter)
Run all TCK tests.
|
private final java.util.List<Objenesis> objenesisInstances
private final java.util.List<java.lang.Class<?>> candidates
private final java.util.Map<java.lang.Object,java.lang.String> descriptions
public void registerCandidate(java.lang.Class<?> candidateClass, java.lang.String description)
candidateClass
- Class to attempt to instantiatedescription
- Description of the classpublic void registerObjenesisInstance(Objenesis objenesis, java.lang.String description)
objenesis
- Tested Objenesis instancedescription
- Description of the Objenesis instancepublic void runTests(Reporter reporter)
reporter
- Where to report the results of the test to.private java.util.Map<java.lang.String,java.lang.Object> findAllDescriptions(java.util.List<?> keys, java.util.Map<?,java.lang.String> descriptions)
keys
- list of items for which we are searching for a descriptiondescriptions
- all descriptionsprotected java.lang.String describePlatform()