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

Java TestContextManager类代码示例

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

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



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

示例1: checkThatExceptionsAreNotSilentlySwallowed

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Test(expected = Exception.class)
public void checkThatExceptionsAreNotSilentlySwallowed() throws Exception {
	SpringJUnit4ClassRunner runner = new SpringJUnit4ClassRunner(getClass()) {

		@Override
		protected TestContextManager createTestContextManager(Class<?> clazz) {
			return new TestContextManager(clazz) {

				@Override
				public void prepareTestInstance(Object testInstance) {
					throw new RuntimeException(
						"This RuntimeException should be caught and wrapped in an Exception.");
				}
			};
		}
	};
	runner.createTest();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:SpringJUnit4ClassRunnerTests.java


示例2: createTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Creates a new {@link TestContextManager} for the supplied test class.
 * <p>
 * Can be overridden by subclasses.
 *
 * @param clazz
 *            the test class to be managed
 */
@Override
protected TestContextManager createTestContextManager(final Class<?> clazz) {
    return new TestContextManager(clazz) {
        @Override
        public void beforeTestClass() throws Exception {
            super.beforeTestClass();
        }

        @Override
        public void afterTestClass() throws Exception {
            // If we aren't caching the Spring context them mark it dirty so
            // it is destroyed.
            if (!cacheSpringContext) {
                final TestContext testContext = getTestContext();
                testContext.markApplicationContextDirty(HierarchyMode.EXHAUSTIVE);
                testContext.setAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE,
                        Boolean.TRUE);
            }

            super.afterTestClass();
        }
    };
}
 
开发者ID:gchq,项目名称:stroom-proxy,代码行数:32,代码来源:StroomSpringJUnit4ClassRunner.java


示例3: checkThatExceptionsAreNotSilentlySwallowed

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Test(expected = Exception.class)
public void checkThatExceptionsAreNotSilentlySwallowed() throws Exception {
	SpringJUnit4ClassRunner runner = new SpringJUnit4ClassRunner(getClass()) {

		@Override
		protected TestContextManager createTestContextManager(Class<?> clazz) {
			return new TestContextManager(clazz) {

				@Override
				public void prepareTestInstance(Object testInstance) {
					throw new RuntimeException("This RuntimeException should be caught and wrapped in an Exception.");
				}
			};
		}
	};
	runner.createTest();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:18,代码来源:SpringJUnit4ClassRunnerTests.java


示例4: setUp

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    testContextManager = new TestContextManager(getClass());
    testContextManager.prepareTestInstance(this);
    
    judgmentsServer.deleteByQuery("*:*");
    judgmentsServer.commit();
    
    indexJudgments();
}
 
开发者ID:CeON,项目名称:saos,代码行数:11,代码来源:JudgmentSearchServiceTest.java


示例5: setUp

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  this.testContextManager = new TestContextManager( getClass() );
  this.testContextManager.prepareTestInstance( this );

  KettleEnvironment.init();
  PentahoSessionHolder.setStrategyName( PentahoSessionHolder.MODE_GLOBAL );

  mockVersionManager();
  removePentahoRootFolder();
  startMicroPlatform();

  createSystemUser();
  createTester();

  createPurRepository();
  loginAsTester();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:PurRepositoryTestBase.java


示例6: withBeforeTestMethodCallbacks

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Wrap the supplied {@link Statement} with a {@code RunBeforeTestMethodCallbacks} statement.
 * @see RunBeforeTestMethodCallbacks
 */
