代码拉取完成,页面将自动刷新
package me.chanjar.configuration.ex3;
import me.chanjar.configuration.service.Foo;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
public class FooConfigurationTest {
private AnnotationConfigApplicationContext context;
@BeforeMethod
public void init() {
context = new AnnotationConfigApplicationContext();
}
@AfterMethod(alwaysRun = true)
public void reset() {
context.close();
}
@Test(expectedExceptions = NoSuchBeanDefinitionException.class)
public void testFooCreatePropertyNull() {
context.register(FooConfiguration.class);
context.refresh();
context.getBean(Foo.class);
}
@Test
public void testFooCreatePropertyTrue() {
EnvironmentTestUtils.addEnvironment(context, "foo.create=true");
context.register(FooConfiguration.class);
context.refresh();
assertNotNull(context.getBean(Foo.class));
}
@Test(expectedExceptions = NoSuchBeanDefinitionException.class)
public void testFooCreatePropertyFalse() {
EnvironmentTestUtils.addEnvironment(context, "foo.create=false");
context.register(FooConfiguration.class);
context.refresh();
assertNotNull(context.getBean(Foo.class));
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。