// resourcesUsed and users (per-user resources used) are checked in
        // testPerUserResource()
        /// <exception cref="System.Exception"/>
        private void VerifySubQueueGeneric(string q, TestRMWebServicesCapacitySched.QueueInfo
                                           info, float parentAbsCapacity, float parentAbsMaxCapacity)
        {
            string[] qArr = q.Split("\\.");
            NUnit.Framework.Assert.IsTrue("q name invalid: " + q, qArr.Length > 1);
            string qshortName = qArr[qArr.Length - 1];

            NUnit.Framework.Assert.AreEqual("usedCapacity doesn't match", 0, info.usedCapacity
                                            , 1e-3f);
            NUnit.Framework.Assert.AreEqual("capacity doesn't match", csConf.GetNonLabeledQueueCapacity
                                                (q), info.capacity, 1e-3f);
            float expectCapacity       = csConf.GetNonLabeledQueueMaximumCapacity(q);
            float expectAbsMaxCapacity = parentAbsMaxCapacity * (info.maxCapacity / 100);

            if (CapacitySchedulerConfiguration.Undefined == expectCapacity)
            {
                expectCapacity       = 100;
                expectAbsMaxCapacity = 100;
            }
            NUnit.Framework.Assert.AreEqual("maxCapacity doesn't match", expectCapacity, info
                                            .maxCapacity, 1e-3f);
            NUnit.Framework.Assert.AreEqual("absoluteCapacity doesn't match", parentAbsCapacity
                                            * (info.capacity / 100), info.absoluteCapacity, 1e-3f);
            NUnit.Framework.Assert.AreEqual("absoluteMaxCapacity doesn't match", expectAbsMaxCapacity
                                            , info.absoluteMaxCapacity, 1e-3f);
            NUnit.Framework.Assert.AreEqual("absoluteUsedCapacity doesn't match", 0, info.absoluteUsedCapacity
                                            , 1e-3f);
            NUnit.Framework.Assert.AreEqual("numApplications doesn't match", 0, info.numApplications
                                            );
            NUnit.Framework.Assert.IsTrue("queueName doesn't match, got: " + info.queueName +
                                          " expected: " + q, qshortName.Matches(info.queueName));
            NUnit.Framework.Assert.IsTrue("state doesn't match", (csConf.GetState(q).ToString
                                                                      ()).Matches(info.state));
        }
        /// <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);
            }
        }