{
if (m_syncResource == nullptr)
{
- std::cout << "m_syncResource is null" << std::endl;
return;
}
private:
static void onPost(const OC::HeaderOptions &/*headerOption*/,
- const OC::OCRepresentation & /*rep*/ , const int eCode)
+ const OC::OCRepresentation & /*rep*/ , const int /*eCode*/)
{
- std::cout << __func__ << " result : " << eCode << std::endl;
}
void findResultCallback(std::shared_ptr<OC::OCResource> resource)
{
-
- std::cout << __func__ << " " << resource->host() << std::endl;
-
if(resource->uri() == "/notification")
{
resource->get(OC::QueryParamsMap(),
}
}
void onGet(const OC::HeaderOptions &/*headerOption*/,
- const OC::OCRepresentation & rep , const int eCode,
+ const OC::OCRepresentation & /*rep*/ , const int /*eCode*/,
std::shared_ptr<OC::OCResource> resource)
{
- std::cout << __func__ << " " << rep.getHost() << " result : " << eCode << std::endl;
-
OC::QueryParamsMap map;
map.insert(std::pair<std::string,std::string>(std::string("consumerid"),
std::string("123456789012345678901234567890123456")));
try
{
- std::cout << "resourc : host " << resource->host() << std::endl;
- std::cout << "resourc : uri " << resource->uri() << std::endl;
- std::cout << " resource->connectivityType() "
- << resource->connectivityType() << std::endl;
- std::cout << "resourc : getResourceInterfaces "
- << resource->getResourceInterfaces()[0] << std::endl;
- std::cout << "resourc : getResourceTypes "
- << resource->getResourceTypes()[0] << std::endl;
-
std::vector<std::string> rts{"oic.r.notification"};
m_msgResource
}
void onObserve(const OC::HeaderOptions &/*headerOption*/,
- const OC::OCRepresentation &rep , const int &eCode, const int &,
+ const OC::OCRepresentation &rep , const int & /*eCode*/, const int &,
std::shared_ptr<OC::OCResource> )
{
- std::cout << __func__ << " " << rep.getHost() << " result : " << eCode;
- std::cout << " uri : " << rep.getUri() << std::endl;
-
if (rep.getUri() == "/notification/message" && rep.hasAttribute("MESSAGE_ID")
&& rep.getValue<int>("MESSAGE_ID") != 1)
{
- std::cout << "ID : " << rep.getValue<int>("ID") << std::endl;
- std::cout << "TITLE : " << rep.getValueToString("TITLE") << std::endl;
- std::cout << "CONTENT : " << rep.getValueToString("CONTENT") << std::endl;
m_messageFunc(int(rep.getValue<int>("MESSAGE_ID")),
std::string(rep.getValueToString("TITLE")),
std::string(rep.getValueToString("CONTENT")),
}
else if (rep.getUri() == "/notification/sync")
{
- std::cout << "else if (rep.getUri() == sync) " << std::endl;
m_syncFunc(int(rep.getValue<int>("STATE")), int(rep.getValue<int>("ID")));
}
}
void onTopicGet(const OC::HeaderOptions &/*headerOption*/,
- const OC::OCRepresentation & rep , const int eCode,
- std::shared_ptr<OC::OCResource> resource)
+ const OC::OCRepresentation & /*rep*/ , const int /*eCode*/,
+ std::shared_ptr<OC::OCResource> /*resource*/)
{
- //TO-DO using this function.
- (void) rep;
- (void) eCode;
- (void) resource;
- std::cout << "onTopicGet()" << std::endl;
}
OCStackResult msgResourceCancelObserve(OC::QualityOfService qos)
static void NSRequestedSubscribeCallbackEmpty(NSConsumer *)
{
- std::cout << __func__ << std::endl;
}
static void NSSyncCallbackEmpty(NSSyncInfo *)
{
- std::cout << __func__ << std::endl;
}
static void NSMessageCallbackFromConsumerEmpty(
const int &, const std::string &, const std::string &, const std::string &)
{
- std::cout << __func__ << std::endl;
}
static void NSSyncCallbackFromConsumerEmpty(int, int)
{
- std::cout << __func__ << std::endl;
}
protected:
mocks.OnCallFunc(NSRequestedSubscribeCallbackEmpty).Do(
[](NSConsumer * consumer)
{
- std::cout << "NSRequestedSubscribeCallback" << std::endl;
g_consumerID = strdup(consumer->consumerId);
responseCon.notify_all();
});
{
if (id == msgID)
{
- std::cout << "This function never call" << std::endl;
expectTrue = false;
}
});
mocks.ExpectCallFunc(NSMessageCallbackFromConsumerEmpty).Do(
[&msgID](const int &id, const std::string&, const std::string&, const std::string&)
{
- std::cout << "id : " << id << std::endl;
if (id == msgID)
{
- std::cout << "ExpectCallNotifyOnConsumerByAcceptIsTrue" << std::endl;
responseCon.notify_all();
}
});
mocks.ExpectCallFunc(NSSyncCallbackFromConsumerEmpty).Do(
[& id](int & type, int &syncId)
{
- std::cout << "NSSyncCallbackEmpty" << std::endl;
- if (syncId == id &&
- type == NS_SYNC_READ)
+ if (syncId == id && type == NS_SYNC_READ)
{
- std::cout << "ExpectCallbackSyncOnReadFromConsumer" << std::endl;
responseCon.notify_all();
}
});
mocks.ExpectCallFunc(NSSyncCallbackEmpty).Do(
[& id](NSSyncInfo * sync)
{
- std::cout << "NSSyncCallbackEmpty" << std::endl;
if ((int)sync->messageId == id && sync->state == NS_SYNC_READ)
{
- std::cout << "ExpectCallbackSyncOnReadFromConsumer" << std::endl;
responseCon.notify_all();
}
});
if(!topics)
{
- printf("topic is NULL\n");
isSame = false;
}
else
std::string compStr(iter->topicName);
std::string compStr2(iter->next->topicName);
- printf("str = %s, compStr = %s\n", str.c_str(), iter->topicName);
- printf("str2 = %s, compStr2 = %s\n", str2.c_str(), iter->next->topicName);
-
if(str.compare(compStr) == 0 && str2.compare(compStr2) == 0)
{
isSame = true;
if(!topics)
{
- printf("topic is NULL\n");
isSame = false;
}
else
NSTopicLL * iter = topics;
std::string compStr(iter->topicName);
- printf("str = %s, compStr = %s\n", str.c_str(), iter->topicName);
-
if(str.compare(compStr) == 0)
{
isSame = true;
if(!topics)
{
- printf("topic is NULL\n");
isSame = false;
}
else
NSTopicLL * firstData = topics;
NSTopicLL * secondData = firstData->next;
- printf("str = %s, compStr = %s, state = %d\n", str.c_str(), firstData->topicName,
- (int)firstData->state);
-
- printf("str2 = %s, compStr = %s, state = %d\n", str2.c_str(), secondData->topicName,
- (int)secondData->state);
-
if(str.compare(firstData->topicName) == 0 && str2.compare(secondData->topicName) == 0
&& ((int)firstData->state) == 1 && ((int)secondData->state) == 0)
{
if(!topics)
{
- printf("topic is NULL\n");
isSame = false;
}
else
NSTopicLL * firstData = topics;
NSTopicLL * secondData = firstData->next;
- printf("str = %s, compStr = %s, state = %d\n", str.c_str(), firstData->topicName,
- (int)firstData->state);
-
- printf("str2 = %s, compStr = %s, state = %d\n", str2.c_str(), secondData->topicName,
- (int)secondData->state);
-
if(str.compare(firstData->topicName) == 0 && str2.compare(secondData->topicName) == 0
&& ((int)firstData->state) == 0 && ((int)secondData->state) == 1)
{
responseCon.wait_for(lock, std::chrono::milliseconds(500));
}
+TEST_F(NotificationProviderTest, ExpectFailAcceptSubscription)
+{
+ NSResult result;
+ result = NS_SUCCESS;
+ result = NSAcceptSubscription(NULL, true);
+ result = NSAcceptSubscription("\0", true);
+
+ EXPECT_EQ(result, NS_FAIL);
+}
+
+TEST_F(NotificationProviderTest, ExpectFailSendMessage)
+{
+ NSResult result;
+ result = NS_SUCCESS;
+ result = NSSendMessage(NULL);
+
+ EXPECT_EQ(result, NS_FAIL);
+}
+
+TEST_F(NotificationProviderTest, ExpectFailRegisterTopic)
+{
+ NSResult result;
+ result = NS_SUCCESS;
+ result = NSProviderRegisterTopic(NULL);
+ result = NSProviderRegisterTopic("\0");
+
+ EXPECT_EQ(result, NS_FAIL);
+}
+
+TEST_F(NotificationProviderTest, ExpectFailUnregisterTopic)
+{
+ NSResult result;
+ result = NS_SUCCESS;
+ result = NSProviderUnregisterTopic(NULL);
+ result = NSProviderUnregisterTopic("\0");
+
+ EXPECT_EQ(result, NS_FAIL);
+}
+
+TEST_F(NotificationProviderTest, ExpectFailGetConsumerTopics)
+{
+ NSTopicLL topic;
+ NSTopicLL * topicLL = &topic;
+
+ topicLL = NSProviderGetConsumerTopics(NULL);
+ topicLL = NSProviderGetConsumerTopics("\0");
+
+ EXPECT_EQ(topicLL, (NSTopicLL *)NULL);
+}
+
+TEST_F(NotificationProviderTest, ExpectFailSetConsumerTopics)
+{
+ NSResult result;
+ result = NS_SUCCESS;
+ result = NSProviderSetConsumerTopic(NULL, NULL);
+ result = NSProviderSetConsumerTopic(NULL, "\0");
+ result = NSProviderSetConsumerTopic("\0", NULL);
+ result = NSProviderSetConsumerTopic("\0", "\0");
+ result = NSProviderSetConsumerTopic("abc", NULL);
+ result = NSProviderSetConsumerTopic(NULL, "abc");
+ result = NSProviderSetConsumerTopic("abc", "\0");
+ result = NSProviderSetConsumerTopic("\0", "abc");
+
+ EXPECT_EQ(result, NS_FAIL);
+}
+
+TEST_F(NotificationProviderTest, ExpectFailUnsetConsumerTopics)
+{
+ NSResult result;
+ result = NS_SUCCESS;
+ result = NSProviderUnsetConsumerTopic(NULL, NULL);
+ result = NSProviderUnsetConsumerTopic(NULL, "\0");
+ result = NSProviderUnsetConsumerTopic("\0", NULL);
+ result = NSProviderUnsetConsumerTopic("\0", "\0");
+ result = NSProviderUnsetConsumerTopic("abc", NULL);
+ result = NSProviderUnsetConsumerTopic(NULL, "abc");
+ result = NSProviderUnsetConsumerTopic("abc", "\0");
+ result = NSProviderUnsetConsumerTopic("\0", "abc");
+
+ EXPECT_EQ(result, NS_FAIL);
+}
+
TEST_F(NotificationProviderTest, CancelObserves)
{
bool ret = g_consumerSimul.cancelObserves();