Beispiel #1
0
        public static void ConfirmDataBaseType(XmlElement xmlElem,
                                               string name, DatabaseType dbType, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                if (xmlNode.InnerText == "BTREE")
                {
                    Assert.AreEqual(dbType, DatabaseType.BTREE);
                }
                else if (xmlNode.InnerText == "HASH")
                {
                    Assert.AreEqual(dbType, DatabaseType.HASH);
                }
                else if (xmlNode.InnerText == "QUEUE")
                {
                    Assert.AreEqual(dbType, DatabaseType.QUEUE);
                }
                else if (xmlNode.InnerText == "RECNO")
                {
                    Assert.AreEqual(dbType, DatabaseType.RECNO);
                }
                else if (xmlNode.InnerText == "UNKNOWN")
                {
                    Assert.AreEqual(dbType, DatabaseType.UNKNOWN);
                }
            }
        }
Beispiel #2
0
        public static void ConfirmCreatePolicy(XmlElement xmlElem,
                                               string name, CreatePolicy createPolicy, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                if (xmlNode.InnerText == "ALWAYS")
                {
                    Assert.IsTrue(createPolicy.Equals(CreatePolicy.ALWAYS));
                }
                else if (xmlNode.InnerText == "IF_NEEDED")
                {
                    Assert.IsTrue(createPolicy.Equals(CreatePolicy.IF_NEEDED));
                }
                else if (xmlNode.InnerText == "NEVER")
                {
                    Assert.IsTrue(createPolicy.Equals(CreatePolicy.NEVER));
                }
            }
        }
Beispiel #3
0
        public static void ConfirmIsolation(XmlElement xmlElem,
                                            string name, Isolation value, bool compulsory)
        {
            XmlNode xmlNode;
            int     isolationDegree;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                isolationDegree = int.Parse(xmlNode.InnerText);
                if (isolationDegree == 1)
                {
                    Assert.AreEqual(Isolation.DEGREE_ONE, value);
                }
                else if (isolationDegree == 2)
                {
                    Assert.AreEqual(Isolation.DEGREE_TWO, value);
                }
                else if (isolationDegree == 3)
                {
                    Assert.AreEqual(Isolation.DEGREE_THREE, value);
                }
                else
                {
                    throw new InvalidConfigException(name);
                }
            }
        }
Beispiel #4
0
        public static void ConfirmEncryption(XmlElement xmlElem,
                                             string name, string dPwd, EncryptionAlgorithm dAlg, bool compulsory)
        {
            EncryptionAlgorithm alg;
            XmlNode             xmlNode = XMLReader.GetNode(xmlElem,
                                                            name);

            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                string password = XMLReader.GetNode(
                    (XmlElement)xmlNode, "password").InnerText;
                string tmp = XMLReader.GetNode(
                    (XmlElement)xmlNode, "algorithm").InnerText;
                if (tmp == "AES")
                {
                    alg = EncryptionAlgorithm.AES;
                }
                else
                {
                    alg = EncryptionAlgorithm.DEFAULT;
                }
                Assert.AreEqual(dAlg, alg);
                Assert.AreEqual(dPwd, dPwd);
            }
        }
Beispiel #5
0
        public static bool ConfigByteMatrix(XmlElement xmlElem,
                                            string name, ref byte[,] byteMatrix, bool compulsory)
        {
            int i, j, matrixLen;

            XmlNode xmlNode = XMLReader.GetNode(xmlElem, name);

            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            matrixLen      = xmlNode.ChildNodes.Count;
            byte[,] matrix = new byte[matrixLen, matrixLen];
            for (i = 0; i < matrixLen; i++)
            {
                if (xmlNode.ChildNodes[i].ChildNodes.Count != matrixLen)
                {
                    throw new ConfigNotFoundException(name);
                }
                for (j = 0; j < matrixLen; j++)
                {
                    matrix[i, j] = byte.Parse(
                        xmlNode.ChildNodes[i].ChildNodes[j].InnerText);
                }
            }

            byteMatrix = matrix;
            return(true);
        }
