下面列出了怎么用org.junit.runners.model.FrameworkField的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Creates the {@link TestClass} object for this JUnit runner with the
* specified test class.
* <p>
* This method has been overridden to retrofit the {@link FrameworkMethod}
* objects.
*
* @param testClass The test class.
* @return The {@link TestClass} object for this JUnit runner with the
* specified test class.
*/
@Override
protected TestClass createTestClass(final Class<?> testClass) {
return new TestClass(testClass) {
@Override
public List<FrameworkMethod> getAnnotatedMethods(final Class<? extends Annotation> annotationClass) {
final List<FrameworkMethod> retrofitted = new ArrayList<>();
for (final FrameworkMethod method : super.getAnnotatedMethods(annotationClass))
retrofitted.add(retrofitMethod(method));
return Collections.unmodifiableList(retrofitted);
}
@Override
protected void scanAnnotatedMembers(final Map<Class<? extends Annotation>,List<FrameworkMethod>> methodsForAnnotations, final Map<Class<? extends Annotation>,List<FrameworkField>> fieldsForAnnotations) {
super.scanAnnotatedMembers(methodsForAnnotations, fieldsForAnnotations);
for (final Map.Entry<Class<? extends Annotation>,List<FrameworkMethod>> entry : methodsForAnnotations.entrySet()) {
final ListIterator<FrameworkMethod> iterator = entry.getValue().listIterator();
while (iterator.hasNext())
iterator.set(retrofitMethod(iterator.next()));
}
}
};
}
/**
* {@inheritDoc}
*/
@Override
protected void scanAnnotatedMembers(final Map<Class<? extends Annotation>,
List<FrameworkMethod>> methodsForAnnotations,
final Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations) {
for (final Class<?> eachClass : getSuperClasses(getJavaClass())) {
for (final Method eachMethod : MethodSorter.getDeclaredMethods(eachClass)) {
addToAnnotationLists(new FrameworkMethod(eachMethod), methodsForAnnotations);
}
// Fields are ignored
}
for (final Map.Entry<Class<? extends Annotation>,
List<FrameworkMethod>> methodsEntry : methodsForAnnotations.entrySet()) {
final Class<? extends Annotation> key = methodsEntry.getKey();
if (key == Test.class) {
final List<FrameworkMethod> methods = methodsEntry.getValue();
final List<FrameworkMethod> newMethods = new ArrayList<>(methods.size() * 2);
for (final FrameworkMethod m : methods) {
newMethods.add(new StandardsFrameworkMethod(m.getMethod(), false));
newMethods.add(new StandardsFrameworkMethod(m.getMethod(), true));
}
methodsForAnnotations.put(key, newMethods);
}
}
}
/**
* Implements behavior from: org.junit.runners.Parameterized$TestClassRunnerForParameters
*/
private Object createTestUsingFieldInjection() throws Exception {
List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
if (annotatedFieldsByParameter.size() != fParameters.length) {
throw new Exception("Wrong number of parameters and @Parameter fields."
+ " @Parameter fields counted: " + annotatedFieldsByParameter.size()
+ ", available parameters: " + fParameters.length + ".");
}
Object testClassInstance = getTestClass().getJavaClass().getConstructor().newInstance();
for (FrameworkField each : annotatedFieldsByParameter) {
Field field = each.getField();
Parameter annotation = field.getAnnotation(Parameter.class);
int index = annotation.value();
try {
field.set(testClassInstance, fParameters[index]);
} catch (IllegalArgumentException iare) {
throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName()
+ " with the value " + fParameters[index] + " that is not the right type ("
+ fParameters[index].getClass().getSimpleName() + " instead of "
+ field.getType().getSimpleName() + ").", iare);
}
}
return testClassInstance;
}
private void injectTestParameter() throws Exception
{
int parameterFieldCount = statementData.getParameterFrameworkFields().size();
Object[] parameter = statementData.getParameter();
if (parameterFieldCount != parameter.length)
{
throw new Exception("Number of parameters (" + parameter.length + ") and " + //
"fields (" + parameterFieldCount + ") " + //
"annotated with @Parameter must match!");
}
for (FrameworkField parameterFrameworkField : statementData.getParameterFrameworkFields())
{
Field field = parameterFrameworkField.getField();
int parameterIndex = field.getAnnotation(Parameter.class).value();
LOGGER.debug("Set parameter \"" + parameterFrameworkField.getName() + "\" to \"" + parameter[parameterIndex] + "\"");
setField(field, parameter[parameterIndex]);
}
}
public List<T> getInjectionTestPoints()
throws IllegalAccessException
{
List<T> result = new ArrayList<>();
List<FrameworkField> fields = getTestClass().getAnnotatedFields();
final MethodHandles.Lookup lookup = MethodHandles.lookup();
for (FrameworkField field : fields) {
Field javaField = field.getField();
javaField.setAccessible(true);
MethodHandle setter = lookup.unreflectSetter(javaField);
T ip = createInjectionPoint(javaField.getType(),
javaField.getAnnotations(),
setter);
result.add(ip);
}
return result;
}
@Override
protected void scanAnnotatedMembers(Map<Class<? extends Annotation>,List<FrameworkMethod>> methodsForAnnotations,
Map<Class<? extends Annotation>,List<FrameworkField>> fieldsForAnnotations)
{
super.scanAnnotatedMembers(methodsForAnnotations, fieldsForAnnotations);
for (Map.Entry<Class<? extends Annotation>,List<FrameworkMethod>> entry
: methodsForAnnotations.entrySet()) {
if (Test.class.equals(entry.getKey())) {
List<FrameworkMethod> methods = new ArrayList<>();
for (FrameworkMethod method : entry.getValue()) {
Method javaMethod = method.getMethod();
if (javaMethod.getParameterTypes().length > 0) {
methods.add(new BaratineFrameworkMethod(javaMethod));
}
else {
methods.add(method);
}
}
entry.setValue(methods);
}
}
}
private static PropertyDescriptor findDescriptor(TestClass testClass,
PropertyDescriptor[] descriptors,
FrameworkField field,
String name)
throws Exception
{
for (PropertyDescriptor d : descriptors)
{
if (d.getName().equals(name))
{
if (d.getWriteMethod() == null) break; // To throw error
return d;
}
}
throw new Exception("@Inject value '" + name
+ "' doesn't match a writeable property near "
+ testClass.getName() + '.'
+ field.getField().getName());
}
public KurentoTestListener(List<FrameworkField> services) {
this.serviceFields = services;
for (FrameworkField service : serviceFields) {
TestService serviceRunner = null;
try {
serviceRunner = (TestService) service.getField().get(null);
if (!serviceRunners.contains(serviceRunner)) {
serviceRunners.add(serviceRunner);
if (serviceRunner.getScope() == TESTSUITE) {
serviceRunner.start();
}
}
} catch (Throwable e) {
log.warn("Exception instanting service in class {}", serviceRunner, e);
}
}
}
private void doInject(TestClass klass, Object instance) {
try {
for (FrameworkField frameworkField : klass.getAnnotatedFields(Inject.class)) {
Field field = frameworkField.getField();
if ((instance == null && Modifier.isStatic(field.getModifiers()) ||
instance != null)) {//we want to do injection even on static fields before test run, so we make sure that client is correct for current state of server
field.setAccessible(true);
if (field.getType() == ManagementClient.class && controller.isStarted()) {
field.set(instance, controller.getClient());
} else if (field.getType() == ModelControllerClient.class && controller.isStarted()) {
field.set(instance, controller.getClient().getControllerClient());
} else if (field.getType() == ServerController.class) {
field.set(instance, controller);
}
}
}
} catch (Exception e) {
throw new RuntimeException("Failed to inject", e);
}
}
@Override
protected List<FrameworkMethod> getChildren() {
final List<FrameworkMethod> result = new ArrayList<>();
final TestClass testClass = getTestClass();
final Collection<Object> parameters = resolveParameters(testClass);
// If there are no resolved parameters we can just use the default methods
if (parameters.isEmpty()) {
result.addAll(super.getChildren());
} else {
final FrameworkField field = findParameterField(testClass);
for (FrameworkMethod method : super.getChildren()) {
for (Object value : parameters) {
parameterDescriptions.add(method, field, value);
// Add the same method for each parameter value
result.add(method);
}
}
}
return result;
}
private static List<GeoWaveStoreRunnerConfig> addRunnerConfigsForField(
final FrameworkField field,
final List<GeoWaveStoreRunnerConfig> currentConfigs,
final Set<GeoWaveStoreType> storeTypes) throws GeoWaveITException {
final GeoWaveTestStore store = field.getField().getAnnotation(GeoWaveTestStore.class);
final GeoWaveStoreType[] types = store.value();
if ((types == null) || (types.length == 0)) {
throw new GeoWaveITException(
MessageFormat.format("{0} must have at least one GeoWaveStoreType", field.getName()));
}
final List<GeoWaveStoreRunnerConfig> newConfigs = new ArrayList<>();
for (final GeoWaveStoreRunnerConfig config : currentConfigs) {
for (final GeoWaveStoreType type : types) {
newConfigs.add(new GeoWaveStoreRunnerConfig(config, field.getName(), type));
storeTypes.add(type);
}
}
return newConfigs;
}
/**
* @return {@code true} if the test class has any fields annotated with {@code Rule} whose type is
* {@link Timeout}.
*/
static boolean hasTimeoutRule(TestClass testClass) {
// Many protected convenience methods in BlockJUnit4ClassRunner that are available in JUnit 4.11
// such as getTestRules(Object) were not public until
// https://github.com/junit-team/junit/commit/8782efa08abf5d47afdc16740678661443706740,
// which appears to be JUnit 4.9. Because we allow users to use JUnit 4.7, we need to include a
// custom implementation that is backwards compatible to JUnit 4.7.
List<FrameworkField> fields = testClass.getAnnotatedFields(Rule.class);
for (FrameworkField field : fields) {
if (field.getField().getType().equals(Timeout.class)) {
return true;
}
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
protected void validateFields(final List<Throwable> errors) {
super.validateFields(errors);
if (fieldsAreAnnotated()) {
final List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
final int[] usedIndices = new int[annotatedFieldsByParameter.size()];
for (final FrameworkField each : annotatedFieldsByParameter) {
final int index = each.getField().getAnnotation(Parameter.class)
.value();
if (index < 0 || index > annotatedFieldsByParameter.size() - 1) {
errors.add(new Exception("Invalid @Parameter value: "
+ index + ". @Parameter fields counted: "
+ annotatedFieldsByParameter.size()
+ ". Please use an index between 0 and "
+ (annotatedFieldsByParameter.size() - 1) + "."));
}
else {
usedIndices[index]++;
}
}
for (int index = 0; index < usedIndices.length; index++) {
final int numberOfUse = usedIndices[index];
if (numberOfUse == 0) {
errors.add(new Exception("@Parameter(" + index
+ ") is never used."));
}
else if (numberOfUse > 1) {
errors.add(new Exception("@Parameter(" + index
+ ") is used more than once (" + numberOfUse + ")."));
}
}
}
}
/**
* {@inheritDoc}
*/
@Override
public Object invokeExplosively(final Object target, final Object... params)
throws Throwable {
if (!parameters_.isEmpty()) {
final List<FrameworkField> annotatedFieldsByParameter = testClass_.getAnnotatedFields(Parameter.class);
if (annotatedFieldsByParameter.size() != parameters_.size()) {
throw new Exception(
"Wrong number of parameters and @Parameter fields."
+ " @Parameter fields counted: "
+ annotatedFieldsByParameter.size()
+ ", available parameters: " + parameters_.size()
+ ".");
}
for (final FrameworkField each : annotatedFieldsByParameter) {
final Field field = each.getField();
final Parameter annotation = field.getAnnotation(Parameter.class);
final int index = annotation.value();
try {
field.set(target, parameters_.get(index));
}
catch (final IllegalArgumentException iare) {
throw new Exception(testClass_.getName()
+ ": Trying to set " + field.getName()
+ " with the value " + parameters_.get(index)
+ " that is not the right type ("
+ parameters_.get(index).getClass().getSimpleName()
+ " instead of " + field.getType().getSimpleName()
+ ").", iare);
}
}
}
return super.invokeExplosively(target, params);
}
/**
* Implements behavior from: org.junit.runners.Parameterized$TestClassRunnerForParameters
*/
@Override
protected void validateFields(List<Throwable> errors) {
super.validateFields(errors);
if (fieldsAreAnnotated()) {
List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
int[] usedIndices = new int[annotatedFieldsByParameter.size()];
for (FrameworkField each : annotatedFieldsByParameter) {
int index = each.getField().getAnnotation(Parameter.class).value();
if (index < 0 || index > annotatedFieldsByParameter.size() - 1) {
errors.add(new Exception("Invalid @Parameter value: " + index + ". @Parameter fields counted: "
+ annotatedFieldsByParameter.size() + ". Please use an index between 0 and "
+ (annotatedFieldsByParameter.size() - 1) + "."));
} else {
usedIndices[index]++;
}
}
for (int index = 0; index < usedIndices.length; index++) {
int numberOfUse = usedIndices[index];
if (numberOfUse == 0) {
errors.add(new Exception("@Parameter(" + index + ") is never used."));
} else if (numberOfUse > 1) {
errors.add(new Exception("@Parameter(" + index + ") is used more than once (" + numberOfUse
+ ")."));
}
}
}
}
private Collection<ArchTestExecution> findArchRuleFields() {
List<ArchTestExecution> result = new ArrayList<>();
for (FrameworkField ruleField : getTestClass().getAnnotatedFields(ArchTest.class)) {
result.addAll(findArchRulesIn(ruleField));
}
return result;
}
private Set<ArchTestExecution> findArchRulesIn(FrameworkField ruleField) {
boolean ignore = elementShouldBeIgnored(ruleField.getField());
if (ruleField.getType() == ArchRules.class) {
return asTestExecutions(getArchRules(ruleField.getField()), ignore);
}
return Collections.<ArchTestExecution>singleton(new ArchRuleExecution(getTestClass().getJavaClass(), ruleField.getField(), ignore));
}
private Object createTestUsingFieldInjection() throws Exception {
List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
if (annotatedFieldsByParameter.size() != parameters.length) {
throw new Exception(
"Wrong number of parameters and @Parameter fields."
+ " @Parameter fields counted: "
+ annotatedFieldsByParameter.size()
+ ", available parameters: " + parameters.length
+ ".");
}
Object testClassInstance = getTestClass().getJavaClass().newInstance();
for (FrameworkField each : annotatedFieldsByParameter) {
Field field = each.getField();
Parameter annotation = field.getAnnotation(Parameter.class);
int index = annotation.value();
try {
field.set(testClassInstance, parameters[index]);
} catch (IllegalArgumentException iare) {
throw new Exception(getTestClass().getName()
+ ": Trying to set " + field.getName()
+ " with the value " + parameters[index]
+ " that is not the right type ("
+ parameters[index].getClass().getSimpleName()
+ " instead of " + field.getType().getSimpleName()
+ ").", iare);
}
}
return testClassInstance;
}
@Override
protected void validateFields(List<Throwable> errors) {
super.validateFields(errors);
if (getInjectionType() == InjectionType.FIELD) {
List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
int[] usedIndices = new int[annotatedFieldsByParameter.size()];
for (FrameworkField each : annotatedFieldsByParameter) {
int index = each.getField().getAnnotation(Parameter.class)
.value();
if (index < 0 || index > annotatedFieldsByParameter.size() - 1) {
errors.add(new Exception("Invalid @Parameter value: "
+ index + ". @Parameter fields counted: "
+ annotatedFieldsByParameter.size()
+ ". Please use an index between 0 and "
+ (annotatedFieldsByParameter.size() - 1) + "."));
} else {
usedIndices[index]++;
}
}
for (int index = 0; index < usedIndices.length; index++) {
int numberOfUse = usedIndices[index];
if (numberOfUse == 0) {
errors.add(new Exception("@Parameter(" + index
+ ") is never used."));
} else if (numberOfUse > 1) {
errors.add(new Exception("@Parameter(" + index
+ ") is used more than once (" + numberOfUse + ")."));
}
}
}
}
public JpaUnitRunner(final Class<?> clazz) throws InitializationError {
super(clazz);
executor = new DecoratorExecutor();
final List<FrameworkField> ruleFields = getTestClass().getAnnotatedFields(Rule.class);
if (ruleFields.stream().anyMatch(f -> f.getType().equals(JpaUnitRule.class))) {
throw new InitializationError("JpaUnitRunner and JpaUnitRule exclude each other");
}
}
public SharedBehaviorTesting(
Function<RunNotifier, Statement> superChildrenInvoker,
BiConsumer<FrameworkMethod, RunNotifier> superChildRunner,
TestSupplier superCreateTest,
Supplier<Description> superDescription,
Supplier<TestClass> testClass,
BiFunction<Class<?>, String, Description> descriptionFactory,
FeatureSet features)
throws InitializationError {
this.superChildrenInvoker = superChildrenInvoker;
this.superChildRunner = superChildRunner;
this.superCreateTest = superCreateTest;
this.superDescription = superDescription;
this.features = features;
List<FrameworkField> testerFields = testClass.get().getAnnotatedFields(Shared.class);
if (testerFields.isEmpty()) {
throw new InitializationError("No public @Shared field found");
} else if (testerFields.size() > 1) {
throw new InitializationError("Multiple public @Shared fields found");
}
FrameworkField frameworkField = getOnlyElement(testerFields);
if (!frameworkField.isPublic()) {
throw new InitializationError("@Shared field " + frameworkField + " must be public");
}
if (!frameworkField.getType().isAssignableFrom(BehaviorTester.class)) {
throw new InitializationError(String.format(
"@Shared field %s must be of type %s",
frameworkField,
BehaviorTester.class.getSimpleName()));
}
testerField = frameworkField.getField();
introspection = descriptionFactory.apply(testClass.get().getJavaClass(), "Introspect");
}
private static Dimension[] findDimensions(TestClass testClass)
throws Throwable
{
List<FrameworkField> fields =
testClass.getAnnotatedFields(Inject.class);
if (fields.isEmpty())
{
throw new Exception("No fields of " + testClass.getName()
+ " have the @Inject annotation");
}
BeanInfo beanInfo = Introspector.getBeanInfo(testClass.getJavaClass());
PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
Dimension[] dimensions = new Dimension[fields.size()];
int i = 0;
for (FrameworkField field : fields)
{
int modifiers = field.getField().getModifiers();
if (! Modifier.isPublic(modifiers) || ! Modifier.isStatic(modifiers))
{
throw new Exception("@Inject " + testClass.getName() + '.'
+ field.getField().getName()
+ " must be public static");
}
Dimension dim = new Dimension();
dim.property = field.getField().getAnnotation(Inject.class).value();
dim.descriptor = findDescriptor(testClass, descriptors, field, dim.property);
dim.values = (Object[]) field.get(null);
dimensions[i++] = dim;
}
return dimensions;
}
private Object createTestUsingFieldInjection() throws Exception {
List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
if (annotatedFieldsByParameter.size() != parameters.length) {
throw new Exception(
"Wrong number of parameters and @Parameter fields."
+ " @Parameter fields counted: "
+ annotatedFieldsByParameter.size()
+ ", available parameters: " + parameters.length
+ ".");
}
Object testClassInstance = getTestClass().getJavaClass().newInstance();
for (FrameworkField each : annotatedFieldsByParameter) {
Field field = each.getField();
Parameterized.Parameter annotation = field.getAnnotation(Parameterized.Parameter.class);
int index = annotation.value();
try {
field.set(testClassInstance, parameters[index]);
} catch (IllegalArgumentException iare) {
throw new Exception(getTestClass().getName()
+ ": Trying to set " + field.getName()
+ " with the value " + parameters[index]
+ " that is not the right type ("
+ parameters[index].getClass().getSimpleName()
+ " instead of " + field.getType().getSimpleName()
+ ").", iare);
}
}
return testClassInstance;
}
@Override
protected void validateFields(List<Throwable> errors) {
super.validateFields(errors);
if (fieldsAreAnnotated()) {
List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter();
int[] usedIndices = new int[annotatedFieldsByParameter.size()];
for (FrameworkField each : annotatedFieldsByParameter) {
int index = each.getField().getAnnotation(Parameterized.Parameter.class)
.value();
if (index < 0 || index > annotatedFieldsByParameter.size() - 1) {
errors.add(new Exception("Invalid @Parameter value: "
+ index + ". @Parameter fields counted: "
+ annotatedFieldsByParameter.size()
+ ". Please use an index between 0 and "
+ (annotatedFieldsByParameter.size() - 1) + "."));
} else {
usedIndices[index]++;
}
}
for (int index = 0; index < usedIndices.length; index++) {
int numberOfUse = usedIndices[index];
if (numberOfUse == 0) {
errors.add(new Exception("@Parameter(" + index
+ ") is never used."));
} else if (numberOfUse > 1) {
errors.add(new Exception("@Parameter(" + index
+ ") is used more than once (" + numberOfUse + ")."));
}
}
}
}
/**
* {@link ParameterizedClassRule}が設定されているフィールドまたはメソッドをチェックします。
*
* @param errors エラーのリスト。チェックした結果エラーがあった場合、このリストに追加される
*/
protected void validateParameterizedClassRules(List<Throwable> errors) {
for (FrameworkMethod method : getTestClass().getAnnotatedMethods(ParameterizedClassRule.class)) {
if (!method.isStatic()) {
errors.add(new Exception("Method " + method.getName() + "() should be static"));
}
if (!method.isPublic()) {
errors.add(new Exception("Method " + method.getName() + "() should be public"));
}
if (method.getMethod().getParameterTypes().length != 0) {
errors.add(new Exception("Method " + method.getName() + "() should have no parameters"));
}
if (!ParameterizedTestRule.class.isAssignableFrom(method.getType())) {
errors.add(new Exception("Method " + method.getName()
+ "() must return an implementation of ParameterizedTestRule"));
}
}
for (FrameworkField field : getTestClass().getAnnotatedFields(ParameterizedClassRule.class)) {
if (!field.isStatic()) {
errors.add(new Exception("Field " + field.getName() + " should be static"));
}
if (!field.isPublic()) {
errors.add(new Exception("Field " + field.getName() + " should be public"));
}
if (!ParameterizedTestRule.class.isAssignableFrom(field.getType())) {
errors.add(new Exception("Field " + field.getName() + " must implement ParameterizedTestRule"));
}
}
}
@Override
public void run(RunNotifier notifier) {
if (listener != null) {
notifier.removeListener(listener);
}
List<FrameworkField> services = this.getTestClass().getAnnotatedFields(Service.class);
ArrayList<FrameworkField> sortedServices = new ArrayList<>(services);
Collections.sort(sortedServices, new Comparator<FrameworkField>() {
@Override
public int compare(FrameworkField o1, FrameworkField o2) {
return Integer.compare(o1.getAnnotation(Service.class).value(),
o2.getAnnotation(Service.class).value());
}
});
listener = new KurentoTestListener(sortedServices);
notifier.addListener(listener);
listener.testRunStarted(getDescription());
if (!shutdownHook) {
shutdownHook = true;
Runtime.getRuntime().addShutdownHook(new Thread("app-shutdown-hook") {
@Override
public void run() {
listener.testSuiteFinished();
}
});
}
// TODO Remove this if we change service management
notifier = new KurentoRunNotifier(notifier);
super.run(notifier);
}
private FrameworkField findParameterField(final TestClass testClass) {
final List<FrameworkField> fields = testClass.getAnnotatedFields(Parameter.class);
if (fields.size() > 1) {
throw new RuntimeException(String.format("More than one field was annotated with @%s: %s",
Parameter.class.getSimpleName(), fields));
} else if (fields.isEmpty()) {
throw new RuntimeException(String.format("If the @%s annotation is present on a method a field must be annotated with @%s",
Parameters.class.getSimpleName(), Parameter.class.getSimpleName()));
}
return fields.get(0);
}
@Override
protected void validateFields(final List<Throwable> errors) {
super.validateFields(errors);
if (typeIsAnnotated()) {
if (fieldsAreAnnotated()) {
errors.add(
new GeoWaveITException(
"Only type or fields can be annotated with @GeoWaveTestStore, not both"));
}
try {
getDataStoreOptionFieldsForTypeAnnotation();
} catch (final Exception e) {
errors.add(e);
}
} else if (fieldsAreAnnotated()) {
final List<FrameworkField> annotatedFields = getStoreAnnotatedFields();
for (final FrameworkField field : annotatedFields) {
if (!field.getType().isAssignableFrom(DataStorePluginOptions.class)) {
errors.add(
new GeoWaveITException(
"'"
+ field.getName()
+ "' must be of type '"
+ DataStorePluginOptions.class.getName()
+ "'"));
}
}
}
}
private List<FrameworkField> getAnnotatedFieldsByParameter() {
return getTestClass().getAnnotatedFields(Parameter.class);
}
/**
* Implements behavior from: org.junit.runners.Parameterized
*/
List<FrameworkField> getAnnotatedFieldsByParameter() {
return getTestClass().getAnnotatedFields(Parameter.class);
}