SetUri() public method

public SetUri ( String uri ) : Request
uri String
return Request
Beispiel #1
1
        public void TestConfirmable()
        {
            // send request
            Request req2acc = new Request(Method.POST, true);
            req2acc.SetUri("localhost:" + _serverPort + "/" + ACC_RESOURCE);
            req2acc.SetPayload("client says hi");
            req2acc.Send();

            // receive response and check
            Response response = req2acc.WaitForResponse(100);
            Assert.IsNotNull(response);
            Assert.AreEqual(response.PayloadString, SERVER_RESPONSE);
            Assert.AreEqual(response.Type, MessageType.CON);

            Request req2noacc = new Request(Method.POST, true);
            req2noacc.SetUri("coap://localhost:" + _serverPort + "/" + NO_ACC_RESOURCE);
            req2noacc.SetPayload("client says hi");
            req2noacc.Send();

            // receive response and check
            response = req2noacc.WaitForResponse(100);
            Assert.IsNotNull(response);
            Assert.AreEqual(response.PayloadString, SERVER_RESPONSE);
            Assert.AreEqual(response.Type, MessageType.ACK);
        }
        private void ExecutePOSTRequest()
        {
            String payload = "--no payload--";
            try
            {
                Request request = new Request(Method.POST);
                request.SetUri("coap://localhost:" + _serverPort + "/" + request_short + respond_short);
                if (request_short)
                    request.SetPayload(SHORT_POST_REQUEST);
                else
                    request.SetPayload(LONG_POST_REQUEST);
                request.Send(_clientEndpoint);

                // receive response and check
                Response response = request.WaitForResponse(1000);

                Assert.IsNotNull(response);
                payload = response.PayloadString;

                if (respond_short)
                    Assert.AreEqual(SHORT_POST_RESPONSE, payload);
                else 
                    Assert.AreEqual(LONG_POST_RESPONSE, payload);
            }
            finally
            {
                Thread.Sleep(100); // Quickly wait until last ACKs arrive
            }
        }
Beispiel #3
0
        public void TestConfirmable()
        {
            // send request
            Request req2acc = new Request(Method.POST, true);

            req2acc.SetUri("localhost:" + _serverPort + "/" + ACC_RESOURCE);
            req2acc.SetPayload("client says hi");
            req2acc.Send();

            // receive response and check
            Response response = req2acc.WaitForResponse(100);

            Assert.IsNotNull(response);
            Assert.AreEqual(response.PayloadString, SERVER_RESPONSE);
            Assert.AreEqual(response.Type, MessageType.CON);

            Request req2noacc = new Request(Method.POST, true);

            req2noacc.SetUri("coap://localhost:" + _serverPort + "/" + NO_ACC_RESOURCE);
            req2noacc.SetPayload("client says hi");
            req2noacc.Send();

            // receive response and check
            response = req2noacc.WaitForResponse(100);
            Assert.IsNotNull(response);
            Assert.AreEqual(response.PayloadString, SERVER_RESPONSE);
            Assert.AreEqual(response.Type, MessageType.ACK);
        }
Beispiel #4
0
        private void SendRequestAndExpect(String expected)
        {
            Thread.Sleep(100);
            Request request = Request.NewGet();

            request.SetUri("localhost:" + _serverPort + "/ress");
            String response = request.Send().WaitForResponse(1000).PayloadString;

            Assert.AreEqual(expected, response);
        }
        public void TestDiscoveryFiltering()
        {
            String expected = "</sensors/light>;if=\"sensor\";rt=\"light-lux\"";

            Request request = Request.NewGet();

            request.SetUri("/.well-known/core?rt=light-lux");

            DiscoveryResource discovery  = new DiscoveryResource(_root);
            String            serialized = LinkFormat.Serialize(_root, request.UriQueries);

            Assert.AreEqual(expected, serialized);
        }
        private void ExecutePOSTRequest()
        {
            String payload = "--no payload--";

            try
            {
                Request request = new Request(Method.POST);
                request.SetUri("coap://localhost:" + _serverPort + "/" + request_short + respond_short);
                if (request_short)
                {
                    request.SetPayload(SHORT_POST_REQUEST);
                }
                else
                {
                    request.SetPayload(LONG_POST_REQUEST);
                }
                request.Send(_clientEndpoint);

                // receive response and check
                Response response = request.WaitForResponse(1000);

                Assert.IsNotNull(response);
                payload = response.PayloadString;

                if (respond_short)
                {
                    Assert.AreEqual(SHORT_POST_RESPONSE, payload);
                }
                else
                {
                    Assert.AreEqual(LONG_POST_RESPONSE, payload);
                }
            }
            finally
            {
                Thread.Sleep(100); // Quickly wait until last ACKs arrive
            }
        }