Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext.refresh()


  @Test
  public void annotatedServiceWithoutInterface_PTC_false() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCFalse.class, AnnotatedServiceWithoutInterface.class);
    ctx.refresh();
    AnnotatedServiceWithoutInterface s = ctx.getBean(AnnotatedServiceWithoutInterface.class);
    assertTrue("expected a subclass proxy", AopUtils.isCglibProxy(s));
    assertThat(s, instanceOf(AnnotatedServiceWithoutInterface.class));
  }
View Full Code Here


  @Test
  public void nonAnnotatedService_PTC_true() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCTrue.class, AnnotatedServiceImpl.class);
    ctx.refresh();
    NonAnnotatedService s = ctx.getBean(NonAnnotatedService.class);
    assertTrue("expected a subclass proxy", AopUtils.isCglibProxy(s));
    assertThat(s, instanceOf(AnnotatedServiceImpl.class));
  }
View Full Code Here

  @Test
  public void nonAnnotatedService_PTC_false() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCFalse.class, AnnotatedServiceImpl.class);
    ctx.refresh();
    NonAnnotatedService s = ctx.getBean(NonAnnotatedService.class);
    assertTrue("expected a jdk proxy", AopUtils.isJdkDynamicProxy(s));
    assertThat(s, not(instanceOf(AnnotatedServiceImpl.class)));
  }
View Full Code Here

  @Test
  public void annotatedService_PTC_true() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCTrue.class, NonAnnotatedServiceImpl.class);
    ctx.refresh();
    AnnotatedService s = ctx.getBean(AnnotatedService.class);
    assertTrue("expected a subclass proxy", AopUtils.isCglibProxy(s));
    assertThat(s, instanceOf(NonAnnotatedServiceImpl.class));
  }
View Full Code Here

  @Test
  public void annotatedService_PTC_false() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCFalse.class, NonAnnotatedServiceImpl.class);
    ctx.refresh();
    AnnotatedService s = ctx.getBean(AnnotatedService.class);
    assertTrue("expected a jdk proxy", AopUtils.isJdkDynamicProxy(s));
    assertThat(s, not(instanceOf(NonAnnotatedServiceImpl.class)));
  }
}
View Full Code Here

  @Test
  public void failsWhenJdkProxyAndScheduledMethodNotPresentOnInterface() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, JdkProxyTxConfig.class, RepoConfigA.class);
    try {
      ctx.refresh();
      fail("expected exception");
    }
    catch (BeanCreationException ex) {
      assertTrue(ex.getRootCause().getMessage().startsWith("@Scheduled method 'scheduled' found"));
    }
View Full Code Here

  @Test
  public void succeedsWhenSubclassProxyAndScheduledMethodNotPresentOnInterface() throws InterruptedException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, SubclassProxyTxConfig.class, RepoConfigA.class);
    ctx.refresh();

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

    MyRepository repository = ctx.getBean(MyRepository.class);
    CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
View Full Code Here

  @Test
  public void succeedsWhenJdkProxyAndScheduledMethodIsPresentOnInterface() throws InterruptedException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, JdkProxyTxConfig.class, RepoConfigB.class);
    ctx.refresh();

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

    MyRepositoryWithScheduledMethod repository = ctx.getBean(MyRepositoryWithScheduledMethod.class);
    CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
View Full Code Here

    assertHasStandardEnvironment(ctx);
    ctx.setEnvironment(prodEnv);

    ctx.register(EnvironmentAwareBean.class);
    ctx.refresh();

    assertEnvironmentAwareInvoked(ctx, prodEnv);
  }

  @Test
View Full Code Here

    assertHasStandardEnvironment(ctx);
    ctx.setEnvironment(prodEnv);

    ctx.register(ProdConfig.class);
    ctx.refresh();

    assertThat("should have prod bean", ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

  @Test
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.