本文整理汇总了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");
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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."));
}