Beispiel #1
0
        public void ClientConfigurationSaveTest()
        {
            DbHandler _dbh = new DbHandler();

            // Eliminar archivo de datos serializados creado en prueba anteriores
            if (System.IO.File.Exists(_dbh.DbName))
            {
                System.IO.File.Delete(_dbh.DbName);
            }

            _dbh.Start();

            ClientDataManager cdm = _dbh.DbRoot.ClientManager;

            string id        = "ER$%^667";
            string name      = "TestClt";
            string appPath   = "TestClt\\qewqew \\qwerq\\qwer";
            string logPath   = "TestClt\\245\\vfd erw5\\wregerw";
            int    timeout   = 345;
            int    port      = 0;
            bool   mail      = false;
            bool   logAttach = true;
            int    queueSize = 56;

            ClientData client = cdm.CreateClient(ClientIdType.KeyByIdString,
                                                 id,
                                                 port,
                                                 name,
                                                 appPath,
                                                 logPath,
                                                 timeout,
                                                 mail,
                                                 logAttach,
                                                 queueSize);

            _dbh.Stop();
            _dbh.Start();

            Assert.IsNotNull(_dbh.DbRoot);
            cdm = _dbh.DbRoot.ClientManager;

            Assert.AreEqual(1, cdm.Count);

            client = cdm.GetClient(id);

            Assert.AreEqual(port, client.Port);
            Assert.AreEqual(name, client.Name);
            Assert.AreEqual(appPath, client.AppFilePath);
            Assert.AreEqual(logPath, client.LogFilePath);
            Assert.AreEqual(timeout, client.Timeout);
            Assert.AreEqual(mail, client.MailEnabled);
            Assert.AreEqual(logAttach, client.LogAttachEnabled);
            Assert.AreEqual(queueSize, client.QueueSize);
        }
Beispiel #2
0
        public void ClientKeyIdCreation()
        {
            string id        = "ER$%^667";
            string name      = "TestClt";
            string appPath   = "TestClt\\qewqew \\qwerq\\qwer";
            string logPath   = "TestClt\\245\\vfd erw5\\wregerw";
            int    timeout   = 345;
            int    port      = 0;
            bool   mail      = false;
            bool   logAttach = true;
            int    queueSize = 56;

            ClientDataManager cdm = new ClientDataManager();

            Assert.IsFalse(cdm.ContainsId(id));
            Assert.IsFalse(cdm.ContainsName(name));

            ClientData clt = cdm.CreateClient(ClientIdType.KeyByIdString,
                                              id,
                                              port,
                                              name,
                                              appPath,
                                              logPath,
                                              timeout,
                                              mail,
                                              logAttach,
                                              queueSize);

            Assert.IsTrue(cdm.ContainsId(id));
            Assert.IsFalse(cdm.ContainsPort(port));
            Assert.IsTrue(cdm.ContainsName(name));
            Assert.AreEqual(id, clt.Id);
            Assert.AreEqual(name, clt.Name);
            Assert.AreEqual(appPath, clt.AppFilePath);
            Assert.AreEqual(logPath, clt.LogFilePath);
            Assert.AreEqual(timeout, clt.Timeout);
            Assert.AreEqual(mail, clt.MailEnabled);
            Assert.AreEqual(logAttach, clt.LogAttachEnabled);
            Assert.AreEqual(queueSize, clt.QueueSize);

            ClientData newclt = cdm.GetClient(id);

            Assert.AreEqual(clt, newclt);

            Assert.AreEqual(1, cdm.List.Length);
            cdm.Delete(newclt.ClientId);
            Assert.AreEqual(0, cdm.List.Length);
        }
        /// <summary>
        /// Crea configuracion de prueba para los tests.
        /// Configuracion de cliente
        /// </summary>
        private ClientDataManager CreateClientConfig()
        {
            ClientDataManager cdm = new ClientDataManager();

            ClientData client;

            client = cdm.CreateClient(ClientIdType.KeyByIdString,
                                      Client1_ID,
                                      0,
                                      Client1_Name,
                                      "c:\\Tmp\\ClientUdp\\wcudp1.exe",
                                      "c:\\Tmp\\ClientUdp\\wcudp1.txt",
                                      55, true, false, 12);

            // salvar ref a Guid
            Client1_Guid = client.ClientId;


            return(cdm);
        }