private Statement withBeforeTestMethodCallbacks(Statement statement, FrameworkMethod frameworkMethod,
		Object testInstance, TestContextManager testContextManager) {

	return new RunBeforeTestMethodCallbacks(
			statement, testInstance, frameworkMethod.getMethod(), testContextManager);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:SpringMethodRule.java


示例7: withAfterTestMethodCallbacks

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Wrap the supplied {@link Statement} with a {@code RunAfterTestMethodCallbacks} statement.
 * @see RunAfterTestMethodCallbacks
 */
private Statement withAfterTestMethodCallbacks(Statement statement, FrameworkMethod frameworkMethod,
		Object testInstance, TestContextManager testContextManager) {

	return new RunAfterTestMethodCallbacks(
			statement, testInstance, frameworkMethod.getMethod(), testContextManager);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:SpringMethodRule.java


示例8: createTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Override
protected TestContextManager createTestContextManager(Class<?> clazz) {
	// System.err.println("IntegrationRunner createTestContextManager clazz:" + clazz.getName());
	try {
		TestContextManager manager = super.createTestContextManager(clazz);
		// System.err.println("IntegrationRunner createTestContextManager manager:" + manager);
		return manager;
	}
	catch (RuntimeException e) {
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:14,代码来源:IntegrationRunner.java


示例9: getTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}.
 * @return the {@code TestContextManager} (never {@code null})
 */
private static TestContextManager getTestContextManager(ExtensionContext context) {
	Assert.notNull(context, "ExtensionContext must not be null");
	Class<?> testClass = context.getRequiredTestClass();
	Store store = getStore(context);
	return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class);
}
 
开发者ID:sbrannen,项目名称:spring-test-junit5,代码行数:11,代码来源:SpringExtension.java


示例10: setUp

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    testContextManager = new TestContextManager(getClass());
    testContextManager.prepareTestInstance(this);
    
    solrJudgmentsServer.deleteByQuery("*:*");
    solrJudgmentsServer.commit();
    
    indexJudgments();
}
 
开发者ID:CeON,项目名称:saos,代码行数:11,代码来源:JudgmentSearchServiceQueryParserTest.java


示例11: setUp

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    testContextManager = new TestContextManager(getClass());
    testContextManager.prepareTestInstance(this);
    
    solrJudgmentsServer.deleteByQuery("*:*");
    solrJudgmentsServer.commit();
}
 
开发者ID:CeON,项目名称:saos,代码行数:9,代码来源:JudgmentSearchServiceSortingTest.java


