@Test
public void testIsAllowed() throws Exception {

    HttpServletRequest mockReq = mock(HttpServletRequest.class);
    when(mockReq.getPathInfo())
        .thenReturn("/localhost/9000/jolokia/")
        .thenReturn("/localhost:8181/jolokia/")
        .thenReturn("/www.myhost.com/jolokia/")
        .thenReturn("/myhost1.com/jolokia/")
        .thenReturn("/myhost22.com/jolokia/")
        .thenReturn("/www.banned.com/jolokia/");
    Set<String> allowlist = new HashSet<>(Arrays.asList("localhost", "www.myhost.com"));
    List<Pattern> regexAllowlist = Collections.singletonList(Pattern.compile("myhost[0-9]+\\.com"));
    ProxyDetails details1 = new ProxyDetails(mockReq);
    ProxyDetails details2 = new ProxyDetails(mockReq);
    ProxyDetails details3 = new ProxyDetails(mockReq);
    ProxyDetails details4 = new ProxyDetails(mockReq);
    ProxyDetails details5 = new ProxyDetails(mockReq);
    ProxyDetails details6 = new ProxyDetails(mockReq);
    assertTrue("localhost/9000", details1.isAllowed(allowlist));
    assertTrue("localhost:8181", details2.isAllowed(allowlist));
    assertTrue("www.myhost.com", details3.isAllowed(allowlist));
    assertTrue("myhost1.com", details4.isAllowed(regexAllowlist));
    assertTrue("myhost22.com", details5.isAllowed(regexAllowlist));
    assertFalse("www.banned.com", details6.isAllowed(allowlist));
}