org.junit.jupiter.api.extension.ExtensionContext#Store()源码实例Demo

下面列出了org.junit.jupiter.api.extension.ExtensionContext#Store() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jweb-cms   文件: TempDirectoryExtension.java
@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();
    }
}
 
@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());
}
 
源代码3 项目: component-runtime   文件: SparkExtension.java
@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);
}
 
@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));
    }
}
 
@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();
    }
}
 
源代码6 项目: p4ic4idea   文件: IdeaLightweightExtension.java
private ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getStore(ExtensionContext.Namespace.create(getClass(), context.getRequiredTestMethod()));
}
 
源代码7 项目: flowable-engine   文件: FlowableCmmnExtension.java
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
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()));
}
 
源代码11 项目: flowable-engine   文件: FlowableEventExtension.java
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
源代码12 项目: flowable-engine   文件: FlowableSpringExtension.java
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
源代码13 项目: jweb-cms   文件: TempDirectoryExtension.java
@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();
}
 
源代码14 项目: flowable-engine   文件: FlowableExtension.java
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
源代码15 项目: p4ic4idea   文件: P4ServerExtension.java
private ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getStore(ExtensionContext.Namespace.create(getClass(), context.getRequiredTestMethod()));
}
 
源代码16 项目: GitToolBox   文件: ParameterHolder.java
public static void removeHolder(ExtensionContext.Store store) {
  store.remove(ParameterHolder.class);
}
 
源代码17 项目: spring-vault   文件: VaultExtension.java
private VaultInitializer getInitializer(ExtensionContext extensionContext) {
	ExtensionContext.Store store = extensionContext.getStore(VAULT);
	return store.getOrComputeIfAbsent(VaultInitializer.class, k -> new VaultInitializer(), VaultInitializer.class);
}
 
@Override
protected ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getRoot().getStore(NAMESPACE);
}
 
protected abstract ExtensionContext.Store getStore(ExtensionContext context); 
protected abstract ExtensionContext.Store getStore(ExtensionContext context);