@Test public void configuresInMemoryTraceRepository() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( TraceRepositoryAutoConfiguration.class); assertThat(context.getBean(InMemoryTraceRepository.class)).isNotNull(); context.close(); }
@Test public void skipsIfRepositoryExists() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( Config.class, TraceRepositoryAutoConfiguration.class); assertThat(context.getBeansOfType(InMemoryTraceRepository.class)).isEmpty(); assertThat(context.getBeansOfType(TraceRepository.class)).hasSize(1); context.close(); }
@Test public void configuresInMemoryTraceRepository() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( TraceRepositoryAutoConfiguration.class); assertNotNull(context.getBean(InMemoryTraceRepository.class)); context.close(); }
@Test public void skipsIfRepositoryExists() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( Config.class, TraceRepositoryAutoConfiguration.class); assertThat(context.getBeansOfType(InMemoryTraceRepository.class).size(), equalTo(0)); assertThat(context.getBeansOfType(TraceRepository.class).size(), equalTo(1)); context.close(); }
@ConditionalOnMissingBean(TraceRepository.class) @Bean public InMemoryTraceRepository traceRepository() { return new InMemoryTraceRepository(); }
@Bean @ConditionalOnMissingBean public TraceEndpoint traceEndpoint() { return new TraceEndpoint(this.traceRepository == null ? new InMemoryTraceRepository() : this.traceRepository); }
@Bean public TraceEndpoint endpoint() { TraceRepository repository = new InMemoryTraceRepository(); repository.add(Collections.<String, Object>singletonMap("a", "b")); return new TraceEndpoint(repository); }