/// <exception cref="System.Exception"/>
        private void VerifyLeafQueueGeneric(string q, TestRMWebServicesCapacitySched.LeafQueueInfo
                                            info)
        {
            NUnit.Framework.Assert.AreEqual("numActiveApplications doesn't match", 0, info.numActiveApplications
                                            );
            NUnit.Framework.Assert.AreEqual("numPendingApplications doesn't match", 0, info.numPendingApplications
                                            );
            NUnit.Framework.Assert.AreEqual("numContainers doesn't match", 0, info.numContainers
                                            );
            int maxSystemApps          = csConf.GetMaximumSystemApplications();
            int expectedMaxApps        = (int)(maxSystemApps * (info.absoluteCapacity / 100));
            int expectedMaxAppsPerUser = (int)(expectedMaxApps * (info.userLimit / 100.0f) *
                                               info.userLimitFactor);

            // TODO: would like to use integer comparisons here but can't due to
            //       roundoff errors in absolute capacity calculations
            NUnit.Framework.Assert.AreEqual("maxApplications doesn't match", (float)expectedMaxApps
                                            , (float)info.maxApplications, 1.0f);
            NUnit.Framework.Assert.AreEqual("maxApplicationsPerUser doesn't match", (float)expectedMaxAppsPerUser
                                            , (float)info.maxApplicationsPerUser, info.userLimitFactor);
            NUnit.Framework.Assert.AreEqual("userLimit doesn't match", csConf.GetUserLimit(q)
                                            , info.userLimit);
            NUnit.Framework.Assert.AreEqual("userLimitFactor doesn't match", csConf.GetUserLimitFactor
                                                (q), info.userLimitFactor, 1e-3f);
        }
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        private void VerifySubQueue(JSONObject info, string q, float parentAbsCapacity, float
                                    parentAbsMaxCapacity)
        {
            int  numExpectedElements = 13;
            bool isParentQueue       = true;

            if (!info.Has("queues"))
            {
                numExpectedElements = 25;
                isParentQueue       = false;
            }
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", numExpectedElements
                                            , info.Length());
            TestRMWebServicesCapacitySched.QueueInfo qi = isParentQueue ? new TestRMWebServicesCapacitySched.QueueInfo
                                                              (this) : new TestRMWebServicesCapacitySched.LeafQueueInfo(this);
            qi.capacity             = (float)info.GetDouble("capacity");
            qi.usedCapacity         = (float)info.GetDouble("usedCapacity");
            qi.maxCapacity          = (float)info.GetDouble("maxCapacity");
            qi.absoluteCapacity     = (float)info.GetDouble("absoluteCapacity");
            qi.absoluteMaxCapacity  = (float)info.GetDouble("absoluteMaxCapacity");
            qi.absoluteUsedCapacity = (float)info.GetDouble("absoluteUsedCapacity");
            qi.numApplications      = info.GetInt("numApplications");
            qi.queueName            = info.GetString("queueName");
            qi.state = info.GetString("state");
            VerifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);
            if (isParentQueue)
            {
                JSONArray arr = info.GetJSONObject("queues").GetJSONArray("queue");
                // test subqueues
                for (int i = 0; i < arr.Length(); i++)
                {
                    JSONObject obj = arr.GetJSONObject(i);
                    string     q2  = q + "." + obj.GetString("queueName");
                    VerifySubQueue(obj, q2, qi.absoluteCapacity, qi.absoluteMaxCapacity);
                }
            }
            else
            {
                TestRMWebServicesCapacitySched.LeafQueueInfo lqi = (TestRMWebServicesCapacitySched.LeafQueueInfo
                                                                    )qi;
                lqi.numActiveApplications  = info.GetInt("numActiveApplications");
                lqi.numPendingApplications = info.GetInt("numPendingApplications");
                lqi.numContainers          = info.GetInt("numContainers");
                lqi.maxApplications        = info.GetInt("maxApplications");
                lqi.maxApplicationsPerUser = info.GetInt("maxApplicationsPerUser");
                lqi.userLimit       = info.GetInt("userLimit");
                lqi.userLimitFactor = (float)info.GetDouble("userLimitFactor");
                VerifyLeafQueueGeneric(q, lqi);
            }
        }
        /// <exception cref="System.Exception"/>
        public virtual void VerifySubQueueXML(Element qElem, string q, float parentAbsCapacity
                                              , float parentAbsMaxCapacity)
        {
            NodeList children     = qElem.GetChildNodes();
            bool     hasSubQueues = false;

            for (int j = 0; j < children.GetLength(); j++)
            {
                Element qElem2 = (Element)children.Item(j);
                if (qElem2.GetTagName().Equals("queues"))
                {
                    NodeList qListInfos = qElem2.GetChildNodes();
                    if (qListInfos.GetLength() > 0)
                    {
                        hasSubQueues = true;
                    }
                }
            }
            TestRMWebServicesCapacitySched.QueueInfo qi = (hasSubQueues) ? new TestRMWebServicesCapacitySched.QueueInfo
                                                              (this) : new TestRMWebServicesCapacitySched.LeafQueueInfo(this);
            qi.capacity            = WebServicesTestUtils.GetXmlFloat(qElem, "capacity");
            qi.usedCapacity        = WebServicesTestUtils.GetXmlFloat(qElem, "usedCapacity");
            qi.maxCapacity         = WebServicesTestUtils.GetXmlFloat(qElem, "maxCapacity");
            qi.absoluteCapacity    = WebServicesTestUtils.GetXmlFloat(qElem, "absoluteCapacity");
            qi.absoluteMaxCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "absoluteMaxCapacity"
                                                                      );
            qi.absoluteUsedCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "absoluteUsedCapacity"
                                                                       );
            qi.numApplications = WebServicesTestUtils.GetXmlInt(qElem, "numApplications");
            qi.queueName       = WebServicesTestUtils.GetXmlString(qElem, "queueName");
            qi.state           = WebServicesTestUtils.GetXmlString(qElem, "state");
            VerifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);
            if (hasSubQueues)
            {
                for (int j_1 = 0; j_1 < children.GetLength(); j_1++)
                {
                    Element qElem2 = (Element)children.Item(j_1);
                    if (qElem2.GetTagName().Equals("queues"))
                    {
                        NodeList qListInfos = qElem2.GetChildNodes();
                        for (int k = 0; k < qListInfos.GetLength(); k++)
                        {
                            Element qElem3 = (Element)qListInfos.Item(k);
                            string  qName3 = WebServicesTestUtils.GetXmlString(qElem3, "queueName");
                            string  q3     = q + "." + qName3;
                            VerifySubQueueXML(qElem3, q3, qi.absoluteCapacity, qi.absoluteMaxCapacity);
                        }
                    }
                }
            }
            else
            {
                TestRMWebServicesCapacitySched.LeafQueueInfo lqi = (TestRMWebServicesCapacitySched.LeafQueueInfo
                                                                    )qi;
                lqi.numActiveApplications = WebServicesTestUtils.GetXmlInt(qElem, "numActiveApplications"
                                                                           );
                lqi.numPendingApplications = WebServicesTestUtils.GetXmlInt(qElem, "numPendingApplications"
                                                                            );
                lqi.numContainers          = WebServicesTestUtils.GetXmlInt(qElem, "numContainers");
                lqi.maxApplications        = WebServicesTestUtils.GetXmlInt(qElem, "maxApplications");
                lqi.maxApplicationsPerUser = WebServicesTestUtils.GetXmlInt(qElem, "maxApplicationsPerUser"
                                                                            );
                lqi.userLimit       = WebServicesTestUtils.GetXmlInt(qElem, "userLimit");
                lqi.userLimitFactor = WebServicesTestUtils.GetXmlFloat(qElem, "userLimitFactor");
                VerifyLeafQueueGeneric(q, lqi);
            }
        }