Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext


  }


  @Test
  public void testJavaConfig() {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
    System.out.println((ctx.getBean("theOtherBean")));
  }
View Full Code Here


*/
public class ReproTests {

  @Test
  public void repro() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(ApplicationConfig.class);
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    context.refresh();
    assertNotNull(context.getBean(Foo.class));
    stopWatch.stop();
    System.out.println(stopWatch.prettyPrint());
    context.close();
  }
View Full Code Here

*/
public class ReproTests {

  @Test
  public void works() {
    AnnotationConfigApplicationContext context =
        new AnnotationConfigApplicationContext(Config.class, TestConfiguration.class);
    assertNotNull(context.getBean("myBean"));
    context.close();
  }
View Full Code Here

    context.close();
  }

  @Test
  public void fails() {
    AnnotationConfigApplicationContext context =
        new AnnotationConfigApplicationContext(TestConfiguration.class);
    assertNotNull(context.getBean("myBean"));
    context.close();
  }
View Full Code Here

    context.close();
  }

  @Test
  public void alsoFails() {
    AnnotationConfigApplicationContext context =
        new AnnotationConfigApplicationContext(TestConfiguration.class, Config.class);
    assertNotNull(context.getBean("myBean"));
    context.close();
  }
View Full Code Here

*/
public class ReproTests {

  @Test
  public void repro() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ApplicationConfig.class);
    AnnotationConfigApplicationContext dispatcherCtx = new AnnotationConfigApplicationContext();
    dispatcherCtx.setParent(ctx);
    dispatcherCtx.register(DispatcherConfig.class);
    dispatcherCtx.refresh();

    assertTrue(ctx.containsLocalBean("fooBean"));
    assertFalse(ctx.containsLocalBean("fooController"));

    assertFalse(dispatcherCtx.containsLocalBean("fooBean"));
    assertTrue(dispatcherCtx.containsLocalBean("fooController"));
  }
View Full Code Here

    OptionParser parser = new OptionParser();
    parser.accepts("greeting").withRequiredArg();
    OptionSet options = parser.parse(args);
    PropertySource<?> ps = new JOptCommandLinePropertySource(options);

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.getEnvironment().getPropertySources().addLast(ps);
    ctx.register(Greeter.class);
    ctx.refresh();

    Greeter greeter = ctx.getBean(Greeter.class);
    greeter.sayGreeting();
  }
View Full Code Here

*/
public class ReproTests {

  @Test
  public void repro() throws InterruptedException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(ReproConfig.class);
    ctx.refresh();

    Thread.sleep(10); // allow @Scheduled method to be called several times

    MyRepository repository = ctx.getBean(MyRepository.class);
    assertThat("repository is not a proxy", AopUtils.isAopProxy(repository), is(true));
    assertThat("@Scheduled method never called", repository.getInvocationCount(), greaterThan(0));
  }
View Full Code Here

public class ContextTest {

  @Test
  public void repro() {
    AnnotationConfigApplicationContext ctx =
        new AnnotationConfigApplicationContext();
    ctx.register(FirstDao.class);
    ctx.register(SecondDao.class);
    ctx.register(FirstService.class);
    ctx.register(SecondService.class);
    ctx.refresh();
  }
View Full Code Here

import org.springframework.context.annotation.Bean;

public class ReproTests {
  @Test
  public void repro() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(MyComponent.class);
    ctx.register(MyConfig.class);
    ctx.refresh();
    System.out.println(ctx.getBean(MyComponent.class).beans);
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.annotation.AnnotationConfigApplicationContext

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.