• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReflectiveCallable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
protected Statement methodBlock(FrameworkMethod method) {
    Object test;
    try {
        test = new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return createTest();
            }
        }.run();
    } catch (Throwable e) {
        return new Fail(e);
    }

    Statement statement = methodInvoker(method, test);
    statement = possiblyExpectingExceptions(method, test, statement);
    statement = withPotentialTimeout(method, test, statement);
    statement = withBefores(method, test, statement);
    statement = withAfters(method, test, statement);
    statement = withRules(method, test, statement);
    return statement;
}
 
开发者ID:easymall,项目名称:easy-test,代码行数:22,代码来源:EasyJUnit4.java


示例2: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
/**
 * Augment the default JUnit behavior
 * {@linkplain #withPotentialRepeat with potential repeats} of the entire
 * execution chain.
 * <p>Furthermore, support for timeouts has been moved down the execution
 * chain in order to include execution of {@link org.junit.Before @Before}
 * and {@link org.junit.After @After} methods within the timed execution.
 * Note that this differs from the default JUnit behavior of executing
 * {@code @Before} and {@code @After} methods in the main thread while
 * executing the actual test method in a separate thread. Thus, the net
 * effect is that {@code @Before} and {@code @After} methods will be
 * executed in the same thread as the test method. As a consequence,
 * JUnit-specified timeouts will work fine in combination with Spring
 * transactions. However, JUnit-specific timeouts still differ from
 * Spring-specific timeouts in that the former execute in a separate
 * thread while the latter simply execute in the main thread (like regular
 * tests).
 * @see #possiblyExpectingExceptions(FrameworkMethod, Object, Statement)
 * @see #withBefores(FrameworkMethod, Object, Statement)
 * @see #withAfters(FrameworkMethod, Object, Statement)
 * @see #withRulesReflectively(FrameworkMethod, Object, Statement)
 * @see #withPotentialRepeat(FrameworkMethod, Object, Statement)
 * @see #withPotentialTimeout(FrameworkMethod, Object, Statement)
 */
@Override
protected Statement methodBlock(FrameworkMethod frameworkMethod) {
	Object testInstance;
	try {
		testInstance = new ReflectiveCallable() {
			@Override
			protected Object runReflectiveCall() throws Throwable {
				return createTest();
			}
		}.run();
	}
	catch (Throwable ex) {
		return new Fail(ex);
	}

	Statement statement = methodInvoker(frameworkMethod, testInstance);
	statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement);
	statement = withBefores(frameworkMethod, testInstance, statement);
	statement = withAfters(frameworkMethod, testInstance, statement);
	statement = withRulesReflectively(frameworkMethod, testInstance, statement);
	statement = withPotentialRepeat(frameworkMethod, testInstance, statement);
	statement = withPotentialTimeout(frameworkMethod, testInstance, statement);
	return statement;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:49,代码来源:SpringJUnit4ClassRunner.java


示例3: buildStatementWithTestRules

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
/**
 * Extends a given {@link Statement} for a {@link TestClass} with the evaluation of
 * {@link TestRule}, {@link ClassRule}, {@link Before} and {@link After}.
 * <p>
 * Therefore the test class will be instantiated and parameters will be injected with the same
 * mechanism as in {@link Parameterized}.
 * 
 * Implementation has been extracted from BlockJUnit4ClassRunner#methodBlock(FrameworkMethod).
 * 
 * @param baseStatementWithChildren - A {@link Statement} that includes execution of the test's
 *        children
 * @param testClass - The {@link TestClass} of the test.
 * @param description - The {@link Description} will be passed to the {@link Rule}s and
 *        {@link ClassRule}s.
 * @param singleParameter - The parameters will be injected in attributes annotated with
 *        {@link Parameterized.Parameter} or passed to the constructor otherwise.
 * 
 * @see BlockJUnit4ClassRunnerWithParameters#createTest()
 * @see BlockJUnit4ClassRunner#methodBlock(FrameworkMethod)
 */