示例12: createTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Called reflectively by {@link #createTest()} to set up the Spring test context manager in the child
 * classloader.
 * 
 * @param testInstance - an instance of the class under test in the current ClassLoader
 * @return a new TestContextManager
 */
public static TestContextManager createTestContextManager(Object testInstance) {
	TestContextManager testContextManager = new TestContextManager(testInstance.getClass());
	try {
		testContextManager.prepareTestInstance(testInstance);
	} catch (Exception e) {
		throw new RuntimeException("Failed setting up Spring test instance", e);
	}
	return testContextManager;
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:17,代码来源:UnfinalizingSpringTestRunner.java


示例13: createTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Called reflectively by {@link #ensureInitialized()} to set up the Spring test context manager in the remote
 * classloader.
 * 
 * @param testInstance - an instance of the class under test in the current ClassLoader
 * @return a new TestContextManager
 */
private static TestContextManager createTestContextManager(Object testInstance) {
	TestContextManager testContextManager = new TestContextManager(testInstance.getClass());
	try {
		testContextManager.prepareTestInstance(testInstance);
	} catch (Exception e) {
		throw new ClassLoaderException("Failed setting up Spring test instance", e);
	}
	return testContextManager;
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:17,代码来源:FunctionalTestClassLoader.java


示例14: clearTestContextCache

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
private final void clearTestContextCache(TestContextManager testContextManager) throws Exception {
  // well this is fun...
  Field contextCacheField = TestContextManager.class.getDeclaredField("contextCache");
  contextCacheField.setAccessible(true);
  Object cache = contextCacheField.get(null);
  Method method = cache.getClass().getDeclaredMethod("clear");
  method.setAccessible(true);
  method.invoke(cache);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:10,代码来源:SpringProcessEngineTestCase.java


示例15: getTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
private static TestContextManager getTestContextManager(ExtensionContext context) {
    Assert.notNull(context, "ExtensionContext must not be null");
    Class<?> testClass = context.getTestClass().get();
    ExtensionContext.Store store = context.getStore(NAMESPACE);
    return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class);
}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:7,代码来源:AutoTestExtension.java


示例16: getTestContextManager

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Get the {@link TestContextManager} associated with this runner.
 */
protected final TestContextManager getTestContextManager() {
	return this.testContextManager;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:SpringJUnit4ClassRunner.java


示例17: apply

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Apply <em>class-level</em> features of the <em>Spring TestContext
 * Framework</em> to the supplied {@code base} statement.
 * <p>Specifically, this method retrieves the {@link TestContextManager}
 * used by this rule and its associated {@link SpringMethodRule} and
 * invokes the {@link TestContextManager#beforeTestClass() beforeTestClass()}
 * and {@link TestContextManager#afterTestClass() afterTestClass()} methods
 * on the {@code TestContextManager}.
 * <p>In addition, this method checks whether the test is enabled in
 * the current execution environment. This prevents classes with a
 * non-matching {@code @IfProfileValue} annotation from running altogether,
 * even skipping the execution of {@code beforeTestClass()} methods
 * in {@code TestExecutionListeners}.
 * @param base the base {@code Statement} that this rule should be applied to
 * @param description a {@code Description} of the current test execution
 * @return a statement that wraps the supplied {@code base} with class-level
 * features of the Spring TestContext Framework
 * @see #getTestContextManager
 * @see #withBeforeTestClassCallbacks
 * @see #withAfterTestClassCallbacks
 * @see #withProfileValueCheck
 * @see #withTestContextManagerCacheEviction
 */
@Override
public Statement apply(Statement base, Description description) {
	Class<?> testClass = description.getTestClass();
	if (logger.isDebugEnabled()) {
		logger.debug("Applying SpringClassRule to test class [" + testClass.getName() + "]");
	}
	validateSpringMethodRuleConfiguration(testClass);
	TestContextManager testContextManager = getTestContextManager(testClass);

	Statement statement = base;
	statement = withBeforeTestClassCallbacks(statement, testContextManager);
	statement = withAfterTestClassCallbacks(statement, testContextManager);
	statement = withProfileValueCheck(statement, testClass);
	statement = withTestContextManagerCacheEviction(statement, testClass);
	return statement;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:SpringClassRule.java


示例18: apply

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Apply <em>instance-level</em> and <em>method-level</em> features of
 * the <em>Spring TestContext Framework</em> to the supplied {@code base}
 * statement.
 * <p>Specifically, this method invokes the
 * {@link TestContextManager#prepareTestInstance prepareTestInstance()},
 * {@link TestContextManager#beforeTestMethod beforeTestMethod()}, and
 * {@link TestContextManager#afterTestMethod afterTestMethod()} methods
 * on the {@code TestContextManager}, potentially with Spring timeouts
 * and repetitions.
 * <p>In addition, this method checks whether the test is enabled in
 * the current execution environment. This prevents methods with a
 * non-matching {@code @IfProfileValue} annotation from running altogether,
 * even skipping the execution of {@code prepareTestInstance()} methods
 * in {@code TestExecutionListeners}.
 * @param base the base {@code Statement} that this rule should be applied to
 * @param frameworkMethod the method which is about to be invoked on the test instance
 * @param testInstance the current test instance
 * @return a statement that wraps the supplied {@code base} with instance-level
 * and method-level features of the Spring TestContext Framework
 * @see #withBeforeTestMethodCallbacks
 * @see #withAfterTestMethodCallbacks
 * @see #withPotentialRepeat
 * @see #withPotentialTimeout
 * @see #withTestInstancePreparation
 * @see #withProfileValueCheck
 */
@Override
public Statement apply(Statement base, FrameworkMethod frameworkMethod, Object testInstance) {
	if (logger.isDebugEnabled()) {
		logger.debug("Applying SpringMethodRule to test method [" + frameworkMethod.getMethod() + "]");
	}
	Class<?> testClass = testInstance.getClass();
	validateSpringClassRuleConfiguration(testClass);
	TestContextManager testContextManager = SpringClassRule.getTestContextManager(testClass);

	Statement statement = base;
	statement = withBeforeTestMethodCallbacks(statement, frameworkMethod, testInstance, testContextManager);
	statement = withAfterTestMethodCallbacks(statement, frameworkMethod, testInstance, testContextManager);
	statement = withTestInstancePreparation(statement, testInstance, testContextManager);
	statement = withPotentialRepeat(statement, frameworkMethod, testInstance);
	statement = withPotentialTimeout(statement, frameworkMethod, testInstance);
	statement = withProfileValueCheck(statement, frameworkMethod, testInstance);
	return statement;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:46,代码来源:SpringMethodRule.java


示例19: withTestInstancePreparation

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
/**
 * Wrap the supplied {@link Statement} with a {@code RunPrepareTestInstanceCallbacks} statement.
 * @see RunPrepareTestInstanceCallbacks
 */
private Statement withTestInstancePreparation(Statement statement, Object testInstance,
		TestContextManager testContextManager) {

	return new RunPrepareTestInstanceCallbacks(statement, testInstance, testContextManager);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:SpringMethodRule.java


示例20: SpringFlowableTestCase

import org.springframework.test.context.TestContextManager; //导入依赖的package包/类
public SpringFlowableTestCase() {
    this.testContextManager = new TestContextManager(getClass());
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:4,代码来源:SpringFlowableTestCase.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java AttributeInstance类代码示例发布时间:2022-05-21
下一篇:
Java IndicesAliasesResponse类代码示例发布时间: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