Beispiel #6
0
        public static void ConfirmStringList(XmlElement xmlElem,
                                             string name, List <string> strings, bool compulsory)
        {
            XmlNode xmlNode;

            if (strings != null)
            {
                xmlNode = XMLReader.GetNode(xmlElem, name);
                if (xmlNode == null && compulsory == true)
                {
                    throw new ConfigNotFoundException(name);
                }
                else if (xmlNode != null)
                {
                    if (xmlNode.HasChildNodes)
                    {
                        XmlNodeList list = xmlNode.ChildNodes;
                        for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                        {
                            Assert.IsTrue(
                                strings.Contains(list[i].InnerText));
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public static bool ConfigCreatePolicy(XmlElement xmlElem,
                                              string name, ref CreatePolicy createPolicy, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            if (xmlNode.InnerText == "ALWAYS")
            {
                createPolicy = CreatePolicy.ALWAYS;
            }
            else if (xmlNode.InnerText == "IF_NEEDED")
            {
                createPolicy = CreatePolicy.IF_NEEDED;
            }
            else if (xmlNode.InnerText == "NEVER")
            {
                createPolicy = CreatePolicy.NEVER;
            }
            else
            {
                throw new InvalidConfigException(name);
            }

            return(true);
        }
Beispiel #8
0
        public static void ConfirmCachePriority(XmlElement xmlElem,
                                                string name, CachePriority priority, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                if (xmlNode.InnerText == "DEFAULT")
                {
                    Assert.AreEqual(CachePriority.DEFAULT, priority);
                }
                else if (xmlNode.InnerText == "HIGH")
                {
                    Assert.AreEqual(CachePriority.HIGH, priority);
                }
                else if (xmlNode.InnerText == "LOW")
                {
                    Assert.AreEqual(CachePriority.LOW, priority);
                }
                else if (xmlNode.InnerText == "VERY_HIGH")
                {
                    Assert.AreEqual(CachePriority.VERY_HIGH, priority);
                }
                else if (xmlNode.InnerText == "VERY_LOW")
                {
                    Assert.AreEqual(CachePriority.VERY_LOW, priority);
                }
            }
        }
Beispiel #9
0
        public static void ConfirmDuplicatesPolicy(
            XmlElement xmlElem, string name,
            DuplicatesPolicy duplicatedPolicy, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                if (xmlNode.InnerText == "NONE")
                {
                    Assert.AreEqual(duplicatedPolicy, DuplicatesPolicy.NONE);
                }
                else if (xmlNode.InnerText == "SORTED")
                {
                    Assert.AreEqual(duplicatedPolicy, DuplicatesPolicy.SORTED);
                }
                else if (xmlNode.InnerText == "UNSORTED")
                {
                    Assert.AreEqual(duplicatedPolicy, DuplicatesPolicy.UNSORTED);
                }
            }
        }
Beispiel #10
0
        public static bool ConfigMaxSequentialWrites(
            XmlElement xmlElem, string name,
            MPoolConfig mpoolConfig, bool compulsory)
        {
            XmlNode xmlNode;
            uint    pause;
            int     writes;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            pause = uint.Parse(XMLReader.GetNode(
                                   (XmlElement)xmlNode, "pause").InnerText);
            writes = int.Parse(XMLReader.GetNode(
                                   (XmlElement)xmlNode, "maxWrites").InnerText);
            mpoolConfig.SetMaxSequentialWrites(writes, pause);
            return(true);
        }
Beispiel #11
0
        public static bool ConfigDuplicatesPolicy(XmlElement xmlElem,
                                                  string name, ref DuplicatesPolicy duplicatePolicy, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            if (xmlNode.InnerText == "NONE")
            {
                duplicatePolicy = DuplicatesPolicy.NONE;
            }
            else if (xmlNode.InnerText == "SORTED")
            {
                duplicatePolicy = DuplicatesPolicy.SORTED;
            }
            else if (xmlNode.InnerText == "UNSORTED")
            {
                duplicatePolicy = DuplicatesPolicy.UNSORTED;
            }
            else
            {
                throw new InvalidConfigException(name);
            }

            return(true);
        }
Beispiel #12
0
        public static bool ConfigEncryption(XmlElement xmlElem,
                                            string name, DatabaseConfig dbConfig, bool compulsory)
        {
            EncryptionAlgorithm alg;
            XmlNode             xmlNode;
            string tmp, password;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            password = XMLReader.GetNode((XmlElement)xmlNode,
                                         "password").InnerText;
            tmp = XMLReader.GetNode((XmlElement)xmlNode, "algorithm").InnerText;
            if (tmp == "AES")
            {
                alg = EncryptionAlgorithm.AES;
            }
            else
            {
                alg = EncryptionAlgorithm.DEFAULT;
            }
            dbConfig.SetEncryption(password, alg);
            return(true);
        }
Beispiel #13
0
        /*
         * If configure MACHINE, the ByteOrder in database will
         * switch to LITTLE_ENDIAN or BIG_ENDIAN according to the
         * current machine.
         */
        public static void ConfirmByteOrder(XmlElement xmlElem,
                                            string name, ByteOrder byteOrder, bool compulsory)
        {
            XmlNode   xmlNode;
            ByteOrder specOrder;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                specOrder = ByteOrder.FromConst(int.Parse(
                                                    xmlNode.InnerText));
                if (specOrder == ByteOrder.MACHINE)
                {
                    Assert.AreNotEqual(specOrder, byteOrder);
                }
                else
                {
                    Assert.AreEqual(specOrder, byteOrder);
                }
            }
        }
Beispiel #14
0
        public static bool ConfigDeadlockPolicy(XmlElement xmlElem,
                                                string name, ref DeadlockPolicy deadlockPolicy, bool compulsory)
        {
            XmlNode xmlNode = XMLReader.GetNode(xmlElem, name);

            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            string policy = xmlNode.InnerText;

            if (policy == "DEFAULT")
            {
                deadlockPolicy = DeadlockPolicy.DEFAULT;
            }
            else if (policy == "EXPIRE")
            {
                deadlockPolicy = DeadlockPolicy.EXPIRE;
            }
            else if (policy == "MAX_LOCKS")
            {
                deadlockPolicy = DeadlockPolicy.MAX_LOCKS;
            }
            else if (policy == "MAX_WRITE")
            {
                deadlockPolicy = DeadlockPolicy.MAX_WRITE;
            }
            else if (policy == "MIN_LOCKS")
            {
                deadlockPolicy = DeadlockPolicy.MIN_LOCKS;
            }
            else if (policy == "MIN_WRITE")
            {
                deadlockPolicy = DeadlockPolicy.MIN_WRITE;
            }
            else if (policy == "OLDEST")
            {
                deadlockPolicy = DeadlockPolicy.OLDEST;
            }
            else if (policy == "RANDOM")
            {
                deadlockPolicy = DeadlockPolicy.RANDOM;
            }
            else if (policy == "YOUNGEST")
            {
                deadlockPolicy = DeadlockPolicy.YOUNGEST;
            }
            else
            {
                throw new InvalidConfigException(name);
            }
            return(true);
        }
Beispiel #15
0
        public static void ConfirmDeadlockPolicy(XmlElement xmlElem,
                                                 string name, DeadlockPolicy deadlockPolicy, bool compulsory)
        {
            XmlNode xmlNode = XMLReader.GetNode(xmlElem, name);

            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                string policy = xmlNode.InnerText;
                if (policy == "DEFAULT")
                {
                    Assert.AreEqual(DeadlockPolicy.DEFAULT, deadlockPolicy);
                }
                else if (policy == "EXPIRE")
                {
                    Assert.AreEqual(DeadlockPolicy.EXPIRE, deadlockPolicy);
                }
                else if (policy == "MAX_LOCKS")
                {
                    Assert.AreEqual(DeadlockPolicy.MAX_LOCKS, deadlockPolicy);
                }
                else if (policy == "MAX_WRITE")
                {
                    Assert.AreEqual(DeadlockPolicy.MAX_WRITE, deadlockPolicy);
                }
                else if (policy == "MIN_LOCKS")
                {
                    Assert.AreEqual(DeadlockPolicy.MIN_LOCKS, deadlockPolicy);
                }
                else if (policy == "MIN_WRITE")
                {
                    Assert.AreEqual(DeadlockPolicy.MIN_WRITE, deadlockPolicy);
                }
                else if (policy == "OLDEST")
                {
                    Assert.AreEqual(DeadlockPolicy.OLDEST, deadlockPolicy);
                }
                else if (policy == "RANDOM")
                {
                    Assert.AreEqual(DeadlockPolicy.RANDOM, deadlockPolicy);
                }
                else if (policy == "YOUNGEST")
                {
                    Assert.AreEqual(DeadlockPolicy.YOUNGEST, deadlockPolicy);
                }
                else
                {
                    throw new InvalidConfigException(name);
                }
            }
        }
Beispiel #16
0
        /*
         * Reading params successfully returns true. Unless returns
         * false. The retrieved Xml fragment is returning in xmlElem.
         */
        public static XmlElement TestSetUp(string testFixtureName, string testName)
        {
            XMLReader  xmlReader = new XMLReader("../../AllTestData.xml");
            XmlElement xmlElem   = xmlReader.GetXmlElement(testFixtureName, testName);

            if (xmlElem == null)
            {
                throw new ConfigNotFoundException(testFixtureName + ":" + testName);
            }
            else
            {
                return(xmlElem);
            }
        }
Beispiel #17
0
        /*
         * Confirm that the given value is the same with that in
         * xml. If there is no testing data in xml and it is
         * compulsory, the ConfigNotFoundException will be thrown.
         * If there is no testing data and it is optional, nothing
         * will be done. If any testing data is provided, the value
         * will be checked.
         */
        #region Confirm
        public static void ConfirmAckPolicy(XmlElement xmlElem,
                                            string name, AckPolicy ackPolicy, bool compulsory)
        {
            XmlNode xmlNode = XMLReader.GetNode(xmlElem,
                                                name);

            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                string policy = xmlNode.InnerText;
                if (policy == "ALL")
                {
                    Assert.AreEqual(AckPolicy.ALL,
                                    ackPolicy);
                }
                else if (policy == "ALL_PEERS")
                {
                    Assert.AreEqual(AckPolicy.ALL_PEERS,
                                    ackPolicy);
                }
                else if (policy == "NONE")
                {
                    Assert.AreEqual(AckPolicy.NONE,
                                    ackPolicy);
                }
                else if (policy == "ONE")
                {
                    Assert.AreEqual(AckPolicy.ONE,
                                    ackPolicy);
                }
                else if (policy == "ONE_PEER")
                {
                    Assert.AreEqual(AckPolicy.ONE_PEER,
                                    ackPolicy);
                }
                else if (policy == "QUORUM")
                {
                    Assert.AreEqual(AckPolicy.QUORUM,
                                    ackPolicy);
                }
                else
                {
                    throw new InvalidConfigException(name);
                }
            }
        }
