예제 #1
0
        public void TestSubscribeCommand()
        {
            string sessionKey = Join();

            client.AddListener4SIBNotifications(new WebSocketCommandListener4SIBIndicationNotifications());

            SSAPMessage <SSAPBodySubscribeCommandMessage> requestSubscribe  = SSAPMessageGenerator.GetInstance().GenerateSubscribeCommandMessage(KP, KP_INSTANCE, TOKEN, SSAPCommandType.STATUS);
            SSAPMessage <SSAPBodyReturnMessage>           responseSubscribe = client.Send(requestSubscribe);
            string subscriptionId = responseSubscribe.Body.Data.ToString();

            Assert.IsFalse(String.IsNullOrEmpty(subscriptionId));


            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("atributo1", "valor1");
            args.Add("atributo2", "valor2");

            SSAPMessage <SSAPBodyCommandMessage> request  = SSAPMessageGenerator.GetInstance().GenerateCommandMessage(sessionKey, KP, KP_INSTANCE, SSAPCommandType.STATUS, args);
            SSAPMessage <SSAPBodyReturnMessage>  response = client.Send(request);

            Thread.Sleep(5000);

            Assert.IsTrue(indicationCommandRecived);

            Leave(sessionKey);
        }
예제 #2
0
        public void TestIndication()
        {
            string sessionKey = Join();

            client.AddListener4SIBNotifications(new WebSocketListener4SIBIndicationNotifications());

            SSAPMessage <SSAPBodySubscribeMessage> requestSubscribe  = SSAPMessageGenerator.GetInstance().GenerateSubscribeMessage(sessionKey, ONTOLOGY_NAME, 0, "", SSAPQueryTypeEnum.SQLLIKE);
            SSAPMessage <SSAPBodyReturnMessage>    responseSubscribe = client.Send(requestSubscribe);
            string subscriptionId = responseSubscribe.Body.Data.ToString();

            Assert.IsFalse(String.IsNullOrEmpty(subscriptionId));


            SSAPMessage <SSAPBodyOperationMessage> request  = SSAPMessageGenerator.GetInstance().GenerateInsertMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    response = client.Send(request);

            Thread.Sleep(5000);

            Assert.IsTrue(indicationRecived);

            SSAPMessage <SSAPBodyUnsubscribeMessage> requestUnsubscribe  = SSAPMessageGenerator.GetInstance().GenerateUnsubscribeMessage(sessionKey, ONTOLOGY_NAME, subscriptionId);
            SSAPMessage <SSAPBodyReturnMessage>      responseUnsubscribe = client.Send(requestUnsubscribe);

            Assert.IsTrue(responseUnsubscribe.Body.IsOk);

            Leave(sessionKey);
        }