public static Statement buildStatementWithTestRules(Statement baseStatementWithChildren, final TestClass testClass, Description description,
        final Object[] singleParameter) {
    final Object test;
    try {
        test = new ReflectiveCallable() {
            protected Object runReflectiveCall() throws Throwable {
                return createInstanceOfParameterizedTest(testClass, singleParameter);
            }
        }.run();
    } catch (Throwable e) {
        return new Fail(e);
    }

    List<TestRule> testRules = BlockJUnit4ClassRunnerUtil.getTestRules(test, testClass);
    Statement statement = BlockJUnit4ClassRunnerUtil.withTestRules(testRules, description, baseStatementWithChildren);

    statement = ParentRunnerUtil.withBeforeClasses(statement, testClass);
    statement = ParentRunnerUtil.withAfterClasses(statement, testClass);
    statement = ParentRunnerUtil.withClassRules(statement, testClass, description);
    return statement;
}
 
开发者ID:PeterWippermann,项目名称:parameterized-suite,代码行数:42,代码来源:BlockJUnit4ClassRunnerWithParametersUtil.java


示例4: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
/**
 * Augment the default JUnit behavior
 * <p>Furthermore, support for timeouts has been moved down the execution
 * chain in order to include execution of {@link org.junit.Before @Before}
 * and {@link org.junit.After @After} methods within the timed execution.
 * Note that this differs from the default JUnit behavior of executing
 * {@code @Before} and {@code @After} methods in the main thread while
 * executing the actual test method in a separate thread. Thus, the net
 * effect is that {@code @Before} and {@code @After} methods will be
 * executed in the same thread as the test method. As a consequence,
 * JUnit-specified timeouts will work fine in combination with Spring
 * transactions. However, JUnit-specific timeouts still differ from
 * Spring-specific timeouts in that the former execute in a separate
 * thread while the latter simply execute in the main thread (like regular
 * tests).
 *
 * @see #methodInvoker(FrameworkMethod, Object)
 * @see #possiblyExpectingExceptions(FrameworkMethod, Object, Statement)
 * @see #withBefores(FrameworkMethod, Object, Statement)
 * @see #withAfters(FrameworkMethod, Object, Statement)
 * @see #withPotentialTimeout(FrameworkMethod, Object, Statement)
 */
@Override
protected Statement methodBlock(FrameworkMethod frameworkMethod) {
  Object testInstance;
  try {
    testInstance = new ReflectiveCallable() {
      @Override
      protected Object runReflectiveCall() throws Throwable {
        return createTest();
      }
    }.run();
  } catch (Throwable ex) {
    return new Fail(ex);
  }

  Environment.inject(testInstance);

  Statement statement = methodInvoker(frameworkMethod, testInstance);
  statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement);
  statement = withBefores(frameworkMethod, testInstance, statement);
  statement = withAfters(frameworkMethod, testInstance, statement);
  statement = withPotentialTimeout(frameworkMethod, testInstance, statement);
  return statement;
}
 
开发者ID:jspare-projects,项目名称:jspare-container,代码行数:46,代码来源:JspareUnitRunner.java


示例5: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
@Override
protected Statement methodBlock(FrameworkMethod frameworkMethod) {
  testContext = new TestContextImpl(new HashMap<>(classAttributes), null);
  Object testInstance;
  try {
    testInstance = new ReflectiveCallable() {
      @Override
      protected Object runReflectiveCall() throws Throwable {
        return createTest();
      }
    }.run();
  } catch (Throwable ex) {
    return new Fail(ex);
  }

  Environment.inject(testInstance);

  Statement statement = methodInvoker(frameworkMethod, testInstance);
  statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement);
  statement = withBefores(frameworkMethod, testInstance, statement);
  statement = withAfters(frameworkMethod, testInstance, statement);
  statement = withPotentialTimeout(frameworkMethod, testInstance, statement);
  testContext = null;
  return statement;
}
 
开发者ID:jspare-projects,项目名称:vertx-jspare,代码行数:26,代码来源:VertxJspareUnitRunner.java


