public void TestDeRezSceneObject()
        {
            TestHelper.InMethod();
//            log4net.Config.XmlConfigurator.Configure();
                        
            UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
            
            TestScene scene = SceneSetupHelpers.SetupScene();
            IConfigSource configSource = new IniConfigSource();
            IConfig config = configSource.AddConfig("Startup");
            config.Set("serverside_object_permissions", true);
            SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
            TestClient client = SceneSetupHelpers.AddRootAgent(scene, userId);
            
            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
            sogd.Enabled = false;            
            
            SceneObjectPart part
                = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
            part.Name = "obj1";
            scene.AddNewSceneObject(new SceneObjectGroup(part), false);
            List<uint> localIds = new List<uint>();
            localIds.Add(part.LocalId);

            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
            sogd.InventoryDeQueueAndDelete();
            
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
            Assert.That(retrievedPart, Is.Null);
        }
        public void AddKeyValue()
        {
            //<Modification type="add" section="Logging" key="CommonSetting">Value for common setting</Modification>

            IConfigSource ini = new IniConfigSource(Path.Combine(od.FullName,"test.ini"));
            Assert.AreEqual(ini.Configs["Logging"].Get("CommonSetting"), "Value for common setting");
        }
        public void EmptyConstructor()
        {
            string filePath = "EmptyConstructor.ini";
            IniConfigSource source = new IniConfigSource ();

            IConfig config = source.AddConfig ("Pets");
            config.Set ("cat", "Muffy");
            config.Set ("dog", "Rover");
            config.Set ("bird", "Tweety");
            source.Save (filePath);

            Assert.AreEqual (3, config.GetKeys ().Length);
            Assert.AreEqual ("Muffy", config.Get ("cat"));
            Assert.AreEqual ("Rover", config.Get ("dog"));
            Assert.AreEqual ("Tweety", config.Get ("bird"));

            source = new IniConfigSource (filePath);
            config = source.Configs["Pets"];

            Assert.AreEqual (3, config.GetKeys ().Length);
            Assert.AreEqual ("Muffy", config.Get ("cat"));
            Assert.AreEqual ("Rover", config.Get ("dog"));
            Assert.AreEqual ("Tweety", config.Get ("bird"));

            File.Delete (filePath);
        }
        public override void SetUp()
        {
            base.SetUp();

            IConfigSource configSource = new IniConfigSource();
            IConfig jsonStoreConfig = configSource.AddConfig("JsonStore");
            jsonStoreConfig.Set("Enabled", "true");

            m_engine = new MockScriptEngine();
            m_smcm = new ScriptModuleCommsModule();
            JsonStoreModule jsm = new JsonStoreModule();
            m_jssm = new JsonStoreScriptModule();

            m_scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, m_jssm);

            try
            {
                m_smcm.RegisterScriptInvocation(this, "DummyTestMethod");
            }
            catch (ArgumentException)
            {
                Assert.Ignore("Ignoring test since running on .NET 3.5 or earlier.");
            }

            // XXX: Unfortunately, ICommsModule currently has no way of deregistering methods.
        }
