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