示例6: makeLink

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
public ParentRunner<?> makeLink(Class<? extends ParentRunner<?>> runnerClass, final Class<?> testClass,
                                final CompositeRunner compositeRunner, final ParentRunner<?> nextRunner,
                                boolean isTestStructureProvider) throws InitializationError {
    ClassPool pool = ClassPool.getDefault();

    String newClassName = runnerClass.getName() + (isTestStructureProvider ? "TestStructureProvider" : "ChainLink");
    final Class<?> newRunnerCtClass = makeLinkClass(pool, newClassName, runnerClass, isTestStructureProvider);

    try {
        return (ParentRunner<?>) new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return newRunnerCtClass.getConstructor(Class.class, CompositeRunner.class, ParentRunner.class)
                    .newInstance(testClass, compositeRunner, nextRunner);
            }
        }.run();
    } catch (InitializationError e) {
        throw e;
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:23,代码来源:RunnerChainLinkFactory.java


示例7: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
protected Statement methodBlock( FuzzUnitTestMethod testMethod )
{
        Object test;
        try {
                test = new ReflectiveCallable()
                {
                        @Override
                        protected Object runReflectiveCall() throws Throwable
                        {
                                return createTest();
                        }
                }.run();
        } catch( Throwable e ) {
                return new Fail( e );
        }

        Statement statement = methodInvoker( testMethod, test );
        statement = withRules( testMethod, test, statement );
        return statement;
}
 
开发者ID:JoeBeeton,项目名称:FuzzUnit,代码行数:21,代码来源:FuzzUnitTestRunner.java


示例8: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
/**
    * method taken as is from BlockJUnit4ClassRunner 4.7 in order to preserve
    * its functionality over following versions
    */
   @Override
   protected Statement methodBlock(FrameworkMethod method) {
Object test;
try {
    test = new ReflectiveCallable() {
	@Override
	protected Object runReflectiveCall() throws Throwable {
	    return createTest();
	}
    }.run();
} catch (Throwable e) {
    return new Fail(e);
}

Statement statement = methodInvoker(method, test);
statement = possiblyExpectingExceptions(method, test, statement);
statement = withPotentialTimeout(method, test, statement);
statement = withRules(method, test, statement);
statement = withBefores(method, test, statement);
statement = withAfters(method, test, statement);
return statement;
   }
 
开发者ID:lucaspouzac,项目名称:contiperf,代码行数:27,代码来源:BlockContiPerfClassRunner.java


示例9: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
@Override
protected Statement methodBlock(final FrameworkMethod method) {
    final Object test;
    try {
        test = new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return createTest();
            }
        }.run();
    } catch (final Throwable e) {
        return new Fail(e);
    }
    Statement statement = new MetaTest.$(method, test);
    statement = withBefores(method, test, statement);
    statement = withAfters(method, test, statement);
    return statement;
}
 
开发者ID:apache,项目名称:tomee,代码行数:19,代码来源:MetaRunner.java


示例10: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
@Override
protected Statement methodBlock(final FrameworkMethod method) {
    final Object test;
    try {
        test = new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return createTest();
            }
        }.run();
    } catch (final Throwable e) {
        return new Fail(e);
    }
    Statement statement = new InvokeMethod(method, test);
    statement = withBefores(method, test, statement);
    statement = withAfters(method, test, statement);
    return statement;
}
 
开发者ID:apache,项目名称:tomee,代码行数:19,代码来源:ValidationRunner.java


示例11: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
/**
 * had to override this whole method to get enough overall control to wrap
 * all method invocations...  javadoc says that this can be overridden
 */