Beispiel #18
0
        public static void ConfirmUint(XmlElement xmlElem,
                                       string name, uint value, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                Assert.AreEqual(uint.Parse(xmlNode.InnerText), value);
            }
        }
Beispiel #19
0
        public static bool ConfigVerboseMessages(
            XmlElement xmlElem, string name,
            ref VerboseMessages verbose, bool compulsory)
        {
            XmlNode xmlNode = XMLReader.GetNode(xmlElem,
                                                name);

            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            ConfigBool((XmlElement)xmlNode, "AllFileOps",
                       ref verbose.AllFileOps, compulsory);
            ConfigBool((XmlElement)xmlNode, "Deadlock",
                       ref verbose.Deadlock, compulsory);
            ConfigBool((XmlElement)xmlNode, "FileOps",
                       ref verbose.FileOps, compulsory);
            ConfigBool((XmlElement)xmlNode, "Recovery",
                       ref verbose.Recovery, compulsory);
            ConfigBool((XmlElement)xmlNode, "Register",
                       ref verbose.Register, compulsory);
            ConfigBool((XmlElement)xmlNode, "Replication",
                       ref verbose.Replication, compulsory);
            ConfigBool((XmlElement)xmlNode, "ReplicationElection",
                       ref verbose.ReplicationElection, compulsory);
            ConfigBool((XmlElement)xmlNode, "ReplicationLease",
                       ref verbose.ReplicationLease, compulsory);
            ConfigBool((XmlElement)xmlNode, "ReplicationMessages",
                       ref verbose.ReplicationMessages, compulsory);
            ConfigBool((XmlElement)xmlNode, "ReplicationMisc",
                       ref verbose.ReplicationMisc, compulsory);
            ConfigBool((XmlElement)xmlNode, "ReplicationSync",
                       ref verbose.ReplicationSync, compulsory);
            ConfigBool((XmlElement)xmlNode, "RepMgrConnectionFailure",
                       ref verbose.RepMgrConnectionFailure, compulsory);
            ConfigBool((XmlElement)xmlNode, "RepMgrMisc",
                       ref verbose.RepMgrMisc, compulsory);
            ConfigBool((XmlElement)xmlNode, "WaitsForTable",
                       ref verbose.WaitsForTable, compulsory);
            return(true);
        }
