@Ignore // TODO: SPR-6327
 @Test
 public void testImportDifferentResourceTypes() {
   AnnotationConfigApplicationContext ctx =
       new AnnotationConfigApplicationContext(SubResourceConfig.class);
   assertTrue(ctx.containsBean("propertiesDeclaredBean"));
   assertTrue(ctx.containsBean("xmlDeclaredBean"));
 }
 @Test
 public void testImportXml() {
   AnnotationConfigApplicationContext ctx =
       new AnnotationConfigApplicationContext(ImportXmlConfig.class);
   assertTrue("did not contain java-declared bean", ctx.containsBean("javaDeclaredBean"));
   assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
   TestBean tb = ctx.getBean("javaDeclaredBean", TestBean.class);
   assertEquals("myName", tb.getName());
 }
 @Test
 public void testImportXmlIsMergedFromSuperclassDeclarations() {
   AnnotationConfigApplicationContext ctx =
       new AnnotationConfigApplicationContext(SecondLevelSubConfig.class);
   assertTrue(
       "failed to pick up second-level-declared XML bean",
       ctx.containsBean("secondLevelXmlDeclaredBean"));
   assertTrue("failed to pick up parent-declared XML bean", ctx.containsBean("xmlDeclaredBean"));
 }
  @Test
  public void testStateEvents() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
    assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
    @SuppressWarnings("unchecked")
    EnumStateMachine<TestStates, TestEvents> machine =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);

    TestStateMachineListener listener = new TestStateMachineListener();
    machine.addStateListener(listener);

    assertThat(machine, notNullValue());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("foo", "jee1").build());
    assertThat(listener.states.size(), is(1));
    assertThat(listener.states.get(0).from.getId(), is(TestStates.S1));
    assertThat(listener.states.get(0).to.getId(), is(TestStates.S2));
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E2).setHeader("foo", "jee2").build());
    assertThat(listener.states.size(), is(2));
    assertThat(listener.states.get(1).from.getId(), is(TestStates.S2));
    assertThat(listener.states.get(1).to.getId(), is(TestStates.S3));
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E4).setHeader("foo", "jee2").build());
    assertThat(listener.states.size(), is(2));

    ctx.close();
  }
 @Test
 public void oneTrueOneFalse() throws Exception {
   AnnotationConfigApplicationContext context =
       load(Config.class, "security.basic.enabled:false", "security.oauth2");
   assertThat(context.containsBean("myBean"), equalTo(false));
   context.close();
 }
 @Test
 public void importWithPlaceHolder() throws Exception {
   AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
   PropertySource<?> propertySource =
       new MapPropertySource(
           "test", Collections.<String, Object>singletonMap("test", "springframework"));
   ctx.getEnvironment().getPropertySources().addFirst(propertySource);
   ctx.register(ImportXmlConfig.class);
   ctx.refresh();
   assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
 }
 @Test
 public void testFilterIsNotRegisteredInNonWeb() throws Exception {
   AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
   context.register(
       SecurityAutoConfiguration.class,
       SecurityFilterAutoConfiguration.class,
       ServerPropertiesAutoConfiguration.class,
       PropertyPlaceholderAutoConfiguration.class);
   try {
     context.refresh();
     assertFalse(context.containsBean("securityFilterChainRegistration"));
   } finally {
     context.close();
   }
 }
 @Test
 public void both() throws Exception {
   AnnotationConfigApplicationContext context = load(Config.class, "a:a", "b:b");
   assertThat(context.containsBean("myBean"), equalTo(true));
   context.close();
 }
 @Test
 public void propertyB() throws Exception {
   AnnotationConfigApplicationContext context = load(Config.class, "b:b");
   assertThat(context.containsBean("myBean"), equalTo(false));
   context.close();
 }
Esempio n. 10
0
 @Test
 public void testImportNonXmlResource() {
   AnnotationConfigApplicationContext ctx =
       new AnnotationConfigApplicationContext(ImportNonXmlResourceConfig.class);
   assertTrue(ctx.containsBean("propertiesDeclaredBean"));
 }
Esempio n. 11
0
 @Test
 public void testImportXmlIsInheritedFromSuperclassDeclarations() {
   AnnotationConfigApplicationContext ctx =
       new AnnotationConfigApplicationContext(FirstLevelSubConfig.class);
   assertTrue(ctx.containsBean("xmlDeclaredBean"));
 }
 @Test
 public void propertySecurityEnabled() throws Exception {
   AnnotationConfigApplicationContext context = load(Config.class, "security.basic.enabled:true");
   assertThat(context.containsBean("myBean"), equalTo(false));
   context.close();
 }