예제 #3
0
        public string Join()
        {
            SSAPMessage <SSAPBodyJoinTokenMessage> requestJoin  = SSAPMessageGenerator.GetInstance().GenerateJoinByTokenMessage(TOKEN, KP_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    responseJoin = (SSAPMessage <SSAPBodyReturnMessage>)client.Send(requestJoin);
            string sessionKey = responseJoin.SessionKey;

            return(sessionKey);
        }
예제 #4
0
        public void TestBasic()
        {
            SSAPMessage <SSAPBodyJoinTokenMessage> request  = SSAPMessageGenerator.GetInstance().GenerateJoinByTokenMessage(TOKEN, KP_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    response = client.Send(request);
            string strResponse = response.ToJson();

            Assert.IsTrue(response.Body.IsOk);
            Assert.AreNotEqual(response.Body, null);
        }
예제 #5
0
        public void TestQusarQuery()
        {
            string sessionKey = Join();

            SSAPMessage <SSAPBodyQueryMessageQuasar> request = SSAPMessageGenerator.GetInstance().GenerateQueryMessageQusarSQL(sessionKey, ONTOLOGY_QUERY_SQLLIKE, 0, SSAPQueryResultFormat.JSON, "resultformat");

            SSAPMessage <SSAPBodyReturnMessage> response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);

            Leave(sessionKey);
        }
예제 #6
0
        public void TestJoinAndLeave()
        {
            SSAPMessage <SSAPBodyJoinTokenMessage> requestJoin  = SSAPMessageGenerator.GetInstance().GenerateJoinByTokenMessage(TOKEN, KP_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    responseJoin = client.Send(requestJoin);
            string sessionKey = responseJoin.SessionKey;

            Assert.IsTrue(responseJoin.Body.IsOk);

            SSAPMessage <SSAPBodyLeaveMessage>  requestLeave  = SSAPMessageGenerator.GetInstance().GenerateLeaveMessage(sessionKey);
            SSAPMessage <SSAPBodyReturnMessage> responseLeave = client.Send(requestLeave);

            Assert.IsTrue(responseLeave.Body.IsOk);
        }
예제 #7
0
        public void TestQuerySqlBDC()
        {
            string sessionKey = Join();

            SSAPMessage <SSAPBodyOperationMessage> request  = SSAPMessageGenerator.GetInstance().GenerateQueryMessage(sessionKey, null, "select * from Asset where identificacion='tweets_sofia'", SSAPQueryTypeEnum.BDC);
            SSAPMessage <SSAPBodyReturnMessage>    response = client.Send(request);

            JArray data = (JArray)response.Body.Data;

            Assert.IsTrue(response.Body.IsOk);

            Leave(sessionKey);
        }
예제 #8
0
        public void TestInsertNative()
        {
            string sessionKey = Join();

            SSAPMessage <SSAPBodyOperationMessage> request  = SSAPMessageGenerator.GetInstance().GenerateInsertMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);
            JObject data = (JObject)response.Body.Data;

            Assert.IsFalse(String.IsNullOrEmpty(data["_id"]["$oid"].Value <string>()));

            Leave(sessionKey);
        }
예제 #9
0
        public void TestError()
        {
            string sessionKey = Join();

            DateTime dt        = DateTime.Now;
            String   timeStamp = String.Format("{0:s}", dt);

            SSAPMessage <SSAPBodyErrorMessage>  request  = SSAPMessageGenerator.GetInstance().GenerateErrorMessage(KP, KP_INSTANCE, TOKEN, SSAPSeverityLevel.CRITICAL, "code", "message", timeStamp);
            SSAPMessage <SSAPBodyReturnMessage> response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);

            Leave(sessionKey);
        }
예제 #10
0
        public void TestUpdateSqlLike()
        {
            string sessionKey = Join();

            SSAPMessage <SSAPBodyOperationMessage> request  = SSAPMessageGenerator.GetInstance().GenerateUpdateMessage(sessionKey, ONTOLOGY_NAME, null, ONTOLOGY_UPDATE_SQLLIKE, SSAPQueryTypeEnum.SQLLIKE);
            SSAPMessage <SSAPBodyReturnMessage>    response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);
            JArray data = (JArray)response.Body.Data;

            Assert.IsFalse(String.IsNullOrEmpty(data[0]["_id"]["$oid"].Value <string>()));

            Leave(sessionKey);
        }
예제 #11
0
        public void TestCommand()
        {
            var sessionKey = Join();

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("atributo1", "valor1");
            args.Add("atributo2", "valor2");

            SSAPMessage <SSAPBodyCommandMessage> request  = SSAPMessageGenerator.GetInstance().GenerateCommandMessage(sessionKey, KP, KP_INSTANCE, SSAPCommandType.STATUS, args);
            SSAPMessage <SSAPBodyReturnMessage>  response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);

            Leave(sessionKey);
        }
예제 #12
0
        public void TestStatusNullDictionary()
        {
            string sessionKey = Join();

            DateTime dt        = DateTime.Now;//new DateTime();
            String   timeStamp = String.Format("{0:s}", dt);

            Dictionary <string, string> status = null;

            SSAPMessage <SSAPBodyStatusMessage> request  = SSAPMessageGenerator.GetInstance().GenerateStatusMessage(KP, KP_INSTANCE, TOKEN, status, timeStamp);
            SSAPMessage <SSAPBodyReturnMessage> response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);

            Leave(sessionKey);
        }