Beispiel #5
0
        private static bool _fileExists = false; // does the ini file exists?

        static SettingsManager()
        {
            try
            {
                ConfigFile = string.Format("{0}/{1}", FileHelpers.AssemblyRoot, "config.ini"); // the config file's location.
                Parser = new IniConfigSource(ConfigFile); // see if the file exists by trying to parse it.
                _fileExists = true;
            }
            catch (Exception e)
            {
                Parser = new IniConfigSource(); // initiate a new .ini source.
                _fileExists = false;
                Logger.WarnException(e, "Error loading settings config.ini, will be using default settings. Exception thrown: ");
            }
            finally
            {
                // adds aliases so we can use On and Off directives in ini files.
                Parser.Alias.AddAlias("On", true);
                Parser.Alias.AddAlias("Off", false);

                // logger level aliases.
                Parser.Alias.AddAlias("MinimumLevel", Logger.Level.Trace);
                Parser.Alias.AddAlias("MaximumLevel", Logger.Level.Trace);
            }

            Parser.ExpandKeyValues();
        }
        public void TestAddTemporaryAsset()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
            config.AddConfig("AssetService");
            config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
            config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");

            LocalAssetServicesConnector lasc = new LocalAssetServicesConnector();
            lasc.Initialise(config);

            // If it is remote, it should be stored
            AssetBase a2 = AssetHelpers.CreateNotecardAsset();
            a2.Local = false;
            a2.Temporary = true;

            lasc.Store(a2);

            AssetBase retreivedA2 = lasc.Get(a2.ID);
            Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID));
            Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID));
            Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length));

            AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID);
            Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID));

            byte[] retrievedA2Data = lasc.GetData(a2.ID);
            Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length));

            // TODO: Add cache and check that this does receive a copy of the asset
        }
        static Config()
        {
            var cfg = new IniConfigSource("PetduinoConnect.ini");

            _instance = new Config
            {
                Dweet = new DweetConfig
                {
                    Thing = cfg.Configs["Dweet"].Get("dweet_thing")
                },
                Serial = new SerialConfig
                {
                    Port = cfg.Configs["Serial"].Get("com_port"),
                    BuadRate = cfg.Configs["Serial"].GetInt("com_baud", 9660),
                    DataBits = cfg.Configs["Serial"].GetInt("com_databits", 8),
                    StopBits = cfg.Configs["Serial"].GetStopBits("com_stopbits", StopBits.One),
                    Parity = cfg.Configs["Serial"].GetEnum<Parity>("parity", Parity.None),
                    DtrEnable = cfg.Configs["Serial"].GetBoolean("dtr_enable")
                },
                General = new GeneralConfig
                {
                    Timeout = cfg.Configs["General"].GetInt("timeout", 3000)
                }
            };
        }
        public void TestGoodAssetStoreRequest()
        {
            TestHelpers.InMethod();

            UUID assetId = TestHelpers.ParseTail(0x1);

            IConfigSource config = new IniConfigSource();         
            config.AddConfig("AssetService");           
            config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");

            AssetService assetService = new AssetService(config);

            AssetServerPostHandler asph = new AssetServerPostHandler(assetService);

            AssetBase asset = AssetHelpers.CreateNotecardAsset(assetId, "Hello World");

            MemoryStream buffer = new MemoryStream();

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Encoding = Encoding.UTF8;

            using (XmlWriter writer = XmlWriter.Create(buffer, settings))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(AssetBase));
                serializer.Serialize(writer, asset);
                writer.Flush();
            }            

            buffer.Position = 0;
            asph.Handle(null, buffer, null, null);

            AssetBase retrievedAsset = assetService.Get(assetId.ToString());

            Assert.That(retrievedAsset, Is.Not.Null);
        }
        public void TestSameRegionTeleport()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            EntityTransferModule etm = new EntityTransferModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            // Not strictly necessary since FriendsModule assumes it is the default (!)
            config.Configs["Modules"].Set("EntityTransferModule", etm.Name);

            TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            SceneHelpers.SetupSceneModules(scene, config, etm);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
            sp.AbsolutePosition = new Vector3(30, 31, 32);
            scene.RequestTeleportLocation(
                sp.ControllingClient,
                scene.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
        }
