### Question:
UrlFilter implements Filter { protected boolean checkSelector(RequestPathInfo pathInfo, ValueMap properties) { return check(pathInfo.getSelectorString(), PN_ALLOWED_SELECTORS, PN_ALLOWED_SELECTOR_PATTERN, properties); }  void destroy(); void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); void init(FilterConfig filterConfig);  }### Answer:
@Test public void null_selector() { UrlFilter filter = new UrlFilter(); RequestPathInfo testInfo = mock(RequestPathInfo.class); when(testInfo.getSelectorString()).thenReturn(null); assertTrue(filter.checkSelector(testInfo, null)); }
@Test public void non_null_selector() { UrlFilter filter = new UrlFilter(); RequestPathInfo testInfo = mock(RequestPathInfo.class); when(testInfo.getSelectorString()).thenReturn("sample"); assertTrue(filter.checkSelector(testInfo, properties)); properties.put(UrlFilter.PN_ALLOWED_SELECTORS, (Object) new String[0]); assertFalse(filter.checkSelector(testInfo, properties)); properties.put(UrlFilter.PN_ALLOWED_SELECTORS, (Object) new String[] { "sample", "sample2" }); assertTrue(filter.checkSelector(testInfo, properties)); properties.put(UrlFilter.PN_ALLOWED_SELECTORS, (Object) new String[] { "other" }); assertFalse(filter.checkSelector(testInfo, properties)); properties.clear(); properties.put(UrlFilter.PN_ALLOWED_SELECTOR_PATTERN, "^s[a-z]m.*$"); assertTrue(filter.checkSelector(testInfo, properties)); properties.put(UrlFilter.PN_ALLOWED_SELECTOR_PATTERN, "^s[1-2]m$"); assertFalse(filter.checkSelector(testInfo, properties)); properties.clear(); properties.put(UrlFilter.PN_ALLOWED_SELECTORS, (Object) new String[] { "other" }); properties.put(UrlFilter.PN_ALLOWED_SELECTOR_PATTERN, "^s[a-z]m.*$"); assertTrue(filter.checkSelector(testInfo, properties)); properties.put(UrlFilter.PN_ALLOWED_SELECTORS, (Object) new String[] { "sample" }); properties.put(UrlFilter.PN_ALLOWED_SELECTOR_PATTERN, "^s[a-z]m$"); assertTrue(filter.checkSelector(testInfo, properties)); }