示例#1
0
        public virtual void TestJobsQueryStateInvalid()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("state", "InvalidState").Accept(MediaType.ApplicationJson
                                                                                                                                             ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(ClientResponse.Status.BadRequest, response.GetClientResponseStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject msg       = response.GetEntity <JSONObject>();
            JSONObject exception = msg.GetJSONObject("RemoteException");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                ());
            string message   = exception.GetString("message");
            string type      = exception.GetString("exception");
            string classname = exception.GetString("javaClassName");

            WebServicesTestUtils.CheckStringContains("exception message", "org.apache.hadoop.mapreduce.v2.api.records.JobState.InvalidState"
                                                     , message);
            WebServicesTestUtils.CheckStringMatch("exception type", "IllegalArgumentException"
                                                  , type);
            WebServicesTestUtils.CheckStringMatch("exception classname", "java.lang.IllegalArgumentException"
                                                  , classname);
        }
 private void VerifyStateInvalidException(string message, string type, string classname
                                          )
 {
     WebServicesTestUtils.CheckStringContains("exception message", "org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState.FOO_STATE"
                                              , message);
     WebServicesTestUtils.CheckStringMatch("exception type", "IllegalArgumentException"
                                           , type);
     WebServicesTestUtils.CheckStringMatch("exception classname", "java.lang.IllegalArgumentException"
                                           , classname);
 }
        public virtual void TestNodesQueryStateInvalid()
        {
            WebResource r = Resource();

            rm.RegisterNode("h1:1234", 5120);
            rm.RegisterNode("h2:1235", 5121);
            try
            {
                r.Path("ws").Path("v1").Path("cluster").Path("nodes").QueryParam("states", "BOGUSSTATE"
                                                                                 ).Accept(MediaType.ApplicationJson).Get <JSONObject>();
                NUnit.Framework.Assert.Fail("should have thrown exception querying invalid state"
                                            );
            }
            catch (UniformInterfaceException ue)
            {
                ClientResponse response = ue.GetResponse();
                NUnit.Framework.Assert.AreEqual(ClientResponse.Status.BadRequest, response.GetClientResponseStatus
                                                    ());
                NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                                );
                JSONObject msg       = response.GetEntity <JSONObject>();
                JSONObject exception = msg.GetJSONObject("RemoteException");
                NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                    ());
                string message   = exception.GetString("message");
                string type      = exception.GetString("exception");
                string classname = exception.GetString("javaClassName");
                WebServicesTestUtils.CheckStringContains("exception message", "org.apache.hadoop.yarn.api.records.NodeState.BOGUSSTATE"
                                                         , message);
                WebServicesTestUtils.CheckStringMatch("exception type", "IllegalArgumentException"
                                                      , type);
                WebServicesTestUtils.CheckStringMatch("exception classname", "java.lang.IllegalArgumentException"
                                                      , classname);
            }
            finally
            {
                rm.Stop();
            }
        }