Beispiel #10
0
        private static void LoadMainConfig()
        {
            try
            {
                _mainConfigFile = string.Format("{0}/Conf/{1}", FileHelpers.AssemblyRoot, "default.conf"); // the config file's location.
                _mainConfigParser = new IniConfigSource(_mainConfigFile); // see if the file exists by trying to parse it.
                _mainConfigFileExists = true;
            }
            catch (Exception)
            {
                _mainConfigParser = new IniConfigSource(); // initiate a new .ini source.
                _mainConfigFileExists = false;
                Log.Warning("Error loading settings {0}, will be using default settings.", _mainConfigFile);
            }
            finally
            {
                // adds aliases so we can use On and Off directives in ini files.
                _mainConfigParser.Alias.AddAlias("On", true);
                _mainConfigParser.Alias.AddAlias("Off", false);

                // logger level aliases.
                //Parser.Alias.AddAlias("MinimumLevel", Logger.Level.Trace);
                //Parser.Alias.AddAlias("MaximumLevel", Logger.Level.Trace);

                _mainConfigParser.ExpandKeyValues();
            }
        }
        public static IConfigSource Parse(string rawConfiguration)
        {
            IConfigSource source;

            try
            {
                source = new IniConfigSource(new StringReader(rawConfiguration));
            }
            catch (IniException e)
            {
                throw new ConfigurationException(string.Format("Configuration load failed - {0}", e.Message), e);
            }

            // Check that all the parameters and sections are there.
            try
            {
                IConfig generalConfig = GetConfig(source, GENERAL_SECTION_NAME);
                string rawModelType = generalConfig.GetString(MODEL_TYPE_KEY);

                Enum.Parse(typeof(AbstractGameAssetType), rawModelType, true);
            }
            catch (ArgumentException e)
            {
                throw new ConfigurationException(string.Format("Configuration problem - {0}", e.Message), e);
            }

            return source;
        }
        public static string Get(Type connType)
        {
            string sConn;

            if (conns.TryGetValue(connType, out sConn))
                return sConn;

            Assembly asm = Assembly.GetExecutingAssembly();
            string sType = connType.Name;

            // Note: when running from NUnit, the DLL is located in some temp dir, so how do we get 
            // to the INI file? Ok, so put it into the resources! 
            // string iniName = Path.Combine(Path.GetDirectoryName(asm.Location), "TestDataConnections.ini");

            string[] allres = asm.GetManifestResourceNames();
            string sResFile = Array.Find(allres, s => s.Contains("TestDataConnections.ini"));

            if (String.IsNullOrEmpty(sResFile))
                throw new Exception(String.Format("Please add resource TestDataConnections.ini, with section [TestConnections] and settings like {0}=\"...\"",
                    sType));

            using (Stream resource = asm.GetManifestResourceStream(sResFile))
            {
                IConfigSource source = new IniConfigSource(resource);
                var cfg = source.Configs["TestConnections"];
                sConn = cfg.Get(sType, "");
            }

            if (!String.IsNullOrEmpty(sConn))
                conns[connType] = sConn;

            return sConn;
        }
		public void SetAndSave ()
		{
			string filePath = "Test.ini";

			StreamWriter writer = new StreamWriter (filePath);
			writer.WriteLine ("; some comment");
			writer.WriteLine ("[new section]");
			writer.WriteLine (" dog = Rover");
			writer.WriteLine (""); // empty line
			writer.WriteLine ("; a comment");
			writer.WriteLine (" cat = Muffy");
			writer.Close ();
			
			IniConfigSource source = new IniConfigSource (filePath);
			IConfig config = source.Configs["new section"];
			Assert.AreEqual ("Rover", config.Get ("dog"));
			Assert.AreEqual ("Muffy", config.Get ("cat"));
			
			config.Set ("dog", "Spots");
			config.Set ("cat", "Misha");
			config.Set ("DoesNotExist", "SomeValue");
			
			Assert.AreEqual ("Spots", config.Get ("dog"));
			Assert.AreEqual ("Misha", config.Get ("cat"));
			Assert.AreEqual ("SomeValue", config.Get ("DoesNotExist"));
			source.Save ();
			
			source = new IniConfigSource (filePath);
			config = source.Configs["new section"];
			Assert.AreEqual ("Spots", config.Get ("dog"));
			Assert.AreEqual ("Misha", config.Get ("cat"));
			Assert.AreEqual ("SomeValue", config.Get ("DoesNotExist"));
			
			File.Delete (filePath);
		}
