Search in sources :

Example 1 with SpecInfo

use of org.spockframework.runtime.model.SpecInfo in project spock by spockframework.

the class TapestryExtension method collectModules.

// Returns null if no SubModule annotation was found.
// Returns an empty list if one or more SubModule annotations were found,
// but they didn't specify any modules. This distinction is important to
// allow activation of the extension w/o specifying any modules.
private Set<Class<?>> collectModules(SpecInfo spec) {
    Set<Class<?>> modules = null;
    for (SpecInfo curr : spec.getSpecsTopToBottom()) {
        SubModule subModule = curr.getAnnotation(SubModule.class);
        if (subModule == null)
            continue;
        if (modules == null)
            modules = new HashSet<Class<?>>();
        modules.addAll(Arrays.<Class<?>>asList(subModule.value()));
    }
    return modules;
}
Also used : SubModule(org.apache.tapestry5.ioc.annotations.SubModule) SpecInfo(org.spockframework.runtime.model.SpecInfo)

Example 2 with SpecInfo

use of org.spockframework.runtime.model.SpecInfo in project ratpack by ratpack.

the class TempDirExtension method visitFieldAnnotation.

@Override
public void visitFieldAnnotation(TempDir annotation, FieldInfo field) {
    Class<?> fieldType = field.getType();
    if (!fieldType.isAssignableFrom(TemporaryFolder.class)) {
        throw new InvalidSpecException("@TempDir can only be used on TemporaryFolder");
    }
    TempDirInterceptor interceptor = new TempDirInterceptor(fieldType, field, configuration.baseDir, configuration.keep);
    // attach interceptor
    SpecInfo specInfo = field.getParent();
    if (field.isShared()) {
        specInfo.addInterceptor(interceptor);
    } else {
        for (FeatureInfo featureInfo : specInfo.getBottomSpec().getAllFeatures()) {
            featureInfo.addIterationInterceptor(interceptor);
        }
    }
}
Also used : SpecInfo(org.spockframework.runtime.model.SpecInfo) InvalidSpecException(org.spockframework.runtime.InvalidSpecException) FeatureInfo(org.spockframework.runtime.model.FeatureInfo)

Example 3 with SpecInfo

use of org.spockframework.runtime.model.SpecInfo in project spock by spockframework.

the class ClassSelectorResolver method resolveClass.

private Resolution resolveClass(Class<?> specClass, Context context) {
    if (SpecUtil.isRunnableSpec(specClass) && classNameFilter.test(specClass.getName())) {
        return context.addToParent(parent -> {
            SpecInfo specInfo = new SpecInfoBuilder(specClass).build();
            specInfo.getAllFeatures().forEach(featureInfo -> featureInfo.setExcluded(true));
            UniqueId uniqueId = parent.getUniqueId().append("spec", specInfo.getReflection().getName());
            return Optional.of(new SpecNode(uniqueId, runContext.getConfiguration(RunnerConfiguration.class), specInfo));
        }).map(this::toResolution).orElse(Resolution.unresolved());
    }
    return Resolution.unresolved();
}
Also used : SpecInfo(org.spockframework.runtime.model.SpecInfo)

Example 4 with SpecInfo

use of org.spockframework.runtime.model.SpecInfo in project spock by spockframework.

the class TapestryInterceptor method findAllBeforeRegistryCreatedMethods.

private List<Method> findAllBeforeRegistryCreatedMethods() {
    List<Method> methods = new ArrayList<Method>();
    for (SpecInfo curr : spec.getSpecsTopToBottom()) {
        Method method = ReflectionUtil.getDeclaredMethodByName(curr.getReflection(), "beforeRegistryCreated");
        if (method != null) {
            method.setAccessible(true);
            methods.add(method);
        }
    }
    return methods;
}
Also used : SpecInfo(org.spockframework.runtime.model.SpecInfo) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method)

Example 5 with SpecInfo

use of org.spockframework.runtime.model.SpecInfo in project dropwizard-guicey by xvik.

the class AbstractAppExtension method visitSpec.

@Override
public void visitSpec(final SpecInfo spec) {
    final GuiceyInterceptor interceptor = new GuiceyInterceptor(spec, buildResourceFactory(annotation));
    final SpecInfo topSpec = spec.getTopSpec();
    topSpec.addSharedInitializerInterceptor(interceptor);
    topSpec.addInitializerInterceptor(interceptor);
    topSpec.addCleanupSpecInterceptor(interceptor);
}
Also used : SpecInfo(org.spockframework.runtime.model.SpecInfo) ConfigOverride(io.dropwizard.testing.ConfigOverride)

Aggregations

SpecInfo (org.spockframework.runtime.model.SpecInfo)5 ConfigOverride (io.dropwizard.testing.ConfigOverride)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 SubModule (org.apache.tapestry5.ioc.annotations.SubModule)1 InvalidSpecException (org.spockframework.runtime.InvalidSpecException)1 FeatureInfo (org.spockframework.runtime.model.FeatureInfo)1