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


Java ExtensionContext.getStore方法代码示例

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


在下文中一共展示了ExtensionContext.getStore方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOrCreateInjector

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的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: getMock

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的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

示例3: getMock

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的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

示例4: getMock

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的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

示例5: getMock

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的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

示例6: getMock

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
    Class<?> mockType = parameter.getType();
    ExtensionContext.Store mocks = extensionContext.getStore(ExtensionContext.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:jcapsule,项目名称:jwebassembly,代码行数:12,代码来源:MockitoExtension.java

示例7: getStore

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
private Store getStore(ExtensionContext context) {
    return context.getStore(Namespace.create(getClass(), context));
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:4,代码来源:TimingExtension.java

示例8: getStore

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
private Store getStore(ExtensionContext context) {
    return context.getStore(NAMESPACE);
}
 
开发者ID:maxbechtold,项目名称:golden-master,代码行数:4,代码来源:RunInvocationContextProvider.java

示例9: resolveParameter

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    ExtensionContext.Store store = context.getStore(ExtensionContext.Namespace.create(WiremockResolver.class));

    return "http://localhost:" + store.get(WiremockResolver.WIREMOCK_PORT);
}
 
开发者ID:lanwen,项目名称:wiremock-junit5,代码行数:7,代码来源:WiremockUriResolver.java

示例10: getStore

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
private ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getStore(Namespace.create("de.aliceice.paper", getClass().getName()));
}
 
开发者ID:aliceice,项目名称:paper,代码行数:4,代码来源:EnglishLocaleExtension.java

示例11: getStore

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
/**
 * We use custom namespace based on this extension class and test class
 */
private ExtensionContext.Store getStore(ExtensionContext context) {
    return context.getStore(ExtensionContext.Namespace.create(getClass(), context.getRequiredTestClass()));
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:7,代码来源:WeldJunit5Extension.java

示例12: getStore

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
private Store getStore(ExtensionContext context) {
	return context.getStore(Namespace.create(context.getRequiredTestMethod()));
}
 
开发者ID:sbrannen,项目名称:junit5-demo,代码行数:4,代码来源:TimingExtension.java

示例13: getStore

import org.junit.jupiter.api.extension.ExtensionContext; //导入方法依赖的package包/类
/**
 * Creates a {@link Store} for a {@link ExtensionContext} in the context of the given {@code
 * extensionContext}. A {@link Store} is bound to an {@link ExtensionContext} so different test
 * invocations do not share the same store. For example a test invocation on {@code
 * ClassA.testMethodA} will have a different {@link Store} instance to that associated with a test
 * invocation on {@code ClassA.testMethodB} or test invocation on {@code ClassC.testMethodC}.
 *
 * @param extensionContext the <em>context</em> in which the current test or container is being
 *     executed
 * @return a {@link Store} for the given {@code extensionContext}
 */
private Store getStore(ExtensionContext extensionContext) {
  return extensionContext.getStore(namespace(extensionContext));
}
 
开发者ID:glytching,项目名称:junit-extensions,代码行数:15,代码来源:WatcherExtension.java


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