Beispiel #14
0
 internal static void UpdateMooegeIni(Repository repository)
 {
     var repoIniPath = new IniConfigSource(Paths.GetMooegeIniPath(repository));
     //For each selection we set the correct MPQ storage path & PacketLog|ServerLog settings on the config INI, this is the best way I could think to have the paths updated at everytime
     //We CANNOT call variable Compile.mooegeINI because that variable only saves latest compiled ini path for INSTANT writting after compiling a repository.
     //WE do not need to write different IPS / PORTS for this since its LOCAL function, We do that over RepositorySelectionSERVER.
     #region SetSettings
     repoIniPath.Configs["Storage"].Set("MPQRoot", MadCow.MpqServer);
     repoIniPath.Configs["ServerLog"].Set("Enabled", Mooege.FileLogging);
     repoIniPath.Configs["PacketLog"].Set("Enabled", Mooege.PacketLogging);
     repoIniPath.Configs["Storage"].Set("EnableTasks", Mooege.Tasks);
     repoIniPath.Configs["Storage"].Set("LazyLoading", Mooege.LazyLoading);
     repoIniPath.Configs["Authentication"].Set("DisablePasswordChecks", Mooege.PasswordCheck);
     //We set the server variables:
     //MooNet-Server IP
     repoIniPath.Configs["MooNet-Server"].Set("BindIP", MadCow.CurrentProfile.MooNetServerIp);
     //Game-Server IP
     repoIniPath.Configs["Game-Server"].Set("BindIP", MadCow.CurrentProfile.GameServerIp);
     //Public IP
     repoIniPath.Configs["NAT"].Set("PublicIP", MadCow.CurrentProfile.NatIp);
     //MooNet-Server Port
     repoIniPath.Configs["MooNet-Server"].Set("Port", MadCow.CurrentProfile.MooNetServerPort);
     //Game-Server Port
     repoIniPath.Configs["Game-Server"].Set("Port", MadCow.CurrentProfile.GameServerPort);
     //MOTD
     repoIniPath.Configs["MooNet-Server"].Set("MOTD", MadCow.CurrentProfile.MooNetServerMotd);
     //NAT
     repoIniPath.Configs["NAT"].Set("Enabled", MadCow.CurrentProfile.NatEnabled);
     repoIniPath.Save();
     #endregion
     Console.WriteLine("Current Profile: " + MadCow.CurrentProfile);
     Console.WriteLine("Set Mooege config.ini according to your profile " + MadCow.CurrentProfile);
     Console.WriteLine(repository + " is ready to go.");
 }
        public void DeleteKeyValue()
        {
            //<Modification type="delete" section="Logging" key="MessageColumns"/>

            IConfigSource ini = new IniConfigSource(Path.Combine(od.FullName, "test.ini"));
            Assert.AreEqual(ini.Configs["Logging"].Get("MessageColumns"), null);
        }
        /// <summary>
        /// Initialises the somer blink configuration file at path.
        /// </summary>
        /// <param name="path">The path.</param>
        public static void InitialiseSomerBlinkConfigFileAtPath(string path)
        {
            var source = new IniConfigSource();
            source.AddConfig("Credentials");
            source.Configs["Credentials"].Set("Username", "");
            source.Configs["Credentials"].Set("Password", "");

            source.AddConfig("Settings");
            source.Configs["Settings"].Set("MinWaitTime", "2000");
            source.Configs["Settings"].Set("MaxWaitTime", "60000");
            source.Configs["Settings"].Set("MinBlinkBidIsk", "2500000");
            source.Configs["Settings"].Set("MaxBlinkBidIsk", "10000000");
            source.Configs["Settings"].Set("DownTime", "4");
            source.Configs["Settings"].Set("RunTime", "4");

            source.AddConfig("Extra");
            source.Configs["Settings"].Set("DebugMode", "0");
            source.Configs["Settings"].Set("proxyIp", "x.x.x.x");
            source.Configs["Settings"].Set("proxyPort", "8080");
            source.Configs["Settings"].Set("proxyUser", "");
            source.Configs["Settings"].Set("proxyPass", "");
            source.Configs["Settings"].Set("useProxy", "false");

            source.Save(path);

            SaveToDesktop(path);
            Logger.LogMessage();
            Logger.LogMessage("--------------------");
            Logger.LogMessage("ConfigFile shortcut created on desktop");
        }
        public void AddNewConfigsAndKeys()
        {
            // Add some new configs and keys here and test.
            StringWriter writer = new StringWriter ();
            writer.WriteLine ("[Pets]");
            writer.WriteLine (" cat = muffy");
            writer.WriteLine (" dog = rover");
            IniConfigSource source = new IniConfigSource
                                    (new StringReader (writer.ToString ()));

            IConfig config = source.Configs["Pets"];
            Assert.AreEqual ("Pets", config.Name);
            Assert.AreEqual (2, config.GetKeys ().Length);

            IConfig newConfig = source.AddConfig ("NewTest");
            newConfig.Set ("Author", "Brent");
            newConfig.Set ("Birthday", "February 8th");

            newConfig = source.AddConfig ("AnotherNew");

            Assert.AreEqual (3, source.Configs.Count);
            config = source.Configs["NewTest"];
            Assert.IsNotNull (config);
            Assert.AreEqual (2, config.GetKeys ().Length);
            Assert.AreEqual ("February 8th", config.Get ("Birthday"));
            Assert.AreEqual ("Brent", config.Get ("Author"));
        }
