本文整理汇总了Java中org.junit.jupiter.api.extension.ExtensionContext.Store.get方法的典型用法代码示例。如果您正苦于以下问题:Java Store.get方法的具体用法?Java Store.get怎么用?Java Store.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.jupiter.api.extension.ExtensionContext.Store
的用法示例。
在下文中一共展示了Store.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateInjector
import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入方法依赖的package包/类
/**
* Returns an injector for the given context if and only if the given context has an {@link
* ExtensionContext#getElement() annotated element}.
*/
private static Optional<Injector> getOrCreateInjector(ExtensionContext context)
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException {
if (!context.getElement().isPresent()) {
return Optional.empty();
}
AnnotatedElement element = context.getElement().get();
Store store = context.getStore(NAMESPACE);
Injector injector = store.get(element, Injector.class);
if (injector == null) {
injector = createInjector(context);
store.put(element, injector);
}
return Optional.of(injector);
}
示例2: getTestContext
import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入方法依赖的package包/类
/**
* one test context (datasetExecutor, dbunitConfig etc..) per test
*/
private DBUnitTestContext getTestContext(ExtensionContext context) {
Class<?> testClass = context.getTestClass().get();
Store store = context.getStore(namespace);
DBUnitTestContext testContext = store.get(testClass, DBUnitTestContext.class);
if (testContext == null) {
testContext = new DBUnitTestContext();
store.put(testClass, testContext);
}
return testContext;
}
示例3: invokeDataProviderMethodToRetrieveData
import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入方法依赖的package包/类
/**
* Retrieves the test data from given dataprovider method.
*
* @param dataProviderMethod the dataprovider method that gives the parameters; never {@code null}
* @param cacheDataProviderResult determines if the dataprovider result should be cached using
* {@code dataProviderMethod} as key
* @param context the execution context to use to create a {@link TestInfo} if required; never {@code null}
*
* @return a list of methods, each method bound to a parameter combination returned by the dataprovider
* @throws NullPointerException if and only if one of the given arguments is {@code null}
*/
protected Object invokeDataProviderMethodToRetrieveData(Method dataProviderMethod, boolean cacheDataProviderResult,
ExtensionContext context) {
checkNotNull(dataProviderMethod, "'dataProviderMethod' must not be null");
checkNotNull(context, "'context' must not be null");
Store store = context.getRoot().getStore(NAMESPACE_USE_DATAPROVIDER);
Object cached = store.get(dataProviderMethod);
if (cached != null) {
return cached;
}
try {
// TODO how to not require junit-jupiter-engine dependency and reuse already existing ExtensionRegistry?
ExtensionRegistry extensionRegistry = createRegistryWithDefaultExtensions(emptyConfigurationParameters());
Object data = executableInvoker.invoke(dataProviderMethod, context.getTestInstance().orElse(null), context,
extensionRegistry);
if (cacheDataProviderResult) {
store.put(dataProviderMethod, data);
}
return data;
} catch (Exception e) {
throw new ParameterResolutionException(
String.format("Exception while invoking dataprovider method '%s': %s", dataProviderMethod.getName(),
e.getMessage()),
e);
}
}
示例4: getCurrentLevelSeedFromStore
import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入方法依赖的package包/类
private static Long getCurrentLevelSeedFromStore(ExtensionContext context) {
Store store = getStore(context);
Object seed = null;
if(store != null) seed = store.get("seed");
return seed != null ? (Long) seed : null;
}