Package org.springframework.context.event

Examples of org.springframework.context.event.ContextRefreshedEvent


  @Test
  public void testWiringWithBeanTemplate() {
    TestDeclarable declarable = new TestDeclarable();

    declarable.init(createParameters(LazyWiringDeclarableSupport.BEAN_NAME_PARAMETER, "declarableTemplateBean"));
    declarable.onApplicationEvent(new ContextRefreshedEvent(applicationContext));
    declarable.assertInitialized();

    assertNotNull(declarable.getDataSource());
    assertNotNull(declarable.getUser());
    assertEquals("supertool", declarable.getUser().getUsername());
View Full Code Here


    TestDeclarable declarable = new TestDeclarable();

    try {
      declarable.init(createParameters(LazyWiringDeclarableSupport.BEAN_NAME_PARAMETER,
        "nonExistingBeanTemplate"));
      declarable.onApplicationEvent(new ContextRefreshedEvent(applicationContext));
    }
    catch (IllegalArgumentException expected) {
      assertTrue(expected.getMessage().startsWith(
        "No bean with name 'nonExistingBeanTemplate' was found in the Spring context"));
      throw expected;
View Full Code Here

    try {
      testApplicationListener = SpringContextBootstrappingInitializer.register(testApplicationListener);

      assertUnnotified(testApplicationListener);

      ContextRefreshedEvent testContextRefreshedEvent = new ContextRefreshedEvent(mock(ApplicationContext.class,
        "testOnApplicationEvent"));

      new SpringContextBootstrappingInitializer().onApplicationEvent(testContextRefreshedEvent);

      assertNotifiedWithEvent(testApplicationListener, testContextRefreshedEvent);
View Full Code Here

      assertUnnotified(testApplicationListenerOne);
      assertUnnotified(testApplicationListenerTwo);
      assertUnnotified(testApplicationListenerThree);

      ContextRefreshedEvent testContextRefreshedEvent = new ContextRefreshedEvent(mock(ApplicationContext.class,
        "testRegisterWithOnApplicationEvent"));

      new SpringContextBootstrappingInitializer().onApplicationEvent(testContextRefreshedEvent);

      assertNotifiedWithEvent(testApplicationListenerOne, testContextRefreshedEvent);
View Full Code Here

      testApplicationListener = SpringContextBootstrappingInitializer.unregister(
        SpringContextBootstrappingInitializer.register(testApplicationListener));

      assertUnnotified(testApplicationListener);

      ContextRefreshedEvent testContextRefreshedEvent = new ContextRefreshedEvent(mock(ApplicationContext.class,
        "testRegisterThenUnregisterWithOnApplicationEvent"));

      new SpringContextBootstrappingInitializer().onApplicationEvent(testContextRefreshedEvent);

      assertUnnotified(testApplicationListener);
View Full Code Here

    }
  }

  @Test
  public void testNotifyOnExistingContextRefreshedEventAfterContextRefreshed() {
    ContextRefreshedEvent testContextRefreshedEvent = new ContextRefreshedEvent(mock(ApplicationContext.class));

    new SpringContextBootstrappingInitializer().onApplicationEvent(testContextRefreshedEvent);

    TestApplicationListener testApplicationListener = new TestApplicationListener(
      "testNotifyApplicationListenersOnContextRefreshedEventAfterApplicationContextRefreshed");
View Full Code Here

      assertUnnotified(testApplicationListenerOne);
      assertUnnotified(testApplicationListenerTwo);
      assertUnnotified(testApplicationListenerThree);

      ContextRefreshedEvent testContextRefreshedEvent = new ContextRefreshedEvent(mockApplicationContext);

      initializer.onApplicationEvent(testContextRefreshedEvent);

      assertNotifiedWithEvent(testApplicationListenerOne, testContextRefreshedEvent);
      assertUnnotified(testApplicationListenerTwo);
View Full Code Here

    public TestApplicationListener(final String name) {
      this.name = name;
    }

    public ContextRefreshedEvent getActualEvent() {
      ContextRefreshedEvent localActualEvent = this.actualEvent;
      this.actualEvent = null;
      return localActualEvent;
    }
View Full Code Here

      "testOnApplicationEventWithNonConfigurableApplicationContext");

    LazyWiringDeclarableSupport declarable = new TestLazyWiringDeclarableSupport();

    try {
      declarable.onApplicationEvent(new ContextRefreshedEvent(mockApplicationContext));
    }
    catch (IllegalArgumentException expected) {
      assertEquals(String.format("The Spring ApplicationContext (%1$s) must be an instance of ConfigurableApplicationContext.",
        mockApplicationContext.getClass().getName()), expected.getMessage());
      throw expected;
View Full Code Here

    Properties parameters = createParameters("param", "value");

    try {
      declarable.init(parameters);
      declarable.onApplicationEvent(new ContextRefreshedEvent(mockApplicationContext));
      declarable.assertEquals(parameters);
      declarable.assertSame(mockBeanFactory);

      assertTrue(doPostInitCalled.get());
View Full Code Here

TOP

Related Classes of org.springframework.context.event.ContextRefreshedEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.