Beispiel #18
0
        private static IConfigSource DefaultConfig()
        {
            IConfigSource result = new IniConfigSource();

            {
                IConfig config = result.AddConfig("Config");
                config.Set("listen_port", 8003);
                config.Set("assetset_location", String.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar));
            }

            {
                IConfig config = result.AddConfig("Plugins");
                config.Set("asset_storage_provider", "OpenSimAssetStorage");
                config.Set("inventory_storage_provider", "OpenSimInventoryStorage");
                config.Set("authentication_provider", "NullAuthentication");
                config.Set("authorization_provider", "AuthorizeAll");
                config.Set("metrics_provider", "NullMetrics");
                config.Set("frontends", "ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend");
            }

            {
                IConfig config = result.AddConfig("OpenSim");
                config.Set("asset_database_provider", "OpenSim.Data.MySQL.dll");
                config.Set("inventory_database_provider", "OpenSim.Data.MySQL.dll");
                config.Set("asset_database_connect", String.Empty);
                config.Set("inventory_database_connect", String.Empty);
            }

            return result;
        }
Beispiel #19
0
        private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB)
        {            
            // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the 
            // CapabilitiesModule complain when it can't set up HTTP endpoints.
            //            BaseHttpServer httpServer = new BaseHttpServer(99999);
            //            MainServer.AddHttpServer(httpServer);
            //            MainServer.Instance = httpServer;

            // We need entity transfer modules so that when sp2 logs into the east region, the region calls 
            // EntityTransferModuleto set up a child agent on the west region.
            // XXX: However, this is not an entity transfer so is misleading.
            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Chat");
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule());           
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule());
        }
        public void ConfigCollectionEvents()
        {
            IniConfigSource source = new IniConfigSource ();
            source.Configs.ConfigAdded +=
                            new ConfigEventHandler (this.source_configAdded);
            source.Configs.ConfigRemoved +=
                            new ConfigEventHandler (this.source_configRemoved);

            Assert.AreEqual (configAddedCount, 0);

            eventCollection = null;
            IConfig config = source.AddConfig ("Test");
            Assert.IsTrue (source.Configs == eventCollection);
            Assert.AreEqual (configAddedCount, 1);
            Assert.AreEqual ("Test", eventConfig.Name);

            eventCollection = null;
            config = source.Configs.Add ("Test 2");
            Assert.IsTrue (source.Configs == eventCollection);
            Assert.AreEqual (configAddedCount, 2);
            Assert.AreEqual ("Test 2", eventConfig.Name);

            eventCollection = null;
            source.Configs.RemoveAt (0);
            Assert.IsTrue (source.Configs == eventCollection);
            Assert.AreEqual (configAddedCount, 2);
            Assert.AreEqual ("Test", eventConfig.Name);
        }
        public void IncludeTests()
        {
            const string mainIniFile = "OpenSimDefaults.ini";
            m_config = new IniConfigSource();

            // Create ini files in a directory structure
            IniConfigSource ini;
            IConfig config;

            ini = new IniConfigSource();
            config = ini.AddConfig("IncludeTest");
            config.Set("Include-absolute", "absolute/*/config/*.ini");
            config.Set("Include-relative", "../" + m_testSubdirectory + "/relative/*/config/*.ini");
            CreateIni(mainIniFile, ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute1").Set("name1", "value1");
            CreateIni("absolute/one/config/setting.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute2").Set("name2", 2.3);
            CreateIni("absolute/two/config/setting1.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute2").Set("name3", "value3");
            CreateIni("absolute/two/config/setting2.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative1").Set("name4", "value4");
            CreateIni("relative/one/config/setting.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative2").Set("name5", true);
            CreateIni("relative/two/config/setting1.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative2").Set("name6", 6);
            CreateIni("relative/two/config/setting2.ini", ini);

            // Prepare call to ConfigurationLoader.LoadConfigSettings()
            ConfigurationLoader cl = new ConfigurationLoader();
            IConfigSource argvSource = new IniConfigSource();
            argvSource.AddConfig("Startup").Set("inifile", mainIniFile);
            ConfigSettings configSettings;

            OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, out configSettings);

            // Remove default config
            config = source.Source.Configs["Startup"];
            source.Source.Configs.Remove(config);
            config = source.Source.Configs["Network"];
            source.Source.Configs.Remove(config);

            // Finally, we are able to check the result
            Assert.AreEqual(m_config.ToString(), source.Source.ToString(),
                "Configuration with includes does not contain all settings.");
            // The following would be preferable but fails due to a type mismatch which I am not able to resolve
            //CollectionAssert.AreEquivalent(m_config.Configs, source.Source.Configs,
            //    String.Format("Configuration with includes does not contain all settings.\nAll settings:\n{0}\nSettings read:\n{1}", m_config, source.Source));
        }
        public void Init()
        {
            //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
//            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
            m_xEngine = new XEngine();

            // Necessary to stop serialization complaining
            WorldCommModule wcModule = new WorldCommModule();

            IniConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
            SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);

            m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
            m_scene.StartScripts();
        }
        public void TestDeRezSceneObject()
        {
            TestHelpers.InMethod();
                        
            UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
            
            TestScene scene = new SceneHelpers().SetupScene();
            IConfigSource configSource = new IniConfigSource();
            IConfig config = configSource.AddConfig("Startup");
            config.Set("serverside_object_permissions", true);
            SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() });
            IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
            
            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
            sogd.Enabled = false;            

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", userId);
            uint soLocalId = so.LocalId;

            List<uint> localIds = new List<uint>();
            localIds.Add(so.LocalId);
            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);

            // Check that object isn't deleted until we crank the sogd handle.
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
//            Assert.That(retrievedPart, Is.Not.Null);
//            Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

            sogd.InventoryDeQueueAndDelete();
            
