Package org.springframework.context.support

Examples of org.springframework.context.support.StaticApplicationContext.refresh()


    reader.loadBeanDefinitions(CONFIG_LOCATION);
    QualifierAnnotationAutowireCandidateResolver resolver = (QualifierAnnotationAutowireCandidateResolver)
        context.getDefaultListableBeanFactory().getAutowireCandidateResolver();
    resolver.addQualifierType(MultipleAttributeQualifier.class);
    context.registerSingleton("testBean", QualifiedByAttributesTestBean.class);
    context.refresh();
    QualifiedByAttributesTestBean testBean = (QualifiedByAttributesTestBean) context.getBean("testBean");
    Person moeSenior = testBean.getMoeSenior();
    Person moeJunior = testBean.getMoeJunior();
    assertEquals("Moe Sr.", moeSenior.getName());
    assertEquals("Moe Jr.", moeJunior.getName());
View Full Code Here


  public void testResolveMessage() {
    MockRequestContext context = new MockRequestContext();
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.getStaticMessageSource().addMessage("foo", Locale.FRANCE, "bar");
    ac.refresh();
    context.getRootFlow().setApplicationContext(ac);
    context.getMockExternalContext().setLocale(Locale.FRANCE);
    Expression exp = parser.parseExpression("resourceBundle.foo",
        new FluentParserContext().evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
View Full Code Here

  public void testResolveMessage() {
    MockRequestContext context = new MockRequestContext();
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.getStaticMessageSource().addMessage("foo", Locale.FRANCE, "bar");
    ac.refresh();
    context.getRootFlow().setApplicationContext(ac);
    context.getMockExternalContext().setLocale(Locale.FRANCE);
    Expression exp = parser.parseExpression("resourceBundle.foo",
        new FluentParserContext().evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
View Full Code Here

    StaticApplicationContext applicationContext = new StaticApplicationContext();
    StaticMessageSource messageSource = applicationContext.getStaticMessageSource();
    messageSource.addMessage("myCode", externalContext.getLocale(), "myCode message");
    messageSource.addMessage("myCode.myCode", externalContext.getLocale(), "myCode myCode message");
    applicationContext.refresh();

    Flow flow = (Flow) requestContext.getActiveFlow();
    flow.setApplicationContext(applicationContext);

    String expressionString = "#{resourceBundle.myCode}";
View Full Code Here

    @Test
    public void testAppListenerCalled() {
        StaticApplicationContext ctx = new StaticApplicationContext();
        ctx.registerSingleton("myListener", MyApplicationListener.class);
        ctx.registerSingleton("myListenerAndRepo", MyApplicationListenerAndRepository.class);
        ctx.refresh();

        MyApplicationListener listener = ctx.getBean(MyApplicationListener.class);
        MyApplicationListenerAndRepository listenerAndRepo = ctx.getBean(MyApplicationListenerAndRepository.class);

        MyEvent event = new MyEvent("fubar");
View Full Code Here

        StaticApplicationContext ctx = new StaticApplicationContext();
        MyApplicationListener delegate = new MyApplicationListener();
        MyEventSource source = new MyEventSource();
        MyEvent event = new MyEvent(source);
        ctx.addApplicationListener(new SourceFilteringListener(source, delegate));
        ctx.refresh();
        ctx.publishEvent(event);

        assertSame("Mismatched delegate event", event, delegate.getLastEvent());

        List<Operation> opsList = ((OperationListCollector) spiedOperationCollector).getCollectedOperations();
View Full Code Here

    return services;
  }

  private static StaticApplicationContext createTestApplicationContext() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    return context;
  }

}
View Full Code Here

        if (appContext == null) {
            mother.set(instance);

            StaticApplicationContext parent = new StaticApplicationContext();
            parent.registerSingleton("stepMother", StepMotherFactory.class);
            parent.refresh();

            String springXml = System.getProperty("cuke4duke.springXml", "cucumber.xml");
            appContext = new ClassPathXmlApplicationContext(new String[]{springXml}, parent);
            if (mother.get() != null) {
                throw new IllegalStateException("Expected ObjectMotherFactory to snatch up the thread local. Concurrent runs?");
View Full Code Here

    sac.getDefaultListableBeanFactory().registerBeanDefinition("singletonToBeProxied", bd);

    sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);
    sac.registerSingleton("autowiredIndexedTestBean", IndexedTestBean.class);

    sac.refresh();

    MessageSource messageSource = (MessageSource) sac.getBean("messageSource");
    ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied");
    assertFalse(Proxy.isProxyClass(messageSource.getClass()));
    assertTrue(Proxy.isProxyClass(singletonToBeProxied.getClass()));
View Full Code Here

    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
    sac.getDefaultListableBeanFactory().registerBeanDefinition("singletonToBeProxied", bd);

    sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);

    sac.refresh();

    ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied");
    assertTrue(Proxy.isProxyClass(singletonToBeProxied.getClass()));

    TestInterceptor ti = (TestInterceptor) sac.getBean("testInterceptor");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.