@Override
protected Statement methodBlock(FrameworkMethod method) {
	Object test;
	try {
		test= new ReflectiveCallable() {
			@Override
			protected Object runReflectiveCall() throws Throwable {
				return createTest();
			}
		}.run();
	} catch (Throwable e) {
		return new Fail(e);
	}

	Statement statement= methodInvoker(method, test);
	statement= possiblyExpectingExceptions(method, test, statement);
	statement= withPotentialTimeout(method, test, statement);
	statement= withBefores(method, test, statement);
	statement= withAfters(method, test, statement);
	statement= withRules(method, test, statement);
	return statement;
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:27,代码来源:UnfinalizingTestRunner.java


示例12: invokeExplosively

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
@Override
public Object invokeExplosively(Object target, Object... params) throws Throwable {
    // TODO: ok to ignore parameters here? i guess it depends on the Runner if they are used.
    return new ReflectiveCallable() {
        @Override
        protected Object runReflectiveCall() throws Throwable {
            return nextRunnerRunChild.invoke(nextRunner, wrapped, runNotifier);
        }
    }.run();
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:11,代码来源:FrameworkMethodChainLink.java


示例13: invokeClassBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
public static Statement invokeClassBlock(final ParentRunner<?> nextRunner, final RunNotifier notifier) {
    try {
        return (Statement)new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                Method classBlockMethod = ParentRunner.class.getDeclaredMethod("classBlock", RunNotifier.class);
                classBlockMethod.setAccessible(true);
                return classBlockMethod.invoke(nextRunner, notifier);
            }
        }.run();
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:15,代码来源:RunnerChainLinkFactory.java


示例14: invokeGetChildren

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
public static List invokeGetChildren(final ParentRunner<?> runner) {
    try {
        return (List)new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                Method getChildrenMethod = ParentRunner.class.getDeclaredMethod("getChildren");
                getChildrenMethod.setAccessible(true);
                return getChildrenMethod.invoke(runner);
            }
        }.run();
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:15,代码来源:RunnerChainLinkFactory.java


示例15: invokeDescribeChild

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
public static Description invokeDescribeChild(final ParentRunner<?> runner, final Object child) {
    try {
        return (Description) new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                Method describeChildMethod = ParentRunner.class.getDeclaredMethod("describeChild", Object.class);
                describeChildMethod.setAccessible(true);
                return describeChildMethod.invoke(runner, child);
            }
        }.run();
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:15,代码来源:RunnerChainLinkFactory.java


示例16: evaluate

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
@Override
public void evaluate() throws Throwable {
    final Method runChildrenMethod = ParentRunner.class.getDeclaredMethod("runChildren", RunNotifier.class);
    runChildrenMethod.setAccessible(true);

    new ReflectiveCallable() {
        @Override
        protected Object runReflectiveCall() throws Throwable {
            return runChildrenMethod.invoke(runner, notifier);
        }
    }.run();
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:13,代码来源:RunChildren.java


示例17: invoke

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
public static Object invoke(final Method method, final Object... args) {
    try {
        return new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return method.invoke(currentTestInstance.peek(), args);
            }
        }.run();
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:13,代码来源:TestObjectInstanceContainer.java


示例18: methodBlock

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
private Statement methodBlock(FrameworkMethod method) {
    Object testObject;
    try {
        testObject = new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return getTestClass().getOnlyConstructor().newInstance(new Object[0]);
            }
        }.run();
    } catch (Throwable throwable) {
        return new Fail(throwable);
    }

    return new InvokeMethod(method, testObject);
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:16,代码来源:TestRunner.java


示例19: invokeExplosively

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
/**
 * Returns the result of invoking this method on {@code target} with
 * parameters {@code params}. {@link InvocationTargetException}s thrown are
 * unwrapped, and their causes rethrown.
 */
public Object invokeExplosively(final Object target, final Object... params)
        throws Throwable {
    return new ReflectiveCallable() {
        @Override
        protected Object runReflectiveCall() throws Throwable {
            return fMethod.invoke(target, params);
        }
    }.run();
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:15,代码来源:FrameworkMethod.java


示例20: invokeExplosively

import org.junit.internal.runners.model.ReflectiveCallable; //导入依赖的package包/类
@Override public Object invokeExplosively(final Object target, Object... params)
    throws Throwable {
  checkNotNull(target, "target");

  ReflectiveCallable callable = new ReflectiveCallable() {
    @Override protected Object runReflectiveCall() throws Throwable {
      return getMethod().invoke(target, methodArgs);
    }
  };
  return callable.run();
}
 
开发者ID:square,项目名称:burst,代码行数:12,代码来源:BurstMethod.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java View类代码示例发布时间:2022-05-21
下一篇:
Java Constants类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap