下面列出了org.springframework.context.annotation.role.ComponentWithRole#org.springframework.context.annotation.role.ComponentWithoutRole 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void onComponentClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ComponentWithoutRole.class, ComponentWithRole.class);
ctx.refresh();
assertThat("Expected bean to have ROLE_APPLICATION",
ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION));
assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null));
assertThat("Expected bean to have ROLE_INFRASTRUCTURE",
ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE));
assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role"));
}
@Test
public void onComponentClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ComponentWithoutRole.class, ComponentWithRole.class);
ctx.refresh();
assertThat("Expected bean to have ROLE_APPLICATION",
ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION));
assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null));
assertThat("Expected bean to have ROLE_INFRASTRUCTURE",
ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE));
assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role"));
}
@Test
public void onComponentClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ComponentWithoutRole.class, ComponentWithRole.class);
ctx.refresh();
assertThat("Expected bean to have ROLE_APPLICATION",
ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION));
assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null));
assertThat("Expected bean to have ROLE_INFRASTRUCTURE",
ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE));
assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role"));
}