Beispiel #20
0
        public static bool ConfigBool(XmlElement xmlElem,
                                      string name, ref bool value, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            value = bool.Parse(xmlNode.InnerText);
            return(true);
        }
Beispiel #21
0
        public static bool ConfigString(XmlElement xmlElem,
                                        string name, ref string valChar, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            valChar = xmlNode.InnerText;
            return(true);
        }
Beispiel #22
0
        public static bool ConfigCachePriority(XmlElement xmlElem,
                                               string name, ref CachePriority cachePriority, bool compulsory)
        {
            XmlNode xmlNode;
            string  priority;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            priority = xmlNode.InnerText;
            if (priority == "DEFAULT")
            {
                cachePriority = CachePriority.DEFAULT;
            }
            else if (priority == "HIGH")
            {
                cachePriority = CachePriority.HIGH;
            }
            else if (priority == "LOW")
            {
                cachePriority = CachePriority.LOW;
            }
            else if (priority == "VERY_HIGH")
            {
                cachePriority = CachePriority.VERY_HIGH;
            }
            else if (priority == "VERY_LOW")
            {
                cachePriority = CachePriority.VERY_LOW;
            }
            else
            {
                throw new InvalidConfigException(name);
            }

            return(true);
        }
Beispiel #23
0
        public static bool ConfigByteOrder(XmlElement xmlElem,
                                           string name, ref ByteOrder byteOrder, bool compulsory)
        {
            XmlNode xmlNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            byteOrder = ByteOrder.FromConst(
                int.Parse(xmlNode.InnerText));
            return(true);
        }
