类org.springframework.web.socket.ContextLoaderTestUtils源码实例Demo

下面列出了怎么用org.springframework.web.socket.ContextLoaderTestUtils的API类实例代码及写法,或者点击链接到github查看源代码。

private void setup(Class<?> configurationClass) {
	AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
	applicationContext.register(configurationClass);
	applicationContext.refresh();
	this.applicationContext = applicationContext;
	ContextLoaderTestUtils.setCurrentWebApplicationContext(this.applicationContext);
}
 
@Test
public void cannotFindApplicationContext() throws Exception {
	ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
	WithAutowire encoder = new WithAutowire();
	encoder.init(null);
	assertThatIllegalStateException().isThrownBy(() ->
			encoder.encode(myType))
		.withMessageContaining("Unable to locate the Spring ApplicationContext");
}
 
private void setup(Class<?> configurationClass) {
	AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
	applicationContext.register(configurationClass);
	applicationContext.refresh();
	this.applicationContext = applicationContext;
	ContextLoaderTestUtils.setCurrentWebApplicationContext(this.applicationContext);
}
 
@Test
public void cannotFindApplicationContext() throws Exception {
	ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
	WithAutowire encoder = new WithAutowire();
	encoder.init(null);
	thown.expect(IllegalStateException.class);
	thown.expectMessage("Unable to locate the Spring ApplicationContext");
	encoder.encode(myType);
}
 
private void setup(Class<?> configurationClass) {
	AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
	applicationContext.register(configurationClass);
	applicationContext.refresh();
	this.applicationContext = applicationContext;
	ContextLoaderTestUtils.setCurrentWebApplicationContext(this.applicationContext);
}
 
@Test
public void cannotFindApplicationContext() throws Exception {
	ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
	WithAutowire encoder = new WithAutowire();
	encoder.init(null);
	thown.expect(IllegalStateException.class);
	thown.expectMessage("Unable to locate the Spring ApplicationContext");
	encoder.encode(myType);
}
 
@After
public void teardown() {
	ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
}
 
@After
public void teardown() {
	ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
}
 
@After
public void teardown() {
	ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
}
 
 类方法
 同包方法