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


Java ReflectionSupport类代码示例

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


ReflectionSupport类属于org.junit.platform.commons.support包,在下文中一共展示了ReflectionSupport类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProcessToDoShouldReplaceSingleValueRangeSubscriptArgumentPlaceholderUsingOnlyNegativeIndices

import org.junit.platform.commons.support.ReflectionSupport; //导入依赖的package包/类
@Test
void testProcessToDoShouldReplaceSingleValueRangeSubscriptArgumentPlaceholderUsingOnlyNegativeIndices() {
    // Given:
    final Method testMethod = ReflectionSupport
            .findMethod(Assertions.class, "assertTrue", new Class<?>[] { boolean.class })
            .orElseThrow(() -> new IllegalStateException("Could not find method"));

    final List<Object> arguments = list('x');


    ReplacementData data = ReplacementData.of(testMethod, 0, arguments);

    // When:
    String result = underTest.process(data, "%na[0]");

    // Then:
    assertThat(result).isEqualTo("arg0=x");
    assertThat(getTestCapturedLog()).containsPattern(
            "WARNING: Parameter names on method '.*' are not available. To store formal parameter names, compile the source file with the '-parameters' option");
}
 
开发者ID:TNG,项目名称:junit-dataprovider,代码行数:21,代码来源:NamedArgumentPlaceholderTest.java

示例2: evaluateExecutionCondition

import org.junit.platform.commons.support.ReflectionSupport; //导入依赖的package包/类
@Override
public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) {
  return context.getElement()
                .flatMap(annotatedElement -> findAnnotation(annotatedElement, DisabledWhen.class))
                .map(DisabledWhen::value)
                .map(supplierClass -> ReflectionSupport.newInstance(supplierClass))
                .map(Supplier::get)
                .map(result -> Objects.requireNonNull(result, "Supplier result must not be null"))
                .map(shouldDisable -> shouldDisable
                    ? disabled(DisabledWhen.class + " evaluated to true")
                    : enabled(DisabledWhen.class + " evaluated to false"))
                .orElse(DEFAULT);
}
 
开发者ID:mkobit,项目名称:junit5-conditional-execution-extensions,代码行数:14,代码来源:DisabledWhenExtension.java

示例3: evaluateExecutionCondition

import org.junit.platform.commons.support.ReflectionSupport; //导入依赖的package包/类
@Override
public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) {
  return context.getElement()
                .flatMap(annotatedElement -> findAnnotation(annotatedElement, EnabledWhen.class))
                .map(EnabledWhen::value)
                .map(supplierClass -> ReflectionSupport.newInstance(supplierClass))
                .map(Supplier::get)
                .map(result -> Objects.requireNonNull(result, "Result must not be null"))
                .map(shouldEnable -> shouldEnable
                    ? enabled(EnabledWhen.class + " evaluated to false")
                    : disabled(EnabledWhen.class + " evaluated to true"))
                .orElse(DEFAULT);
}
 
开发者ID:mkobit,项目名称:junit5-conditional-execution-extensions,代码行数:14,代码来源:EnabledWhenExtension.java

示例4: getConverterContext

import org.junit.platform.commons.support.ReflectionSupport; //导入依赖的package包/类
@Override
protected ConverterContext getConverterContext(CustomConverterDataProvider annotation) {
    return new ConverterContext(ReflectionSupport.newInstance(annotation.objectArrayConverter()),
            ReflectionSupport.newInstance(annotation.singleArgConverter()),
            ReflectionSupport.newInstance(annotation.stringConverter()), annotation.splitBy(),
            annotation.convertNulls(), annotation.trimValues(), annotation.ignoreEnumCase());
}
 
开发者ID:TNG,项目名称:junit-dataprovider,代码行数:8,代码来源:CustomConverterDataProviderArgumentProvider.java

示例5: getConverterContext

import org.junit.platform.commons.support.ReflectionSupport; //导入依赖的package包/类
@Override
protected ConverterContext getConverterContext(DataProvider dataProvider) {
    return new ConverterContext(ReflectionSupport.newInstance(dataProvider.objectArrayConverter()),
            ReflectionSupport.newInstance(dataProvider.singleArgConverter()),
            ReflectionSupport.newInstance(dataProvider.stringConverter()), dataProvider.splitBy(),
            dataProvider.convertNulls(), dataProvider.trimValues(), dataProvider.ignoreEnumCase());
}
 
开发者ID:TNG,项目名称:junit-dataprovider,代码行数:8,代码来源:DataProviderTestProvider.java

示例6: setup

import org.junit.platform.commons.support.ReflectionSupport; //导入依赖的package包/类
@BeforeEach
void setup() {
    tenParamMethod = ReflectionSupport
            .findMethod(getClass(), "tenParamMethod",
                    new Class<?>[] { char.class, int.class, long.class, double.class, String.class, char.class,
                            int.class, long.class, double.class, float.class })
            .orElseThrow(
                    () -> new IllegalStateException("Could not find method having ten parameters for testing."));
}
 
开发者ID:TNG,项目名称:junit-dataprovider,代码行数:10,代码来源:NamedArgumentPlaceholderTest.java


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