@Test
public void testProtocolOriginRestrictionFilter() throws Exception {

  ProtocolOriginRestrictionFilter httpOnly = new
      ProtocolOriginRestrictionFilter(Collections.singleton("http"), OriginMatchResults.ALLOW);
  assertTrue(httpOnly.matches(new URL("http://www.example.com/")));
  assertEquals(OriginMatchResults.ALLOW, httpOnly.isAllowed(new URL("http://www.example.com/")));
  assertFalse(httpOnly.matches(new URL("https://www.example.com/")));
  assertEquals(OriginMatchResults.NO_MATCH, httpOnly.isAllowed(new URL("https://www.example.com/")));
  Set<String> protocolSet = new HashSet<>(Arrays.asList("http", "https"));
  ProtocolOriginRestrictionFilter httpAndHttpsDeny = new
      ProtocolOriginRestrictionFilter(protocolSet, OriginMatchResults.DENY);
  assertTrue(httpAndHttpsDeny.matches(new URL("http://www.example.com/")));
  assertEquals(OriginMatchResults.DENY, httpAndHttpsDeny.isAllowed(new URL("http://www.example.com/")));
  assertTrue(httpAndHttpsDeny.matches(new URL("https://www.example.com/")));
  assertEquals(OriginMatchResults.DENY, httpAndHttpsDeny.isAllowed(new URL("https://www.example.com/")));
}