Package org.springframework.context.support

Examples of org.springframework.context.support.StaticApplicationContext


public class SpringRegistryTestCase extends AbstractRegistryTestCase
{
    @Override
    public Registry getRegistry()
    {
        return new SpringRegistry(new StaticApplicationContext(), muleContext);
    }
View Full Code Here


    public void onSetUp() throws Exception {
        this.proxyController = new ProxyController();
        this.proxyController
            .setCentralAuthenticationService(getCentralAuthenticationService());

        StaticApplicationContext context = new StaticApplicationContext();
        context.refresh();
        this.proxyController.setApplicationContext(context);
    }
View Full Code Here

   
    private ServiceValidateController serviceValidateController;

    @Before
    public void onSetUp() throws Exception {
        StaticApplicationContext context = new StaticApplicationContext();
        context.refresh();
        this.serviceValidateController = new ServiceValidateController();
        this.serviceValidateController
            .setCentralAuthenticationService(getCentralAuthenticationService());
        final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler();
        proxyHandler.setHttpClient(new HttpClient());
View Full Code Here

* @author Juergen Hoeller
*/
public class LifecycleEventTests extends TestCase {

  public void testContextStartedEvent() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.registerSingleton("lifecycle", LifecycleTestBean.class);
    context.registerSingleton("listener", LifecycleListener.class);
    context.refresh();
    LifecycleTestBean lifecycleBean = (LifecycleTestBean) context.getBean("lifecycle");
    LifecycleListener listener = (LifecycleListener) context.getBean("listener");
    assertFalse(lifecycleBean.isRunning());
    assertEquals(0, listener.getStartedCount());
    context.start();
    assertTrue(lifecycleBean.isRunning());
    assertEquals(1, listener.getStartedCount());
    assertSame(context, listener.getApplicationContext());
  }
View Full Code Here

    assertEquals(1, listener.getStartedCount());
    assertSame(context, listener.getApplicationContext());
  }

  public void testContextStoppedEvent() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.registerSingleton("lifecycle", LifecycleTestBean.class);
    context.registerSingleton("listener", LifecycleListener.class);
    context.refresh();
    LifecycleTestBean lifecycleBean = (LifecycleTestBean) context.getBean("lifecycle");
    LifecycleListener listener = (LifecycleListener) context.getBean("listener");
    assertFalse(lifecycleBean.isRunning());
    context.start();
    assertTrue(lifecycleBean.isRunning());
    assertEquals(0, listener.getStoppedCount());   
    context.stop();
    assertFalse(lifecycleBean.isRunning());
    assertEquals(1, listener.getStoppedCount());
    assertSame(context, listener.getApplicationContext());
  }
View Full Code Here

  public void testWithNoApplicationEventClassSupplied() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.afterPropertiesSet();
      }
    }.runTest();
  }
View Full Code Here

  public void testWithNonApplicationEventClassSupplied() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.setApplicationEventClass(getClass());
        interceptor.afterPropertiesSet();
      }
    }.runTest();
View Full Code Here

  public void testWithAbstractStraightApplicationEventClassSupplied() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.setApplicationEventClass(ApplicationEvent.class);
        interceptor.afterPropertiesSet();
      }
    }.runTest();
View Full Code Here

  public void testWithApplicationEventClassThatDoesntExposeAValidCtor() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
        ApplicationContext ctx = new StaticApplicationContext();
        interceptor.setApplicationEventPublisher(ctx);
        interceptor.setApplicationEventClass(TestEventWithNoValidOneArgObjectCtor.class);
        interceptor.afterPropertiesSet();
      }
    }.runTest();
View Full Code Here

      protected void onRefresh() throws BeansException {
        addListener(listener);
      }
    }

    StaticApplicationContext ctx = new TestContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("applicationEventClass", TestEvent.class.getName());
    // should automatically receive applicationEventPublisher reference
    ctx.registerSingleton("publisher", EventPublicationInterceptor.class, pvs);
    ctx.registerSingleton("otherListener", FactoryBeanTestListener.class);
    ctx.refresh();

    EventPublicationInterceptor interceptor =
        (EventPublicationInterceptor) ctx.getBean("publisher");
    ProxyFactory factory = new ProxyFactory(target);
    factory.addAdvice(0, interceptor);

    ITestBean testBean = (ITestBean) factory.getProxy();

    // invoke any method on the advised proxy to see if the interceptor has been invoked
    testBean.getAge();

    // two events: ContextRefreshedEvent and TestEvent
    assertTrue("Interceptor must have published 2 events", listener.getEventCount() == 2);
    TestListener otherListener = (TestListener) ctx.getBean("&otherListener");
    assertTrue("Interceptor must have published 2 events", otherListener.getEventCount() == 2);
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.support.StaticApplicationContext

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.