当前位置: 首页>>代码示例>>Java>>正文


Java Store类代码示例

本文整理汇总了Java中org.junit.jupiter.api.extension.ExtensionContext.Store的典型用法代码示例。如果您正苦于以下问题:Java Store类的具体用法?Java Store怎么用?Java Store使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Store类属于org.junit.jupiter.api.extension.ExtensionContext包,在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:25,代码来源:GuiceExtension.java

示例2: beforeEach

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
@Override
public void beforeEach(ExtensionContext context) {
  IdeaMocksImpl ideaMocks = new IdeaMocksImpl();
  Project project = mock(Project.class);
  MessageBus messageBus = mock(MessageBus.class);
  when(project.getMessageBus()).thenReturn(messageBus);
  when(messageBus.syncPublisher(any(Topic.class))).thenAnswer(invocation -> {
    Topic topic = invocation.getArgument(0);
    Class<?> listenerClass = topic.getListenerClass();
    if (ideaMocks.hasMockListener(listenerClass)) {
      return ideaMocks.getMockListener(listenerClass);
    } else {
      return ideaMocks.mockListener(listenerClass);
    }
  });

  Store store = context.getStore(NS);
  store.put(Project.class, project);
  store.put(MessageBus.class, messageBus);
  store.put(IdeaMocks.class, ideaMocks);
}
 
开发者ID:zielu,项目名称:GitToolBox,代码行数:22,代码来源:IdeaMocksExtension.java

示例3: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
	Class<?> mockType = parameter.getType();
	Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
	String mockName = getMockName(parameter);

	if (mockName != null) {
		return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
	}
	else {
		return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
	}
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:13,代码来源:MockitoExtension.java

示例4: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(Parameter parameter,
        ExtensionContext extensionContext) {
    Class<?> mockType = parameter.getType();
    Store mocks = extensionContext
            .getStore(Namespace.create(MockitoExtension.class, mockType));
    String mockName = getMockName(parameter);

    if (mockName != null) {
        return mocks.getOrComputeIfAbsent(mockName,
                key -> mock(mockType, mockName));
    } else {
        return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(),
                key -> mock(mockType));
    }
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:16,代码来源:MockitoExtension.java

示例5: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
  Class<?> mockType = parameter.getType();
  Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
  String mockName = getMockName(parameter);

  if (mockName != null) {
    return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
  } else {
    return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
  }
}
 
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:12,代码来源:MockitoExtension.java

示例6: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
	Class<?> mockType = parameter.getType();
	Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
	String mockName = getMockName(parameter);

	if (mockName != null) {
		return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
	}
	return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:11,代码来源:MockitoExtension.java

示例7: 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;
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:14,代码来源:DBUnitExtension.java

示例8: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
    Class<?> mockType = parameter.getType();
    Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
    String mockName = getMockName(parameter);

    if (mockName != null) {
        return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
    }
    else {
        return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
    }
}
 
开发者ID:rsky,项目名称:logbook-kai-plugins,代码行数:13,代码来源:MockitoExtension.java

示例9: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
    Class<?> mockType = parameter.getType();
    Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
    String mockName = getMockName(parameter);

    if (mockName != null) {
        return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
    } else {
        return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
    }
}
 
开发者ID:bkimminich,项目名称:kata-botwars,代码行数:12,代码来源:MockitoExtension.java

示例10: getMock

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private Object getMock(final Parameter parameter, final ExtensionContext extensionContext) {
  final Class<?> mockType = parameter.getType();
  final Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
  final String mockName = getMockName(parameter);

  return (mockName != null)
      ? mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName))
      : mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:10,代码来源:MockitoExtension.java

示例11: getTestContextManager

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
/**
 * Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}.
 * @return the {@code TestContextManager} (never {@code null})
 */
private static TestContextManager getTestContextManager(ExtensionContext context) {
	Assert.notNull(context, "ExtensionContext must not be null");
	Class<?> testClass = context.getRequiredTestClass();
	Store store = getStore(context);
	return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class);
}
 
开发者ID:sbrannen,项目名称:spring-test-junit5,代码行数:11,代码来源:SpringExtension.java

示例12: runSetup

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private void runSetup(ExtensionContext context) throws Exception {
  if (runInDispatchThread()) {
    TestRunnerUtil.replaceIdeEventQueueSafely();
    EdtTestUtil.runInEdtAndWait(this::setUp);
  } else {
    setUp();
  }
  Store store = getStore(context);
  store.put(Project.class, getProject());
  store.put(Module.class, getModule());
}
 
开发者ID:zielu,项目名称:GitToolBox,代码行数:12,代码来源:PlatformTestCaseExtension.java

示例13: runTearDown

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
private void runTearDown(ExtensionContext context) throws Exception {
  if (runInDispatchThread()) {
    EdtTestUtil.runInEdtAndWait(this::tearDown);
  } else {
    tearDown();
  }
  Store store = getStore(context);
  store.remove(Project.class);
  store.remove(Module.class);
}
 
开发者ID:zielu,项目名称:GitToolBox,代码行数:11,代码来源:PlatformTestCaseExtension.java

示例14: afterEach

import org.junit.jupiter.api.extension.ExtensionContext.Store; //导入依赖的package包/类
@Override
public void afterEach(ExtensionContext context) {
  Store store = context.getStore(NS);
  store.remove(Project.class);
  store.remove(MessageBus.class);
  store.remove(IdeaMocks.class);
}
 
开发者ID:zielu,项目名称:GitToolBox,代码行数:8,代码来源:IdeaMocksExtension.java

示例15: 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);
    }
}
 
开发者ID:TNG,项目名称:junit-dataprovider,代码行数:40,代码来源:AbstractUseDataProviderArgumentProvider.java


注:本文中的org.junit.jupiter.api.extension.ExtensionContext.Store类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。