當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。