1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "gtest/gtest.h"
24 #include <linux/limits.h>
27 #include "oic_malloc.h"
29 #include "cainterface.h"
30 #include "secureresourcemanager.h"
31 #include "securevirtualresourcetypes.h"
32 #include "srmresourcestrings.h"
33 #include "svcresource.h"
34 #include "srmtestcommon.h"
41 extern char * BinToSvcJSON(const OicSecSvc_t * svc);
42 extern OicSecSvc_t * JSONToSvcBin(const char * jsonStr);
43 extern void DeleteSVCList(OicSecSvc_t* svc);
48 static const char* JSON_FILE_NAME = "oic_unittest.json";
50 #define NUM_SVC_IN_JSON_DB (2)
53 // JSON Marshalling Tests
54 TEST(SVCResourceTest, JSONMarshallingTests)
56 char *jsonStr1 = ReadFile(JSON_FILE_NAME);
59 OicSecSvc_t * svc = JSONToSvcBin(jsonStr1);
60 EXPECT_TRUE(NULL != svc);
63 OicSecSvc_t * tempSvc = svc;
67 EXPECT_EQ(tempSvc->svct, ACCESS_MGMT_SERVICE);
69 tempSvc = tempSvc->next;
71 EXPECT_EQ(cnt, NUM_SVC_IN_JSON_DB);
73 char * jsonStr2 = BinToSvcJSON(svc);
74 EXPECT_TRUE(NULL != jsonStr2);