diff --git a/test/unittests/apiTypesV2/EntityVector_test.cpp b/test/unittests/apiTypesV2/EntityVector_test.cpp index 4db0283a27..6c3fd8660f 100644 --- a/test/unittests/apiTypesV2/EntityVector_test.cpp +++ b/test/unittests/apiTypesV2/EntityVector_test.cpp @@ -36,6 +36,8 @@ */ TEST(EntityVector, render) { + utInit(); + Entity* eP = new Entity(); std::string rendered; EntityVector eV; @@ -50,4 +52,6 @@ TEST(EntityVector, render) rendered = eV.toJson(NGSI_V2_NORMALIZED); eV.release(); + + utExit(); } diff --git a/test/unittests/apiTypesV2/Entity_test.cpp b/test/unittests/apiTypesV2/Entity_test.cpp index cb84e0b16f..01960cb6eb 100644 --- a/test/unittests/apiTypesV2/Entity_test.cpp +++ b/test/unittests/apiTypesV2/Entity_test.cpp @@ -86,10 +86,10 @@ TEST(Entity, check) */ TEST(Entity, checkV1) { - Entity* enP = new Entity(); - utInit(); + Entity* enP = new Entity(); + enP->id = ""; EXPECT_EQ(enP->check(BatchUpdateRequest), "entity id length: 0, min length supported: 1"); diff --git a/test/unittests/cache/SubscriptionCache_test.cpp b/test/unittests/cache/SubscriptionCache_test.cpp index 42092f539a..41a995ef3b 100644 --- a/test/unittests/cache/SubscriptionCache_test.cpp +++ b/test/unittests/cache/SubscriptionCache_test.cpp @@ -48,7 +48,6 @@ extern void setMongoConnectionForUnitTest(orion::DBClientBase _connection); */ TEST(cache, SubscriptionCache) { - LM_M(("In SubscriptionCache test")); utInit(); std::vector entityIdInfos; diff --git a/test/unittests/ngsi/AttributeList_test.cpp b/test/unittests/ngsi/AttributeList_test.cpp index 7470744f37..f4c9fdb2fa 100644 --- a/test/unittests/ngsi/AttributeList_test.cpp +++ b/test/unittests/ngsi/AttributeList_test.cpp @@ -37,11 +37,11 @@ */ TEST(AttributeList, ok) { + utInit(); + StringList al; std::string out; - const char* outfile1 = "ngsi.attributeList.ok.middle.json"; - - utInit(); + const char* outfile1 = "ngsi.attributeList.ok.middle.json"; out = al.toJson(); EXPECT_STREQ("[]", out.c_str()); diff --git a/test/unittests/ngsi/ContextAttribute_test.cpp b/test/unittests/ngsi/ContextAttribute_test.cpp index c13c8e83e4..8f4db3dbaa 100644 --- a/test/unittests/ngsi/ContextAttribute_test.cpp +++ b/test/unittests/ngsi/ContextAttribute_test.cpp @@ -37,11 +37,11 @@ */ TEST(ContextAttribute, checkOne) { - ContextAttribute* caP = new ContextAttribute(); - std::string res; - utInit(); + ContextAttribute* caP = new ContextAttribute(); + std::string res; + caP->name = ""; res = caP->check(false); EXPECT_EQ(res, "attribute name length: 0, min length supported: 1"); diff --git a/test/unittests/ngsi/ContextElementResponseVector_test.cpp b/test/unittests/ngsi/ContextElementResponseVector_test.cpp index fae79cf414..c892f347a9 100644 --- a/test/unittests/ngsi/ContextElementResponseVector_test.cpp +++ b/test/unittests/ngsi/ContextElementResponseVector_test.cpp @@ -38,13 +38,13 @@ */ TEST(ContextElementResponseVector, render) { + utInit(); + ContextElementResponseVector cerv; ContextElementResponse cer; std::string out; - std::vector emptyV; - - utInit(); + std::vector emptyV; out = cerv.toJson(NGSI_V2_NORMALIZED, emptyV, false, emptyV, NULL); EXPECT_STREQ("[]", out.c_str()); diff --git a/test/unittests/ngsi/ContextElementResponse_test.cpp b/test/unittests/ngsi/ContextElementResponse_test.cpp index 2785a20914..2a5f21cc32 100644 --- a/test/unittests/ngsi/ContextElementResponse_test.cpp +++ b/test/unittests/ngsi/ContextElementResponse_test.cpp @@ -37,23 +37,23 @@ */ TEST(ContextElementResponse, render) { + utInit(); + ContextElementResponse cer; const char* outfile = "ngsi.contextElementResponse.render.middle.json"; std::string out; std::vector emptyV; + + cer.entity.id = "ID"; + cer.entity.type = "Type"; + cer.entity.isPattern = "false"; - utInit(); - - cer.entity.id = "ID"; - cer.entity.type = "Type"; - cer.entity.isPattern = "false"; - - cer.statusCode.fill(SccOk, "details"); + cer.statusCode.fill(SccOk, "details"); - out = cer.toJson(NGSI_V2_NORMALIZED, emptyV, false, emptyV, NULL);; - EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'"; - EXPECT_STREQ(expectedBuf, out.c_str()); + out = cer.toJson(NGSI_V2_NORMALIZED, emptyV, false, emptyV, NULL);; + EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'"; + EXPECT_STREQ(expectedBuf, out.c_str()); - utExit(); + utExit(); } diff --git a/test/unittests/ngsi/EntityId_test.cpp b/test/unittests/ngsi/EntityId_test.cpp index afc819b589..c0d278914d 100644 --- a/test/unittests/ngsi/EntityId_test.cpp +++ b/test/unittests/ngsi/EntityId_test.cpp @@ -34,11 +34,11 @@ */ TEST(EntityId, render) { + utInit(); + EntityId eId; std::string out; - const char* outfile1 = "ngsi.entityId.render.middle.json"; - - utInit(); + const char* outfile1 = "ngsi.entityId.render.middle.json"; out = eId.toJson(); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; diff --git a/test/unittests/ngsi/ErrorCode_test.cpp b/test/unittests/ngsi/ErrorCode_test.cpp index 00ab4da52d..c2148c6d52 100644 --- a/test/unittests/ngsi/ErrorCode_test.cpp +++ b/test/unittests/ngsi/ErrorCode_test.cpp @@ -34,12 +34,12 @@ */ TEST(ErrorCode, render) { + utInit(); + ErrorCode e1; std::string out; const char* outfile1 = "ngsi.errorCode.render1.middle.json"; - utInit(); - out = e1.render(); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); @@ -55,6 +55,8 @@ TEST(ErrorCode, render) */ TEST(ErrorCode, check) { + utInit(); + ErrorCode e1(0, "REASON", "DETAILS"); ErrorCode e2(200, "", "DETAILS"); ErrorCode e3(200, "REASON", "DETAILS"); @@ -63,8 +65,6 @@ TEST(ErrorCode, check) std::string expected2 = "no reason phrase"; std::string expected3 = "OK"; - utInit(); - rendered = e1.check(RegisterContext, "", "", 0); EXPECT_STREQ(expected1.c_str(), rendered.c_str()); diff --git a/test/unittests/ngsi/MetadataVector_test.cpp b/test/unittests/ngsi/MetadataVector_test.cpp index ad31112349..95fcba09fa 100644 --- a/test/unittests/ngsi/MetadataVector_test.cpp +++ b/test/unittests/ngsi/MetadataVector_test.cpp @@ -34,6 +34,8 @@ */ TEST(MetadataVector, render) { + utInit(); + Metadata m("Name", "Type", "Value"); Metadata m2("Name2", "Type2", "Value2"); MetadataVector mV; @@ -41,8 +43,6 @@ TEST(MetadataVector, render) const char* outfile2 = "ngsi.metadataVector.render3.middle.json"; std::string out; - utInit(); - mV.push_back(&m); std::vector metadataFilter; diff --git a/test/unittests/ngsi/Metadata_test.cpp b/test/unittests/ngsi/Metadata_test.cpp index 96b127a511..a3a6a90c08 100644 --- a/test/unittests/ngsi/Metadata_test.cpp +++ b/test/unittests/ngsi/Metadata_test.cpp @@ -34,12 +34,12 @@ */ TEST(Metadata, constructor) { + utInit(); + Metadata m1; Metadata m2("n2", "t2", "v2"); Metadata m3(&m2); - utInit(); - EXPECT_EQ("", m1.name); EXPECT_EQ("n2", m2.name); EXPECT_EQ("n2", m3.name); @@ -56,6 +56,8 @@ TEST(Metadata, constructor) */ TEST(Metadata, render) { + utInit(); + std::string out; Metadata m1; Metadata m2("Name", "Integer", "19"); @@ -63,8 +65,6 @@ TEST(Metadata, render) const char* outfile1 = "ngsi.metdata.render1.middle.json"; const char* outfile2 = "ngsi.metdata.render2.middle.json"; - utInit(); - out = m1.toJson(); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); diff --git a/test/unittests/ngsi/ScopeVector_test.cpp b/test/unittests/ngsi/ScopeVector_test.cpp index 88c923cd72..cc9cc887bc 100644 --- a/test/unittests/ngsi/ScopeVector_test.cpp +++ b/test/unittests/ngsi/ScopeVector_test.cpp @@ -35,14 +35,14 @@ */ TEST(ScopeVector, getAndSize) { + utInit(); + ScopeVector sV; Scope scope0("Type", "Value0"); Scope scope1("Type", "Value1"); Scope scope2("Type", "Value2"); Scope* scopeP; - utInit(); - sV.push_back(&scope0); sV.push_back(&scope1); sV.push_back(&scope2); diff --git a/test/unittests/ngsi/StatusCode_test.cpp b/test/unittests/ngsi/StatusCode_test.cpp index 783b41b1d9..144e437681 100644 --- a/test/unittests/ngsi/StatusCode_test.cpp +++ b/test/unittests/ngsi/StatusCode_test.cpp @@ -37,13 +37,13 @@ */ TEST(StatusCode, render) { + utInit(); + StatusCode sc1; StatusCode sc2; std::string out; const char* outfile1 = "ngsi.statusCode.render4.middle.json"; - utInit(); - sc2.fill(SccOk, "DETAILS"); out = sc2.toJson(); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; @@ -62,13 +62,13 @@ TEST(StatusCode, render) */ TEST(StatusCode, fill) { + utInit(); + StatusCode sc; StatusCode sc2; StatusCode ec; std::string out; - utInit(); - sc.fill(SccForbidden, "D"); EXPECT_EQ(sc.code, SccForbidden); EXPECT_STREQ(sc.reasonPhrase.c_str(), "Forbidden"); diff --git a/test/unittests/ngsi/SubscriptionId_test.cpp b/test/unittests/ngsi/SubscriptionId_test.cpp deleted file mode 100644 index 8d6422affb..0000000000 --- a/test/unittests/ngsi/SubscriptionId_test.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -* -* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U -* -* This file is part of Orion Context Broker. -* -* Orion Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* iot_support at tid dot es -* -* Author: Ken Zangelin -*/ -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "ngsi/SubscriptionId.h" - -#include "unittest.h" - - - -/* **************************************************************************** -* -* constructors - -*/ -TEST(SubscriptionId, constructors) -{ - SubscriptionId s1; - SubscriptionId s2("subId"); - - utInit(); - - EXPECT_EQ("", s1.string); - EXPECT_EQ("subId", s2.string); - - utExit(); -} - - - -/* **************************************************************************** -* -* check - -*/ -TEST(SubscriptionId, check) -{ - SubscriptionId sId; - std::string checked; - - utInit(); - - sId.set("SUB_123"); - checked = sId.check(); - EXPECT_STREQ("bad length - 24 chars expected", checked.c_str()); - - sId.set("SUB_12345678901234567890"); - checked = sId.check(); - EXPECT_STREQ("invalid char in ID string", checked.c_str()); - - sId.set("012345678901234567890123"); - checked = sId.check(); - EXPECT_STREQ("OK", checked.c_str()); - - utExit(); -} - - - -/* **************************************************************************** -* -* setGetAndIsEmpty - -*/ -TEST(SubscriptionId, setGetAndIsEmpty) -{ - SubscriptionId sId; - std::string out; - - utInit(); - - sId.set("SUB_123"); - out = sId.get(); - EXPECT_STREQ("SUB_123", out.c_str()); - - EXPECT_FALSE(sId.isEmpty()); - sId.set(""); - EXPECT_TRUE(sId.isEmpty()); - - utExit(); -} - diff --git a/test/unittests/ngsi10/NotifyContextRequest_test.cpp b/test/unittests/ngsi10/NotifyContextRequest_test.cpp index b4c8084c43..0241489575 100644 --- a/test/unittests/ngsi10/NotifyContextRequest_test.cpp +++ b/test/unittests/ngsi10/NotifyContextRequest_test.cpp @@ -40,14 +40,14 @@ */ TEST(NotifyContextRequest, json_render) { + utInit(); + const char* filename1 = "ngsi10.notifyContextRequest.jsonRender1.valid.json"; const char* filename2 = "ngsi10.notifyContextRequest.jsonRender2.valid.json"; const char* filename3 = "ngsi10.notifyContextRequest.jsonRender3.valid.json"; NotifyContextRequest* ncrP; ContextElementResponse* cerP; - std::string rendered; - - utInit(); + std::string rendered; // Preparation ncrP = new NotifyContextRequest(); diff --git a/test/unittests/parse/CompoundValueNode_test.cpp b/test/unittests/parse/CompoundValueNode_test.cpp index f4e73827e7..d619427556 100644 --- a/test/unittests/parse/CompoundValueNode_test.cpp +++ b/test/unittests/parse/CompoundValueNode_test.cpp @@ -38,12 +38,12 @@ */ TEST(CompoundValueNode, tree) { + utInit(); + orion::CompoundValueNode* tree = new orion::CompoundValueNode(orion::ValueTypeObject); orion::CompoundValueNode* vec; orion::CompoundValueNode* vecItem; - char* name = (char*) "vecItem"; - - utInit(); + char* name = (char*) "vecItem"; lmTraceLevelSet(LmtCompoundValueAdd, true); vec = tree->add(orion::ValueTypeVector, "vec", ""); diff --git a/test/unittests/parse/compoundValue_test.cpp b/test/unittests/parse/compoundValue_test.cpp index fee9522ba5..fca42ac720 100644 --- a/test/unittests/parse/compoundValue_test.cpp +++ b/test/unittests/parse/compoundValue_test.cpp @@ -37,11 +37,11 @@ */ TEST(compoundValue, tenCompounds) { + utInit(); + ParseData reqData; UpdateContextRequest* upcrP; - std::string rendered; - - utInit(); + std::string rendered; upcrP = &reqData.upcr.res; rendered = upcrP->toJsonV1(); diff --git a/test/unittests/rest/restReply_test.cpp b/test/unittests/rest/restReply_test.cpp index 86dc9c1208..203b8c351c 100644 --- a/test/unittests/rest/restReply_test.cpp +++ b/test/unittests/rest/restReply_test.cpp @@ -45,10 +45,10 @@ #define TEST_SIZE (4 * 1024 * 1024) TEST(restReply, MHD_create_response_from_data_error) { - ConnectionInfo ci("/ngsi/XXX", "GET", "1.1"); - char* answer = (char*) malloc(TEST_SIZE); - utInit(); + + ConnectionInfo ci("/ngsi/XXX", "GET", "1.1"); + char* answer = (char*) malloc(TEST_SIZE); if (answer != NULL) {