Beispiel #4
0
        internal void CreateTestConfig()
        {
            ClientDataManager cdm = new ClientDataManager();

            /*
             * Cliente con clave Id, puerto automatico
             *
             * client.Name = "WinClt01";
             * client.Id = "WC0001";
             * client.AppFilePath = "c:\\Tmp\\ClientUdp\\wcudp1.exe";
             * client.LogFilePath = "c:\\Tmp\\ClientUdp\\wcudp1.txt";
             * client.MailEnabled = true;
             * client.Timeout = 55;
             * client.Port = 0;
             * client.QueueSize = 12;
             */
            cdm.CreateClient(ClientIdType.KeyByIdString,
                             "WC0001",
                             0,
                             "WinClt01",
                             "c:\\Tmp\\ClientUdp\\wcudp1.exe",
                             "c:\\Tmp\\ClientUdp\\wcudp1.txt",
                             55, true, false, 12);

            /*
             * Cliente con clave Port, puerto 50100
             *
             * client = new ClientData();
             * client.Name = "WinClt02";
             * client.Id = "WC0002";
             * client.AppFilePath = "c:\\Tmp\\ClientUdp\\wcudp2.exe";
             * client.LogFilePath = "c:\\Tmp\\ClientUdp\\wcudp2.txt";
             * client.MailEnabled = true;
             * client.LogAttachEnabled = false;
             * client.Timeout = 65;
             * client.Port = 50100;
             * client.QueueSize = 24;
             */
            cdm.CreateClient(ClientIdType.KeyByUdpPort,
                             null,
                             50100,
                             "WinClt02",
                             "c:\\Tmp\\ClientUdp\\wcudp2.exe",
                             "c:\\Tmp\\ClientUdp\\wcudp2.txt",
                             65, true, false, 24);
            //// ... and again

            //client = new ClientData();
            //client.Name = "CConsole1";
            //client.Id = HeartBeat.DefaultClientID;
            //client.AppFilePath = "c:\\Tmp\\ClientUdp\\cudp.cmd";
            //client.LogFilePath = "c:\\Tmp\\ClientUdp\\cudp.txt";
            //client.MailEnabled = false;
            //client.LogAttachEnabled = false;
            //client.Timeout = 70;
            //client.Port = 50200;
            //client.QueueSize = 48;

            cdm.CreateClient(ClientIdType.KeyByUdpPort,
                             null,
                             50200,
                             "CConsole1",
                             "c:\\Tmp\\ClientUdp\\cudp.cmd",
                             "c:\\Tmp\\ClientUdp\\cudp.txt",
                             70, false, false, 48);

            // config system
            SystemConfigData tmpSys = new SystemConfigData();

            tmpSys.ServerIpAdr    = "127.0.0.1";
            tmpSys.UdpServerPort  = 8888;
            tmpSys.ZyanServerName = Constants.ZyanServerName;
            tmpSys.ZyanServerPort = Constants.ZyanServerPort;
            tmpSys.SMtpServer     = "localhost";

            tmpSys.Source              = "*****@*****.**";
            tmpSys.Password            = "******";
            tmpSys.Destination         = "[email protected], [email protected]";
            tmpSys.TimeoutStartRestart = 180;
            tmpSys.RestartAttemps      = 2;

            SystemPlusClientData tmpDb = new SystemPlusClientData(cdm, tmpSys);

            _dbRoot = tmpDb;

            CommitDatabase();
        }
