/** * Verify the cached mapper delegates the switch mapping query to the inner mapping, which again * handles arbitrary DNSToSwitchMapping implementations * * @throws Throwable on any problem */ @Test public void testCachingRelaysStringOperationsToNullScript() throws Throwable { Configuration conf = new Configuration(); ScriptBasedMapping scriptMapping = new ScriptBasedMapping(conf); assertTrue( "Did not find " + ScriptBasedMapping.NO_SCRIPT + " in " + scriptMapping, scriptMapping.toString().contains(ScriptBasedMapping.NO_SCRIPT)); CachedDNSToSwitchMapping mapping = new CachedDNSToSwitchMapping(scriptMapping); assertTrue( "Did not find " + ScriptBasedMapping.NO_SCRIPT + " in " + mapping, mapping.toString().contains(ScriptBasedMapping.NO_SCRIPT)); }
/** * Verify the cached mapper delegates the switch mapping query to the inner mapping, which again * handles arbitrary DNSToSwitchMapping implementations * * @throws Throwable on any problem */ @Test public void testCachingRelaysStringOperations() throws Throwable { Configuration conf = new Configuration(); String scriptname = "mappingscript.sh"; conf.set(CommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY, scriptname); ScriptBasedMapping scriptMapping = new ScriptBasedMapping(conf); assertTrue( "Did not find " + scriptname + " in " + scriptMapping, scriptMapping.toString().contains(scriptname)); CachedDNSToSwitchMapping mapping = new CachedDNSToSwitchMapping(scriptMapping); assertTrue( "Did not find " + scriptname + " in " + mapping, mapping.toString().contains(scriptname)); }
public void testNoArgsMeansNoResult() { names = new ArrayList<String>(); names.add("some.machine.name"); names.add("other.machine.name"); List<String> result = mapping.resolve(names); assertNull(result); }
public TestScriptBasedMapping() { mapping = new ScriptBasedMapping(); conf = new Configuration(); conf.setInt(ScriptBasedMapping.SCRIPT_ARG_COUNT_KEY, ScriptBasedMapping.MIN_ALLOWABLE_ARGS - 1); conf.set(ScriptBasedMapping.SCRIPT_FILENAME_KEY, "any-filename"); mapping.setConf(conf); }
/** * {@inheritDoc} * * <p>This will get called in the superclass constructor, so a check is needed to ensure that the * raw mapping is defined before trying to relaying a null configuration. * * @param conf */ @Override public void setConf(Configuration conf) { super.setConf(conf); getRawMapping().setConf(conf); }