Java Code Examples for org.junit.jupiter.api.extension.ExtensionContext#Store

The following examples show how to use org.junit.jupiter.api.extension.ExtensionContext#Store . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MeecrowaveExtension.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@Override
public void afterAll(final ExtensionContext context) {
    final ExtensionContext.Store store = context.getStore(NAMESPACE);
    ofNullable(store.get(LifecyleState.class, LifecyleState.class))
            .ifPresent(s -> s.afterLastTest(context));
    if (isPerClass(context)) {
        store.get(Meecrowave.class, Meecrowave.class).close();
    }
}
 
Example 2
Source File: MonoMeecrowaveExtension.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeAll(final ExtensionContext context) {
    final ExtensionContext.Store store = context.getStore(NAMESPACE);
    store.put(MonoBase.Instance.class, BASE.startIfNeeded());
    if (isPerClass(context)) {
        doInject(context);
        store.put(LifecyleState.class, onInjection(context, null));
    }
}
 
Example 3
Source File: SparkExtension.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeAll(final ExtensionContext extensionContext) throws Exception {
    temporaryFolderExtension.beforeAll(extensionContext);
    root = TemporaryFolder.class
            .cast(temporaryFolderExtension.findInstance(extensionContext, TemporaryFolder.class))
            .getRoot();

    final ExtensionContext.Store store = extensionContext.getStore(NAMESPACE);
    store.put(BaseSpark.class.getName(), this);
    AnnotationUtils.findAnnotation(extensionContext.getElement(), WithSpark.class).ifPresent(ws -> {
        withSlaves(ws.slaves());
        withHadoopBase(ws.hadoopBase());
        withHadoopVersion(ws.hadoopVersion());
        withInstallWinUtils(ws.installWinUtils());
        withScalaVersion(of(ws.scalaVersion())
                .filter(it -> !"auto".equals(it))
                .orElse(SparkVersions.SPARK_SCALA_VERSION.getValue()));
        withSparkVersion(of(ws.sparkVersion())
                .filter(it -> !"auto".equals(it))
                .orElse(SparkVersions.SPARK_VERSION.getValue()));
    });
    final Instances instances = start();
    if (instances.getException() != null) {
        instances.close();
        if (Exception.class.isInstance(instances.getException())) {
            throw Exception.class.cast(instances.getException());
        }
        if (Error.class.isInstance(instances.getException())) {
            throw Error.class.cast(instances.getException());
        }
        throw new IllegalStateException(instances.getException());
    }
    store.put(AutoCloseable.class, instances);
}
 
Example 4
Source File: ComponentValidatorTest.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeEach(final ExtensionContext context) {
    final ComponentPackage config = context.getElement().get().getAnnotation(ComponentPackage.class);
    final ExtensionContext.Store store = context.getStore(NAMESPACE);
    final File pluginDir =
            new File(TemporaryFolder.class.cast(store.get(TemporaryFolder.class.getName())).getRoot() + "/"
                    + context.getRequiredTestMethod().getName());
    final ComponentValidator.Configuration cfg = new ComponentValidator.Configuration();
    cfg.setValidateFamily(true);
    cfg.setValidateSerializable(true);
    cfg.setValidateMetadata(true);
    cfg.setValidateInternationalization(true);
    cfg.setValidateDataSet(config.validateDataSet());
    cfg.setValidateActions(true);
    cfg.setValidateComponent(true);
    cfg.setValidateModel(true);
    cfg.setValidateDataStore(true);
    cfg.setValidateLayout(true);
    cfg.setValidateOptionNames(true);
    cfg.setValidateLocalConfiguration(true);
    cfg.setValidateOutputConnection(true);
    cfg.setValidatePlaceholder(true);
    cfg.setValidateSvg(config.validateSvg());
    cfg.setValidateNoFinalOption(true);
    cfg.setValidateDocumentation(config.validateDocumentation());
    cfg.setValidateWording(config.validateWording());
    Optional.of(config.pluginId()).filter(it -> !it.isEmpty()).ifPresent(cfg::setPluginId);
    listPackageClasses(pluginDir, config.value().replace('.', '/'));
    store.put(ComponentPackage.class.getName(), config);
    final TestLog log = new TestLog();
    store.put(TestLog.class.getName(), log);
    store.put(ComponentValidator.class.getName(), new ComponentValidator(cfg, new File[] { pluginDir }, log));
    store.put(ExceptionSpec.class.getName(), new ExceptionSpec());
}
 
Example 5
Source File: TempDirectoryExtension.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void afterAll(ExtensionContext context) throws Exception {
    ExtensionContext.Store store = context.getStore(ExtensionContext.Namespace.create(TempDirectoryExtension.class, app.jweb.test.impl.TempDirectory.class));
    app.jweb.test.impl.TempDirectory tempDirectory = (app.jweb.test.impl.TempDirectory) store.get(app.jweb.test.impl.TempDirectory.class);
    if (tempDirectory != null) {
        tempDirectory.delete();
    }
}
 
Example 6
Source File: TempDirectoryExtension.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    ExtensionContext.Store store = extensionContext.getStore(ExtensionContext.Namespace.create(TempDirectoryExtension.class, app.jweb.test.impl.TempDirectory.class));
    app.jweb.test.impl.TempDirectory tempDirectory = (app.jweb.test.impl.TempDirectory) store.getOrComputeIfAbsent(app.jweb.test.impl.TempDirectory.class, key -> new app.jweb.test.impl.TempDirectory());
    return tempDirectory.root();
}
 
Example 7
Source File: ResourceFlowableIdmExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 8
Source File: VaultExtension.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
private VaultInitializer getInitializer(ExtensionContext extensionContext) {
	ExtensionContext.Store store = extensionContext.getStore(VAULT);
	return store.getOrComputeIfAbsent(VaultInitializer.class, k -> new VaultInitializer(), VaultInitializer.class);
}
 
Example 9
Source File: ParameterHolder.java    From GitToolBox with Apache License 2.0 4 votes vote down vote up
public static void removeHolder(ExtensionContext.Store store) {
  store.remove(ParameterHolder.class);
}
 
Example 10
Source File: P4ServerExtension.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
private ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getStore(ExtensionContext.Namespace.create(getClass(), context.getRequiredTestMethod()));
}
 
Example 11
Source File: FlowableExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 12
Source File: IdeaLightweightExtension.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
private ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getStore(ExtensionContext.Namespace.create(getClass(), context.getRequiredTestMethod()));
}
 
Example 13
Source File: FlowableSpringExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 14
Source File: FlowableEventExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 15
Source File: GuiceyExtensionsSupport.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
private ExtensionContext.Store getLocalExtensionStore(final ExtensionContext context) {
    // test scoped extension scope (required to differentiate nested classes or parameterized executions)
    return context.getStore(ExtensionContext.Namespace
            .create(GuiceyExtensionsSupport.class, context.getRequiredTestClass()));
}
 
Example 16
Source File: PluggableFlowableIdmExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 17
Source File: PluggableFlowableExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 18
Source File: FlowableCmmnExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
Example 19
Source File: InternalFlowableIdmExtension.java    From flowable-engine with Apache License 2.0 votes vote down vote up
protected abstract ExtensionContext.Store getStore(ExtensionContext context); 
Example 20
Source File: InternalFlowableFormExtension.java    From flowable-engine with Apache License 2.0 votes vote down vote up
protected abstract ExtensionContext.Store getStore(ExtensionContext context);