Beispiel #24
0
        public static bool ConfigLogFlush(XmlElement xmlElem,
                                          string name, ref TransactionConfig.LogFlush value,
                                          bool compulsory)
        {
            XmlNode xmlNode;
            string  logFlush;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            logFlush = xmlNode.InnerText;
            if (logFlush == "DEFAULT")
            {
                value = TransactionConfig.LogFlush.DEFAULT;
            }
            else if (logFlush == "NOSYNC")
            {
                value = TransactionConfig.LogFlush.NOSYNC;
            }
            else if (logFlush == "WRITE_NOSYNC")
            {
                value = TransactionConfig.LogFlush.WRITE_NOSYNC;
            }
            else if (logFlush == "SYNC")
            {
                value = TransactionConfig.LogFlush.SYNC;
            }
            else
            {
                throw new InvalidConfigException(name);
            }

            return(true);
        }
Beispiel #25
0
        public static void ConfirmReplicationHostAddress(
            XmlElement xmlElem, string name,
            ReplicationHostAddress address, bool compulsory)
        {
            XmlNode xmlNode = XMLReader.GetNode(xmlElem, name);

            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                string host = XMLReader.GetNode(
                    (XmlElement)xmlNode, "Host").InnerText;
                uint port = uint.Parse(XMLReader.GetNode(
                                           (XmlElement)xmlNode, "Port").InnerText);

                Assert.AreEqual(host, address.Host);
                Assert.AreEqual(port, address.Port);
            }
        }
Beispiel #26
0
        public static void ConfirmByteMatrix(XmlElement xmlElem,
                                             string name, byte[,] byteMatrix, bool compulsory)
        {
            int i, j, matrixLen;

            XmlNode xmlNode = XMLReader.GetNode(xmlElem, name);

            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                /*
                 * If the length of the 2 matrixes are not
                 * the same, the matrixes are definately
                 * not equal.
                 */
                matrixLen = xmlNode.ChildNodes.Count;
                Assert.AreEqual(matrixLen * matrixLen, byteMatrix.Length);

                /*
                 * Go over every element in the matrix to
                 * see if the same with the given xml data.
                 */
                for (i = 0; i < matrixLen; i++)
                {
                    if (xmlNode.ChildNodes[i].ChildNodes.Count != matrixLen)
                    {
                        throw new ConfigNotFoundException(name);
                    }
                    for (j = 0; j < matrixLen; j++)
                    {
                        Assert.AreEqual(
                            byte.Parse(xmlNode.ChildNodes[i].ChildNodes[j].InnerText),
                            byteMatrix[i, j]);
                    }
                }
            }
        }
