Package org.springframework.context.annotation

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


  @Test
  public void withAsyncBeanWithExecutorQualifiedByName() throws ExecutionException, InterruptedException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(AsyncWithExecutorQualifiedByNameConfig.class);
    ctx.refresh();

    AsyncBeanWithExecutorQualifiedByName asyncBean = ctx.getBean(AsyncBeanWithExecutorQualifiedByName.class);
    Future<Thread> workerThread0 = asyncBean.work0();
    assertThat(workerThread0.get().getName(), not(anyOf(startsWith("e1-"), startsWith("otherExecutor-"))));
    Future<Thread> workerThread = asyncBean.work();
View Full Code Here


  @Test
  public void asyncProcessorIsOrderedLowestPrecedenceByDefault() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(AsyncConfig.class);
    ctx.refresh();

    AsyncAnnotationBeanPostProcessor bpp = ctx.getBean(AsyncAnnotationBeanPostProcessor.class);
    assertThat(bpp.getOrder(), is(Ordered.LOWEST_PRECEDENCE));
  }
View Full Code Here

  @Test
  public void orderAttributeIsPropagated() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(OrderedAsyncConfig.class);
    ctx.refresh();

    AsyncAnnotationBeanPostProcessor bpp = ctx.getBean(AsyncAnnotationBeanPostProcessor.class);
    assertThat(bpp.getOrder(), is(Ordered.HIGHEST_PRECEDENCE));
  }
View Full Code Here

  @Test
  public void customAsyncAnnotationIsPropagated() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(CustomAsyncAnnotationConfig.class);
    ctx.refresh();

    Object bean = ctx.getBean(CustomAsyncBean.class);
    assertTrue(AopUtils.isAopProxy(bean));
    boolean isAsyncAdvised = false;
    for (Advisor advisor : ((Advised)bean).getAdvisors()) {
View Full Code Here

   */
  @Test(expected=BeanDefinitionStoreException.class)
  public void aspectModeAspectJAttemptsToRegisterAsyncAspect() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(AspectJAsyncAnnotationConfig.class);
    ctx.refresh();
  }


  @Configuration
  @EnableAsync(mode=AdviceMode.ASPECTJ)
View Full Code Here

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

    AsyncBean asyncBean = ctx.getBean(AsyncBean.class);
    asyncBean.work();
    Thread.sleep(500);
    assertThat(asyncBean.getThreadOfExecution().getName(), startsWith("Custom-"));
View Full Code Here

  @Test
  public void repositoryIsClassBasedCacheProxy() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, ProxyTargetClassCachingConfig.class);
    ctx.refresh();

    assertCacheProxying(ctx);
    assertThat(AopUtils.isCglibProxy(ctx.getBean(FooRepository.class)), is(true));
  }
View Full Code Here

  @Test
  public void repositoryUsesAspectJAdviceMode() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, AspectJCacheConfig.class);
    try {
      ctx.refresh();
    }
    catch (Exception ex) {
      // this test is a bit fragile, but gets the job done, proving that an
      // attempt was made to look up the AJ aspect. It's due to classpath issues
      // in .integration-tests that it's not found.
View Full Code Here

  @Test
  public void enclosingConfigFirstParentDefinesBeanWithScanning() {
    AnnotationConfigApplicationContext ctx= new AnnotationConfigApplicationContext();
    context = ctx;
    ctx.scan(AEnclosingConfig.class.getPackage().getName());
    ctx.refresh();
    assertThat(context.getBean("myBean",String.class), equalTo("myBean"));
  }

  @Test
  public void enclosingConfigFirstParentDefinesBeanWithImportResource() {
View Full Code Here


  private ApplicationContext createConfig(Class<?>... configClasses) {
    AnnotationConfigApplicationContext config = new AnnotationConfigApplicationContext();
    config.register(configClasses);
    config.refresh();
    return config;
  }


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