예제 #13
0
        public void TestUpdateNative()
        {
            string sessionKey = Join();

            SSAPMessage <SSAPBodyOperationMessage> requestInsert  = SSAPMessageGenerator.GetInstance().GenerateInsertMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    responseInsert = client.Send(requestInsert);

            SSAPMessage <SSAPBodyOperationMessage> requestUpdate  = SSAPMessageGenerator.GetInstance().GenerateUpdateMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_UPDATE, ONTOLOGY_UPDATE_WHERE, SSAPQueryTypeEnum.NATIVE);
            SSAPMessage <SSAPBodyReturnMessage>    responseUpdate = client.Send(requestUpdate);

            Assert.IsTrue(responseUpdate.Body.IsOk);
            JArray dataUpdate = (JArray)responseUpdate.Body.Data;

            Assert.IsFalse(String.IsNullOrEmpty(dataUpdate[0]["_id"]["$oid"].Value <string>()));

            Leave(sessionKey);
        }
예제 #14
0
        public void TestQuerySql()
        {
            string sessionKey = Join();

            SSAPMessage <SSAPBodyOperationMessage> requestInsert  = SSAPMessageGenerator.GetInstance().GenerateInsertMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_INSTANCE);
            SSAPMessage <SSAPBodyReturnMessage>    responseInsert = client.Send(requestInsert);

            SSAPMessage <SSAPBodyOperationMessage> request  = SSAPMessageGenerator.GetInstance().GenerateQueryMessage(sessionKey, ONTOLOGY_NAME, "select * from " + ONTOLOGY_NAME, SSAPQueryTypeEnum.SQLLIKE);
            SSAPMessage <SSAPBodyReturnMessage>    response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);
            JArray data = (JArray)response.Body.Data;

            Assert.IsFalse(String.IsNullOrEmpty(data[0]["_id"]["$oid"].Value <string>()));

            Leave(sessionKey);
        }
예제 #15
0
        public void TestBulk()
        {
            string sessionKey = Join();

            SSAPBulkMessage request = SSAPMessageGenerator.GetInstance().GenerateBulkMessage(sessionKey, ONTOLOGY_NAME);

            request.AddMessage(SSAPMessageGenerator.GetInstance().GenerateInsertMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_INSTANCE));
            request.AddMessage(SSAPMessageGenerator.GetInstance().GenerateInsertMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_INSTANCE));
            request.AddMessage(SSAPMessageGenerator.GetInstance().GenerateUpdateMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_UPDATE, ONTOLOGY_UPDATE_WHERE, SSAPQueryTypeEnum.NATIVE));
            request.AddMessage(SSAPMessageGenerator.GetInstance().GenerateUpdateMessage(sessionKey, ONTOLOGY_NAME, ONTOLOGY_UPDATE, ONTOLOGY_UPDATE_WHERE, SSAPQueryTypeEnum.NATIVE));
            SSAPMessage <SSAPBodyReturnMessage> response = (SSAPMessage <SSAPBodyReturnMessage>)client.Send(request);

            SSAPBodyBulkReturnMessage responseData = SSAPBodyBulkReturnMessage.FromJson(response.Body.Data.ToString());

            Assert.IsTrue(responseData.InsertSummary.ObjectsIds.Count > 0);
            Assert.IsTrue(responseData.UpdateSummary.ObjectsIds.Count > 0);

            Leave(sessionKey);
        }
예제 #16
0
        public void TestLocation()
        {
            string sessionKey = Join();

            DateTime dt        = DateTime.Now;//new DateTime();
            String   timeStamp = String.Format("{0:s}", dt);

            Random rnd = new Random();

            double lat   = (int)(rnd.NextDouble() * 50 + 35);
            double lon   = (int)(rnd.NextDouble() * 20 + -3);
            double alt   = (int)(rnd.NextDouble() * 50 + 35);
            double speed = (int)(rnd.NextDouble() * 100 + 0);

            SSAPMessage <SSAPBodyLocationMessage> request  = SSAPMessageGenerator.GetInstance().GenerateLocationMessage(KP, KP_INSTANCE, TOKEN, 1, lat, lon, alt, 1, speed, timeStamp);
            SSAPMessage <SSAPBodyReturnMessage>   response = client.Send(request);

            Assert.IsTrue(response.Body.IsOk);

            Leave(sessionKey);
        }
예제 #17
0
 public void Leave(string sessionKey)
 {
     SSAPMessage <SSAPBodyLeaveMessage>  requestLeave  = SSAPMessageGenerator.GetInstance().GenerateLeaveMessage(sessionKey);
     SSAPMessage <SSAPBodyReturnMessage> responseLeave = client.Send(requestLeave);
 }