Example #1
0
        private ScriptBasedMapping CreateMapping(Configuration conf)
        {
            ScriptBasedMapping mapping = new ScriptBasedMapping();

            mapping.SetConf(conf);
            return(mapping);
        }
Example #2
0
        public virtual void TestNullConfig()
        {
            ScriptBasedMapping mapping = CreateMapping(null);

            Assert.True("Expected to be single switch", mapping.IsSingleSwitch
                            ());
        }
Example #3
0
        public virtual void TestNoFilenameMeansSingleSwitch()
        {
            Configuration      conf    = new Configuration();
            ScriptBasedMapping mapping = CreateMapping(conf);

            Assert.True("Expected to be single switch", mapping.IsSingleSwitch
                            ());
            Assert.True("Expected to be single switch", AbstractDNSToSwitchMapping
                        .IsMappingSingleSwitch(mapping));
        }
Example #4
0
        public virtual void TestCachingRelaysStringOperationsToNullScript()
        {
            Configuration      conf          = new Configuration();
            ScriptBasedMapping scriptMapping = new ScriptBasedMapping(conf);

            Assert.True("Did not find " + ScriptBasedMapping.NoScript + " in "
                        + scriptMapping, scriptMapping.ToString().Contains(ScriptBasedMapping.NoScript)
                        );
            CachedDNSToSwitchMapping mapping = new CachedDNSToSwitchMapping(scriptMapping);

            Assert.True("Did not find " + ScriptBasedMapping.NoScript + " in "
                        + mapping, mapping.ToString().Contains(ScriptBasedMapping.NoScript));
        }
Example #5
0
        public virtual void TestFilenameMeansMultiSwitch()
        {
            Configuration conf = new Configuration();

            conf.Set(ScriptBasedMapping.ScriptFilenameKey, "any-filename");
            ScriptBasedMapping mapping = CreateMapping(conf);

            NUnit.Framework.Assert.IsFalse("Expected to be multi switch", mapping.IsSingleSwitch
                                               ());
            mapping.SetConf(new Configuration());
            Assert.True("Expected to be single switch", mapping.IsSingleSwitch
                            ());
        }
Example #6
0
        public virtual void TestCachingRelaysStringOperations()
        {
            Configuration conf       = new Configuration();
            string        scriptname = "mappingscript.sh";

            conf.Set(CommonConfigurationKeys.NetTopologyScriptFileNameKey, scriptname);
            ScriptBasedMapping scriptMapping = new ScriptBasedMapping(conf);

            Assert.True("Did not find " + scriptname + " in " + scriptMapping
                        , scriptMapping.ToString().Contains(scriptname));
            CachedDNSToSwitchMapping mapping = new CachedDNSToSwitchMapping(scriptMapping);

            Assert.True("Did not find " + scriptname + " in " + mapping, mapping
                        .ToString().Contains(scriptname));
        }
Example #7
0
        public virtual void TestNoArgsMeansNoResult()
        {
            Configuration conf = new Configuration();

            conf.SetInt(ScriptBasedMapping.ScriptArgCountKey, ScriptBasedMapping.MinAllowableArgs
                        - 1);
            conf.Set(ScriptBasedMapping.ScriptFilenameKey, "any-filename");
            conf.Set(ScriptBasedMapping.ScriptFilenameKey, "any-filename");
            ScriptBasedMapping mapping = CreateMapping(conf);
            IList <string>     names   = new AList <string>();

            names.AddItem("some.machine.name");
            names.AddItem("other.machine.name");
            IList <string> result = mapping.Resolve(names);

            NUnit.Framework.Assert.IsNull("Expected an empty list", result);
        }