### Question:
ProxyUserService implements FalconService { @Override public void init() throws FalconException { Set<Map.Entry<Object, Object>> entrySet = RuntimeProperties.get().entrySet(); for (Map.Entry<Object, Object> entry : entrySet) { String key = (String) entry.getKey(); if (key.startsWith(CONF_PREFIX) && key.endsWith(GROUPS)) { String proxyUser = key.substring(0, key.lastIndexOf(GROUPS)); if (RuntimeProperties.get().getProperty(proxyUser + HOSTS) == null) { throw new FalconException(proxyUser + HOSTS + " property not set in runtime " + "properties. Please add it."); } proxyUser = proxyUser.substring(CONF_PREFIX.length()); String value = ((String) entry.getValue()).trim(); LOG.info("Loading proxyuser settings [{}]=[{}]", key, value); Set<String> values = null; if (!value.equals("*")) { values = new HashSet<>(Arrays.asList(value.split(","))); } proxyUserGroups.put(proxyUser, values); } if (key.startsWith(CONF_PREFIX) && key.endsWith(HOSTS)) { String proxyUser = key.substring(0, key.lastIndexOf(HOSTS)); if (RuntimeProperties.get().getProperty(proxyUser + GROUPS) == null) { throw new FalconException(proxyUser + GROUPS + " property not set in runtime " + "properties. Please add it."); } proxyUser = proxyUser.substring(CONF_PREFIX.length()); String value = ((String) entry.getValue()).trim(); LOG.info("Loading proxyuser settings [{}]=[{}]", key, value); Set<String> values = null; if (!value.equals("*")) { String[] hosts = value.split(","); for (int i = 0; i < hosts.length; i++) { String hostName = hosts[i]; try { hosts[i] = normalizeHostname(hostName); } catch (Exception ex) { throw new FalconException("Exception normalizing host name: " + hostName + "." + ex.getMessage(), ex); } LOG.info("Hostname, original [{}], normalized [{}]", hostName, hosts[i]); } values = new HashSet<>(Arrays.asList(hosts)); } proxyUserHosts.put(proxyUser, values); } } }  @Override String getName(); @Override void init(); void validate(String proxyUser, String proxyHost, String doAsUser); @Override void destroy(); static final String SERVICE_NAME; }### Answer:
@Test (expectedExceptions = FalconException.class, expectedExceptionsMessageRegExp = ".*falcon.service" + ".ProxyUserService.proxyuser.foo.groups property not set in runtime properties.*") public void testWrongConfigGroups() throws Exception { RuntimeProperties.get().setProperty("falcon.service.ProxyUserService.proxyuser.foo.hosts", "*"); RuntimeProperties.get().remove("falcon.service.ProxyUserService.proxyuser.foo.groups"); proxyUserService.init(); }
@Test (expectedExceptions = FalconException.class, expectedExceptionsMessageRegExp = ".*falcon.service" + ".ProxyUserService.proxyuser.foo.hosts property not set in runtime properties.*") public void testWrongConfigHosts() throws Exception { RuntimeProperties.get().setProperty("falcon.service.ProxyUserService.proxyuser.foo.groups", "*"); RuntimeProperties.get().remove("falcon.service.ProxyUserService.proxyuser.foo.hosts"); proxyUserService.init(); }
@Test (expectedExceptions = FalconException.class, expectedExceptionsMessageRegExp = "Exception normalizing host name.*") public void testWrongHost() throws Exception { RuntimeProperties.get().setProperty("falcon.service.ProxyUserService.proxyuser.foo.hosts", "otherhost"); RuntimeProperties.get().setProperty("falcon.service.ProxyUserService.proxyuser.foo.groups", "*"); proxyUserService.init(); }