//            SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
            Assert.That(retrievedPart, Is.Null);              
        }
        public void TestCrossOnSameSimulator()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            int sceneObjectIdTail = 0x2;

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);

            SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
            UUID so1Id = so1.UUID;
            so1.AbsolutePosition = new Vector3(128, 10, 20);

            // Cross with a negative value
            so1.AbsolutePosition = new Vector3(128, -10, 20);

            Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
            Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
        }
Beispiel #25
0
        public static void MpqTransfer()
        {
            //Takes Diablo Path from Ini, which gets it from finding diablo3.exe
            if (File.Exists(Program.madcowINI))
            {
                IConfigSource source = new IniConfigSource(Program.madcowINI);
                string Src = source.Configs["DiabloPath"].Get("MPQpath");
                String Dst = source.Configs["DiabloPath"].Get("MPQDest");

                if (ProcessFinder.FindProcess("Diablo") == true)
                {
                    ProcessFinder.KillProcess("Diablo");
                    Console.WriteLine("Killed Diablo3 Process");
                }
                if (Directory.Exists(Dst) == false)
                {
                    Console.WriteLine("Creating MPQ folder...");
                    Directory.CreateDirectory(Dst);
                    Console.WriteLine("Created MPQ folder over:" + Dst);
                }
                //Proceeds to copy data
                Console.WriteLine("Copying MPQ files to MadCow Folders...");
                copyDirectory(Src, Dst);
                //When all the files has been copied then:
                Console.WriteLine("Copying MPQ files to MadCow Folders has completed.");
                Form1.GlobalAccess.Invoke(new Action(() =>
                {
                    Form1.GlobalAccess.CopyMPQButton.Enabled = true;
                    Form1.GlobalAccess.PlayDiabloButton.Enabled = true; //We enable Play D3 button again.
                }));
            }
            else
                Console.WriteLine("MadCow could not find your Diablo III Mpq Folder");
        }
Beispiel #26
0
        private static bool _fileExists = false; // does the ini file exists?

        static ConfigurationManager()
        {
            try
            {
                Parser = new IniConfigSource(ConfigFile); // see if the file exists by trying to parse it.
                _fileExists = true;
            }
            catch (Exception)
            {
                Parser = new IniConfigSource(); // initiate a new .ini source.
                _fileExists = false;
                Logger.Warn("Error loading settings config.ini, will be using default settings.");
            }
            finally
            {
                // adds aliases so we can use On and Off directives in ini files.
                Parser.Alias.AddAlias("On", true); 
                Parser.Alias.AddAlias("Off", false);

                // logger level aliases.
                Parser.Alias.AddAlias("MinimumLevel", Logger.Level.Trace);
                Parser.Alias.AddAlias("MaximumLevel", Logger.Level.Trace);
            }

            Parser.ExpandKeyValues();
        }
