chainMap.put(chainOne, new Key[]{key1a, key1b});
chainMap.put(chainTwo, new Key[]{key2a, key2b});
chainMap.put(chainThree, new Key[]{key3a, key3b});
PatternMatcher patternMatcher = ctrl.createMock(PatternMatcher.class);
ServletRequest request = ctrl.createMock(HttpServletRequest.class);
ServletResponse response = ctrl.createMock(HttpServletResponse.class);
FilterChain originalChain = ctrl.createMock(FilterChain.class);
expect(request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)).andReturn("/context");
expect(request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)).andReturn("/mychain");
expect(request.getCharacterEncoding()).andStubReturn(null);
expect(patternMatcher.matches(chainOne, "/mychain")).andReturn(false);
expect(patternMatcher.matches(chainTwo, "/mychain")).andReturn(true);
Filter filter2a = ctrl.createMock(Filter.class);
Filter filter2b = ctrl.createMock(Filter.class);
expect((Filter)injector.getInstance(key2a)).andReturn(filter2a);
filter2a.doFilter(same(request), same(response), anyObject(FilterChain.class));
expect((Filter)injector.getInstance(key2b)).andReturn(filter2b);
filter2b.doFilter(same(request), same(response), anyObject(FilterChain.class));
originalChain.doFilter(request, response);
ctrl.replay();
SimpleFilterChainResolver underTest = new SimpleFilterChainResolver(chainMap, injector, patternMatcher);
FilterChain got = underTest.getChain(request, response, originalChain);
got.doFilter(request, response);
got.doFilter(request, response);
got.doFilter(request, response);
ctrl.verify();
ctrl.reset();
expect(request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)).andReturn("/context");
expect(request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)).andReturn("/nochain");
expect(request.getCharacterEncoding()).andStubReturn(null);
expect(patternMatcher.matches(chainOne, "/nochain")).andReturn(false);
expect(patternMatcher.matches(chainTwo, "/nochain")).andReturn(false);
expect(patternMatcher.matches(chainThree, "/nochain")).andReturn(false);
ctrl.replay();
assertNull("Expected no chain to match, did not get a null value in return.", underTest.getChain(request, response, originalChain));