Beispiel #27
0
        public static void ConfirmString(XmlElement xmlElem,
                                         string name, string str, bool compulsory)
        {
            XmlNode xmlNode;

            if (str != null)
            {
                xmlNode = XMLReader.GetNode(xmlElem, name);
                if (xmlNode == null && compulsory == true)
                {
                    throw new ConfigNotFoundException(name);
                }
                else if (xmlNode != null)
                {
                    if (xmlNode.HasChildNodes)
                    {
                        Assert.AreEqual(
                            xmlNode.FirstChild.InnerText, str);
                    }
                }
            }
        }
Beispiel #28
0
        public static bool ConfigReplicationHostAddress(
            XmlElement xmlElem, string name,
            ref ReplicationHostAddress address, bool compulsory)
        {
            XmlNode xmlNode = XMLReader.GetNode(
                xmlElem, name);

            if (xmlNode == null && compulsory == false)
            {
                return(false);
            }
            else if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }

            address.Host = XMLReader.GetNode(
                (XmlElement)xmlNode, "Host").InnerText;
            address.Port = uint.Parse(XMLReader.GetNode(
                                          (XmlElement)xmlNode, "Port").InnerText);
            return(true);
        }
Beispiel #29
0
        public static void ConfirmBool(XmlElement xmlElem,
                                       string name, bool value, bool compulsory)
        {
            XmlNode xmlNode;
            bool    expected;

            xmlNode = XMLReader.GetNode(xmlElem,
                                        name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                if (xmlNode.ChildNodes.Count > 1)
                {
                    expected = bool.Parse(
                        xmlNode.FirstChild.NextSibling.InnerText);
                    Assert.AreEqual(expected, value);
                }
            }
        }
Beispiel #30
0
        /*
         * If bytes in CacheSize is assigned, the bytes in cachesize
         * couldn't be the default one.
         */
        public static void ConfirmCacheSize(XmlElement xmlElem,
                                            string name, CacheInfo cache, uint defaultCache,
                                            bool compulsory)
        {
            uint    bytes;
            uint    gigabytes;
            int     nCaches;
            XmlNode xmlNode;
            XmlNode xmlChildNode;

            xmlNode = XMLReader.GetNode(xmlElem, name);
            if (xmlNode == null && compulsory == true)
            {
                throw new ConfigNotFoundException(name);
            }
            else if (xmlNode != null)
            {
                if ((xmlChildNode = XMLReader.GetNode(
                         (XmlElement)xmlNode, "Bytes")) != null)
                {
                    bytes = defaultCache;
                    if ((xmlChildNode = XMLReader.GetNode(
                             (XmlElement)xmlNode, "Gigabytes")) != null)
                    {
                        gigabytes = uint.Parse(xmlChildNode.InnerText);
                        if ((xmlChildNode = XMLReader.GetNode(
                                 (XmlElement)xmlNode, "NCaches")) != null)
                        {
                            nCaches = int.Parse(xmlChildNode.InnerText);
                            Assert.AreNotEqual(bytes, cache.Bytes);
                            Assert.AreEqual(gigabytes, cache.Gigabytes);
                            Assert.AreEqual(nCaches, cache.NCaches);
                        }
                    }
                }
            }
        }
Beispiel #31
0
 /*
  * Reading params successfully returns true. Unless returns
  * false. The retrieved Xml fragment is returning in xmlElem.
  */
 public static XmlElement TestSetUp(string testFixtureName, string testName)
 {
     XMLReader xmlReader = new XMLReader("../../AllTestData.xml");
     XmlElement xmlElem = xmlReader.GetXmlElement(testFixtureName, testName);
     if (xmlElem == null)
         throw new ConfigNotFoundException(testFixtureName + ":" + testName);
     else
         return xmlElem;
 }