コード例 #1
0
  @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"));
  }
コード例 #2
0
  @Test
  public void addInterceptor() {
    registry.addInterceptor(interceptor1);
    List<HandlerInterceptor> interceptors = getInterceptorsForPath(null);

    assertEquals(Arrays.asList(interceptor1), interceptors);
  }
コード例 #3
0
  @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());
  }