HttpCrossOriginFilterInitializer extends FilterInitializer { protected static Map<String, String> getFilterParameters(Configuration conf, String prefix) { 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; static final String ENABLED_SUFFIX; }
@Test public void testGetFilterParameters() { Configuration conf = new Configuration(); conf.set(HttpCrossOriginFilterInitializer.PREFIX + "rootparam", "rootvalue"); conf.set(HttpCrossOriginFilterInitializer.PREFIX + "nested.param", "nestedvalue"); conf.set("outofscopeparam", "outofscopevalue"); Map<String, String> filterParameters = HttpCrossOriginFilterInitializer .getFilterParameters(conf, HttpCrossOriginFilterInitializer.PREFIX); 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); }