Beispiel #5
0
        public void ConfigurationImportExportTest()
        {
            DbHandler _dbh = new DbHandler();

            // Eliminar archivo de datos serializados creado en prueba anteriores
            if (System.IO.File.Exists(_dbh.DbName))
            {
                System.IO.File.Delete(_dbh.DbName);
            }

            string cfgFile = "impexptest.bsr";

            _dbh.Start();

            // System config.
            SystemConfigData _sysCfgData = _dbh.DbRoot.SystemConfig;

            int    expectedPort       = 8888;
            string expectedSMTPserver = "localhost";
            string expectedSource     = "*****@*****.**";
            string expectedPwd        = "monitor";
            int    expectedTimeout    = 3;

            _sysCfgData.UdpServerPort       = expectedPort;
            _sysCfgData.ZyanServerName      = Constants.ZyanServerName;
            _sysCfgData.SMtpServer          = expectedSMTPserver;
            _sysCfgData.Source              = expectedSource;
            _sysCfgData.Password            = expectedPwd;
            _sysCfgData.TimeoutStartRestart = expectedTimeout;

            // Client config.
            ClientDataManager cdm = _dbh.DbRoot.ClientManager;

            string id        = "ER$%^667";
            string name      = "TestClt";
            string appPath   = "TestClt\\qewqew \\qwerq\\qwer";
            string logPath   = "TestClt\\245\\vfd erw5\\wregerw";
            int    timeout   = 345;
            int    port      = 0;
            bool   mail      = false;
            bool   logAttach = true;
            int    queueSize = 56;

            ClientData client = cdm.CreateClient(ClientIdType.KeyByIdString,
                                                 id,
                                                 port,
                                                 name,
                                                 appPath,
                                                 logPath,
                                                 timeout,
                                                 mail,
                                                 logAttach,
                                                 queueSize);

            // export
            _dbh.ExportCfg(cfgFile);

            _dbh.Stop();
            // borrar salva de config creada al detener componente
            if (System.IO.File.Exists(_dbh.DbName))
            {
                System.IO.File.Delete(_dbh.DbName);
            }

            // se crea config por defecto al abrir
            _dbh.Start();

            Assert.IsNotNull(_dbh.DbRoot);
            Assert.IsNotNull(_dbh.DbRoot.ClientManager);
            Assert.IsNotNull(_dbh.DbRoot.SystemConfig);
            // Sin clientes
            Assert.AreEqual(0, _dbh.DbRoot.ClientManager.Count);

            // import
            _dbh.ImportCfg(cfgFile);

            Assert.IsNotNull(_dbh.DbRoot);
            Assert.IsNotNull(_dbh.DbRoot.ClientManager);
            Assert.IsNotNull(_dbh.DbRoot.SystemConfig);

            // Comprobaciones
            // System
            _sysCfgData = _dbh.DbRoot.SystemConfig;

            Assert.AreEqual(expectedPort, _sysCfgData.UdpServerPort);
            Assert.AreEqual(Constants.ZyanServerName, _sysCfgData.ZyanServerName);
            Assert.AreEqual(expectedSMTPserver, _sysCfgData.SMtpServer);
            Assert.AreEqual(expectedSource, _sysCfgData.Source);
            Assert.AreEqual(expectedPwd, _sysCfgData.Password);
            Assert.AreEqual(expectedTimeout, _sysCfgData.TimeoutStartRestart);

            // Clientes
            cdm = _dbh.DbRoot.ClientManager;;

            Assert.AreEqual(1, cdm.Count);

            client = cdm.GetClient(id);

            Assert.AreEqual(name, client.Name);
            Assert.AreEqual(appPath, client.AppFilePath);
            Assert.AreEqual(logPath, client.LogFilePath);
            Assert.AreEqual(timeout, client.Timeout);
            Assert.AreEqual(port, client.Port);
            Assert.AreEqual(mail, client.MailEnabled);
            Assert.AreEqual(logAttach, client.LogAttachEnabled);
            Assert.AreEqual(queueSize, client.QueueSize);

            _dbh.Stop();

            if (System.IO.File.Exists(cfgFile))
            {
                System.IO.File.Delete(cfgFile);
            }
        }