CrossOriginFilterInitializer extends FilterInitializer { static Map<String, String> getFilterParameters(Configuration conf) { Map<String, String> filterParams = new HashMap<String, String>(); for (Map.Entry<String, String> entry : conf.getValByRegex(PREFIX) .entrySet()) { String name = entry.getKey(); String value = entry.getValue(); name = name.substring(PREFIX.length()); filterParams.put(name, value); } return filterParams; }  @Override void initFilter(FilterContainer container, Configuration conf); static final String PREFIX; }
@Test public void testGetFilterParameters() { Configuration conf = new Configuration(); conf.set(CrossOriginFilterInitializer.PREFIX + "rootparam", "rootvalue"); conf.set(CrossOriginFilterInitializer.PREFIX + "nested.param", "nestedvalue"); conf.set("outofscopeparam", "outofscopevalue"); Map<String, String> filterParameters = CrossOriginFilterInitializer.getFilterParameters(conf); String rootvalue = filterParameters.get("rootparam"); String nestedvalue = filterParameters.get("nested.param"); String outofscopeparam = filterParameters.get("outofscopeparam"); Assert.assertEquals("Could not find filter parameter", "rootvalue", rootvalue); Assert.assertEquals("Could not find filter parameter", "nestedvalue", nestedvalue); Assert.assertNull("Found unexpected value in filter parameters", outofscopeparam); }