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<GeoWaveStoreRunnerConfig>(); for (final GeoWaveStoreRunnerConfig config : currentConfigs) { for (final GeoWaveStoreType type : types) { newConfigs.add(new GeoWaveStoreRunnerConfig(config, field.getName(), type)); storeTypes.add(type); } } return newConfigs; }
@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 void prepareFixtures() throws Exception { checkForDuplicateFixtureFieldName(); InjectionContext context = getInjectionContext(); final List<FrameworkField> fieldsWithFixtures = this.getTestClass().getAnnotatedFields(Fixture.class); for (FrameworkField f : fieldsWithFixtures) { if (!f.isStatic()) { throw new IllegalArgumentException("Field " + f.getName() + " is a @Fixture, but is not declared static"); } f.getField().setAccessible(true); Object fixture = f.get(null); if (! (fixture instanceof TestFixture)) { throw new IllegalArgumentException("Field " + f.getName() + " is a @Fixture, but does not reflect a legal TestFixture"); } context.injectMembers(fixture); final String fixtureKey = getFixtureKey(f.getField().getDeclaringClass(), f.getName()); fixtures.put(fixtureKey, (TestFixture) fixture); } }
Field field = f.getField(); if (!Modifier.isStatic(field.getModifiers())) { errors.add(new Exception("Param Getter Field " + f.getName() + " should be static.")); errors.add(new Exception("Param Getter Field " + f.getName() + " should be public.")); errors.add(new Exception("Param Getter Field " + f.getName() + " should be final.")); errors.add(new Exception("Param Getter Field " + f.getName() + " should be " + anno.value().getParamString(getParamType()) + "."));
@Override protected void validateFields(List<Throwable> errors) { super.validateFields(errors); if (fieldAnnotated()) { List<FrameworkField> configFields = getFieldsAnnotatedByKiWiConfig(); for (FrameworkField field : configFields) { if (!field.getType().isAssignableFrom(KiWiConfiguration.class)) { errors.add(new Exception(String.format("Invalid type %s for field %s, must be %s", field.getType().getName(), field.getName(), KiWiConfiguration.class.getSimpleName()))); } } } }
@Override protected Object createTest() throws Exception { if (fieldAnnotated()) { Object testInstance = getTestClass().getOnlyConstructor().newInstance(); List<FrameworkField> configFields = getFieldsAnnotatedByKiWiConfig(); for (FrameworkField field : configFields) { try { field.getField().set(testInstance, config); } catch (IllegalArgumentException iae) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " that has a wrong type."); } } return testInstance; } return getTestClass().getOnlyConstructor().newInstance(config); }