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


Java TestContextManager类代码示例

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


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


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