@Test public void fooServiceWithInterface() { this.context = new AnnotationConfigApplicationContext(FooConfig.class); FooService service = this.context.getBean(FooService.class); fooGetSimple(service); }
private void fooGetSimple(FooService service) { Cache cache = getCache(); Object key = new Object(); assertCacheMiss(key, cache); Object value = service.getSimple(key); assertCacheHit(key, value, cache); }
@Test public void beanConditionOff() { this.context = new AnnotationConfigApplicationContext(BeanConditionConfig.class); FooService service = this.context.getBean(FooService.class); Cache cache = getCache(); Object key = new Object(); service.getWithCondition(key); assertCacheMiss(key, cache); service.getWithCondition(key); assertCacheMiss(key, cache); assertEquals(2, this.context.getBean(BeanConditionConfig.Bar.class).count); }
@Test public void beanConditionOn() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.setEnvironment(new MockEnvironment().withProperty("bar.enabled", "true")); ctx.register(BeanConditionConfig.class); ctx.refresh(); this.context = ctx; FooService service = this.context.getBean(FooService.class); Cache cache = getCache(); Object key = new Object(); Object value = service.getWithCondition(key); assertCacheHit(key, value, cache); value = service.getWithCondition(key); assertCacheHit(key, value, cache); assertEquals(2, this.context.getBean(BeanConditionConfig.Bar.class).count); }
@Test public void fooServiceWithInterfaceCglib() { this.context = new AnnotationConfigApplicationContext(FooConfigCglib.class); FooService service = this.context.getBean(FooService.class); fooGetSimple(service); }