+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
#define private public
#include <gtest/gtest.h>
#include <iostream>
-#include "ResourceClient.h"
+#include "RCSDiscoveryManager.h"
+#include "RCSRemoteResourceObject.h"
#include "RCSResourceObject.h"
#include "OCPlatform.h"
+#include "RCSAddress.h"
#define RESOURCEURI "/a/TemperatureSensor"
#define RESOURCETYPE "Resource.Hosting"
bool cbresult = false;
std::string uri = "/oic/res?rt=Resource.Hosting";
-std::shared_ptr<RemoteResourceObject> object;
-DiscoveryManager *manager = DiscoveryManager::getInstance();
+std::shared_ptr<RCSRemoteResourceObject> object;
+RCSDiscoveryManager*manager = RCSDiscoveryManager::getInstance();
ResourceState receivedResourceState;
RCSResourceAttributes receivedResourceAttributes;
RCSResourceObject::Ptr server;
receivedResourceAttributes = attributes;
}
-void onResourceDiscoveredCallback(std::shared_ptr<RemoteResourceObject> receivedObject)
+void onResourceDiscoveredCallback(std::shared_ptr<RCSRemoteResourceObject> receivedObject)
{
std::cout << "Resource discovered" << std::endl;
object = receivedObject;
TEST(ResourceClientTest, testDiscoverResourcePass)
{
createResource();
- DiscoveryManager *instance = DiscoveryManager::getInstance();
+ RCSDiscoveryManager *instance = RCSDiscoveryManager::getInstance();
cbresult = false;
-
- instance->discoverResource("", uri, CT_DEFAULT, &onResourceDiscoveredCallback);
+ RCSAddress rcsAddress = RCSAddress::multicast();
+ instance->discoverResource(rcsAddress, uri , &onResourceDiscoveredCallback);
sleep(2);
EXPECT_TRUE(object != NULL);
destroyResource();
TEST(ResourceClientTest, testIsMonitoring)
{
createResource();
- manager->DiscoveryManager::discoverResource("", uri, CT_DEFAULT, &onResourceDiscoveredCallback);
+ RCSAddress rcsAddress = RCSAddress::multicast();
+ manager->RCSDiscoveryManager::discoverResource(rcsAddress, uri , &onResourceDiscoveredCallback);
sleep(1);
destroyResource();
EXPECT_FALSE(object->isMonitoring());
TEST(ResourceClientTest, testGetInstance)
{
createResource();
- DiscoveryManager *instance = DiscoveryManager::getInstance();
+ RCSDiscoveryManager *instance = RCSDiscoveryManager::getInstance();
EXPECT_TRUE(instance != NULL);
destroyResource();
}
TEST(ResourceClientTest, testDiscoverResourceEmptyResource)
{
createResource();
- DiscoveryManager *instance = DiscoveryManager::getInstance();
- EXPECT_THROW(instance->discoverResource("", "", CT_DEFAULT, &onResourceDiscoveredCallback),
+ RCSDiscoveryManager *instance = RCSDiscoveryManager::getInstance();
+ RCSAddress rcsAddress = RCSAddress::multicast();
+ EXPECT_THROW(instance->discoverResource(rcsAddress, "", &onResourceDiscoveredCallback),
InvalidParameterException);
destroyResource();
}
TEST(ResourceClientTest, testDiscoverResourceEmptyCallback)
{
createResource();
- DiscoveryManager *instance = DiscoveryManager::getInstance();
- EXPECT_THROW(instance->discoverResource("", uri, CT_DEFAULT, NULL), InvalidParameterException);
+ RCSDiscoveryManager *instance = RCSDiscoveryManager::getInstance();
+ RCSAddress rcsAddress = RCSAddress::multicast();
+ EXPECT_THROW(instance->discoverResource(rcsAddress, uri , NULL), InvalidParameterException);
destroyResource();
object->stopMonitoring();
}