Beispiel #27
0
        public override void SetUp()
        {
            base.SetUp();

            uint port = 9999;
            uint sslPort = 9998;

            // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
            // variables and the VM is not restarted between tests.
            MainServer.RemoveHttpServer(port);

            BaseHttpServer server = new BaseHttpServer(port, false, sslPort, "");
            MainServer.AddHttpServer(server);
            MainServer.Instance = server;

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Startup");
            config.Configs["Startup"].Set("EventQueue", "true");

            CapabilitiesModule capsModule = new CapabilitiesModule();
            EventQueueGetModule eqgModule = new EventQueueGetModule();

            m_scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule);
        }
        public void TestShareWithGroup()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();
                        
            UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
            
            TestScene scene = new SceneHelpers().SetupScene();
            IConfigSource configSource = new IniConfigSource();
            
            IConfig startupConfig = configSource.AddConfig("Startup");
            startupConfig.Set("serverside_object_permissions", true);
            
            IConfig groupsConfig = configSource.AddConfig("Groups");            
            groupsConfig.Set("Enabled", true);
            groupsConfig.Set("Module", "GroupsModule");            
            groupsConfig.Set("DebugEnabled", true);            
                       
            SceneHelpers.SetupSceneModules(
                scene, configSource, new object[] 
                   { new PermissionsModule(), 
                     new GroupsModule(), 
                     new MockGroupsServicesConnector() });
            
            IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;            
            
            IGroupsModule groupsModule = scene.RequestModuleInterface<IGroupsModule>();     
            
            groupsModule.CreateGroup(client, "group1", "To boldly go", true, UUID.Zero, 5, true, true, true);
        }
        public void TestCachedUserNameForNewAgent()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            HGUserManagementModule hgumm = new HGUserManagementModule();
            UUID userId = TestHelpers.ParseStem("11");
            string firstName = "Fred";
            string lastName = "Astaire";
            string homeUri = "example.com";

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("UserManagementModule", hgumm.Name);

            SceneHelpers sceneHelpers = new SceneHelpers();
            TestScene scene = sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(scene, config, hgumm);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            acd.firstname = firstName;
            acd.lastname = lastName;
            acd.ServiceURLs["HomeURI"] = "http://" + homeUri;

            SceneHelpers.AddScenePresence(scene, acd);

            string name = hgumm.GetUserName(userId);
            Assert.That(name, Is.EqualTo(string.Format("{0}.{1} @{2}", firstName, lastName, homeUri)));
        }
        private bool saveZigFile()
        {
            bool retVal = false;
            try
            {
                IniConfigSource source = new IniConfigSource();
                string appDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ZigGIS";
                if (!System.IO.Directory.Exists(appDataPath))
                {
                    System.IO.Directory.CreateDirectory(appDataPath);
                }
                IConfig config = source.AddConfig("connection");
                config.Set("server", this.txtServer.Text);
                config.Set("port", this.txtSchema.Text);
                config.Set("database", this.txtDatabase.Text);
                config.Set("user", this.txtUserName.Text);
                config.Set("password", this.txtPassword.Text);

                config = source.AddConfig("logging");
                config.Set("configfile", this.txtLogFile.Text);

                string zigFileName = this.txtServer.Text + "." + this.txtDatabase.Text + "." + this.txtUserName.Text + "." + System.Guid.NewGuid().ToString() + ".zig";
                source.Save(appDataPath + "\\" + zigFileName);
                return retVal;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return false;
            }
        }
Beispiel #31
0
        public NiniDatabase(string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            if (!File.Exists(fileName))
            {
                //TODO Log error
                FileStream fileStream = File.Create(fileName);
                fileStream.Close();
            }

            IniConfigSource iniConfigSoruce = new Nini.Config.IniConfigSource();

            iniConfigSoruce.AutoSave = true;
            iniConfigSoruce.Load(fileName);

            _storage = iniConfigSoruce;
        }
Beispiel #32
0
 /// <include file='IniConfig.xml' path='//Constructor[@name="Constructor"]/docs/*' />
 public IniConfig(string name, IConfigSource source)
     : base(name, source)
 {
     parent = (IniConfigSource)source;
 }