@Bean @ConditionalOnMissingBean public WebRequestTraceFilter webRequestLoggingFilter(BeanFactory beanFactory) { WebRequestTraceFilter filter = new WebRequestTraceFilter(this.traceRepository, this.traceProperties); if (this.errorAttributes != null) { filter.setErrorAttributes(this.errorAttributes); } return filter; }
@Test public void configureFilter() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( PropertyPlaceholderAutoConfiguration.class, TraceRepositoryAutoConfiguration.class, TraceWebFilterAutoConfiguration.class); assertThat(context.getBean(WebRequestTraceFilter.class)).isNotNull(); context.close(); }
@Test public void overrideTraceFilter() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( CustomTraceFilterConfig.class, PropertyPlaceholderAutoConfiguration.class, TraceRepositoryAutoConfiguration.class, TraceWebFilterAutoConfiguration.class); WebRequestTraceFilter filter = context.getBean(WebRequestTraceFilter.class); assertThat(filter).isInstanceOf(TestWebRequestTraceFilter.class); context.close(); }
@Bean public WebRequestTraceFilter webRequestLoggingFilter(BeanFactory beanFactory) { WebRequestTraceFilter filter = new WebRequestTraceFilter(this.traceRepository, this.traceProperties); if (this.errorAttributes != null) { filter.setErrorAttributes(this.errorAttributes); } return filter; }
@Bean public WebRequestTraceFilter webRequestLoggingFilter(BeanFactory beanFactory) { WebRequestTraceFilter filter = new WebRequestTraceFilter(this.traceRepository, this.traceProperties); filter.setDumpRequests(this.dumpRequests); if (this.errorAttributes != null) { filter.setErrorAttributes(this.errorAttributes); } return filter; }
@Test public void configureFilter() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( PropertyPlaceholderAutoConfiguration.class, TraceRepositoryAutoConfiguration.class, TraceWebFilterAutoConfiguration.class); assertNotNull(context.getBean(WebRequestTraceFilter.class)); context.close(); }