@Test public void addInterceptorsWithUrlPatterns() { registry .addInterceptor(interceptor1) .addPathPatterns("/path1/**") .excludePathPatterns("/path1/secret"); registry.addInterceptor(interceptor2).addPathPatterns("/path2"); assertEquals(Arrays.asList(interceptor1), getInterceptorsForPath("/path1")); assertEquals(Arrays.asList(interceptor2), getInterceptorsForPath("/path2")); assertEquals(Collections.emptyList(), getInterceptorsForPath("/path1/secret")); }
@Test public void addInterceptor() { registry.addInterceptor(interceptor1); List<HandlerInterceptor> interceptors = getInterceptorsForPath(null); assertEquals(Arrays.asList(interceptor1), interceptors); }
@Test public void addInterceptorsWithCustomPathMatcher() { PathMatcher pathMatcher = Mockito.mock(PathMatcher.class); registry.addInterceptor(interceptor1).addPathPatterns("/path1/**").pathMatcher(pathMatcher); MappedInterceptor mappedInterceptor = (MappedInterceptor) registry.getInterceptors().get(0); assertSame(pathMatcher, mappedInterceptor.getPathMatcher()); }