resource container unit tests, updates for container
authorMinji Park <minjii.park@samsung.com>
Tue, 7 Jul 2015 05:41:35 +0000 (14:41 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 8 Jul 2015 01:24:14 +0000 (01:24 +0000)
- unit tests for resource container
- update SConscript
- update bundleinfo and configuration in container

Change-Id: I0c92b15cb1229e5f16a7a7db18aab3cc32778bcc
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1555
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
12 files changed:
service/resource-manipulation/modules/resourceContainer/SConscript
service/resource-manipulation/modules/resourceContainer/examples/ResourceContainerConfig.xml
service/resource-manipulation/modules/resourceContainer/include/internal/Configuration.h
service/resource-manipulation/modules/resourceContainer/src/BundleInfoInternal.cpp
service/resource-manipulation/modules/resourceContainer/src/Configuration.cpp
service/resource-manipulation/modules/resourceContainer/src/ResourceContainerBundleAPI.cpp
service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerInvalidConfig.xml [new file with mode: 0644]
service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerTest.cpp [new file with mode: 0644]
service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerTestConfig.xml [new file with mode: 0644]
service/resource-manipulation/modules/resourceContainer/unittests/SConscript [new file with mode: 0644]
service/resource-manipulation/modules/resourceContainer/unittests/TestBundle/include/TestBundleActivator.h [new file with mode: 0644]
service/resource-manipulation/modules/resourceContainer/unittests/TestBundle/src/TestBundleActivator.cpp [new file with mode: 0644]

index 71afb5d..b1eb87a 100644 (file)
@@ -108,6 +108,10 @@ hue_resource_bundle_src = [ Glob(HUE_RESOURCE_BUNDLE_DIR + 'src/*.cpp'), Glob('s
 HueBundle = hue_resource_bundle_env.SharedLibrary('HueBundle', hue_resource_bundle_src)
 hue_resource_bundle_env.InstallTarget(HueBundle, 'libHueBundle')
 
+######################################################################
+# build resource container unit tests
+######################################################################
+SConscript('unittests/SConscript')
 
 ######################################################################
 # Build Container Test
index e8910d1..a302471 100644 (file)
@@ -2,12 +2,12 @@
 <container>      
     <bundle>
         <id>oic.bundle.discomfortIndexSensor</id>
-        <path>libSampleBundle.so</path>
+        <path>libSoftSensorBundle.so</path>
         <version>1.0.0</version>
         <resources>
             <resourceInfo>
                 <name>DiscomfortIndexSensor1</name>
-                               <resourceType>core.softsensor</resourceType>
+                               <resourceType>oic.softsensor</resourceType>
                 <attributes>
                   <attribute>
                     <name>version</name>       
index 76aa663..9f9872c 100644 (file)
@@ -39,6 +39,7 @@ namespace OIC
     namespace Service
     {
         typedef vector< map< string, string > > configInfo;
+
         struct resourceInfo
         {
             string name;
@@ -47,16 +48,15 @@ namespace OIC
             string address;
             map< string, vector< map< string, string > > > resourceProperty;
         };
+
         class Configuration
         {
             public:
-
-
-
                 Configuration();
                 Configuration(string configFile);
                 ~Configuration();
 
+                bool isLoaded();
                 void getConfiguredBundles(configInfo *configOutput);
                 void getBundleConfiguration(string bundleId, configInfo *configOutput);
                 void getResourceConfiguration(string bundleId, vector< resourceInfo > *configOutput);
@@ -65,6 +65,7 @@ namespace OIC
                 void getConfigDocument(string pathConfigFile);
                 void getCurrentPath(string *pPath);
 
+                bool m_loaded;
                 string m_pathConfigFile;
                 string m_strConfigData;
                 rapidxml::xml_document< char > m_xmlDoc;
index eadd3ce..eb07d02 100644 (file)
@@ -27,12 +27,16 @@ namespace OIC
 
         BundleInfoInternal::BundleInfoInternal()
         {
-
+            m_activator = nullptr;
+            m_deactivator = nullptr;
+            m_bundleHandle = nullptr;
         }
 
         BundleInfoInternal::~BundleInfoInternal()
         {
-
+            m_activator = nullptr;
+            m_deactivator = nullptr;
+            m_bundleHandle = nullptr;
         }
 
         void BundleInfoInternal::setID(string id)
@@ -109,7 +113,7 @@ namespace OIC
             m_bundleHandle = handle;
         }
 
-        voidBundleInfoInternal::getBundleHandle()
+        void *BundleInfoInternal::getBundleHandle()
         {
             return m_bundleHandle;
         }
@@ -164,11 +168,13 @@ namespace OIC
             return m_java_activator_class;
         }*/
 
-        void BundleInfoInternal::setJavaBundleActivatorObject(jobject activator_object){
+        void BundleInfoInternal::setJavaBundleActivatorObject(jobject activator_object)
+        {
             m_java_activator_object = activator_object;
         }
 
-        jobject BundleInfoInternal::getJavaBundleActivatorObject(){
+        jobject BundleInfoInternal::getJavaBundleActivatorObject()
+        {
             return m_java_activator_object;
         }
 
index 2ef2c01..c292e33 100644 (file)
@@ -43,10 +43,12 @@ namespace OIC
 
         Configuration::Configuration()
         {
+            m_loaded = false;
         }
 
         Configuration::Configuration(string configFile)
         {
+            m_loaded = false;
 
             getCurrentPath(&m_pathConfigFile);
             m_pathConfigFile.append("/");
@@ -59,6 +61,11 @@ namespace OIC
         {
         }
 
+        bool Configuration::isLoaded()
+        {
+            return m_loaded;
+        }
+
         void Configuration::getConfiguredBundles(configInfo *configOutput)
         {
             rapidxml::xml_node< char > *bundle;
@@ -68,7 +75,7 @@ namespace OIC
 
             try
             {
-                //cout << "Name of first node is: " << xmlDoc.first_node()->name() << endl;
+                //cout << "Name of first node is: " << m_xmlDoc.first_node()->name() << endl;
 
                 for (bundle = m_xmlDoc.first_node()->first_node("bundle"); bundle; bundle = bundle->next_sibling())
                 {
@@ -111,23 +118,24 @@ namespace OIC
                 {
                     // <id>
                     strBundleId = bundle->first_node("id")->value();
-                    bundleConfigMap.insert(std::make_pair("id", trim_both(strBundleId)));
 
                     if (!strBundleId.compare(bundleId))
                     {
+                        bundleConfigMap.insert(std::make_pair("id", trim_both(strBundleId)));
+
                         // <path>
                         strPath = bundle->first_node("path")->value();
-                        bundleConfigMap.insert(std::make_pair("id", trim_both(strPath)));
+                        bundleConfigMap.insert(std::make_pair("path", trim_both(strPath)));
 
                         // <version>
                         strVersion = bundle->first_node("version")->value();
-                        bundleConfigMap.insert(std::make_pair("id", trim_both(strVersion)));
+                        bundleConfigMap.insert(std::make_pair("version", trim_both(strVersion)));
+
+                        configOutput->push_back(bundleConfigMap);
 
                         break;
                     }
                 }
-
-                configOutput->push_back(bundleConfigMap);
             }
             catch (rapidxml::parse_error &e)
             {
@@ -209,7 +217,6 @@ namespace OIC
                 std::cout << "xml parsing failed !!" << std::endl;
                 std::cout << e.what() << std::endl;
             }
-
         }
 
         void Configuration::getConfigDocument(std::string pathConfigFile)
@@ -232,7 +239,7 @@ namespace OIC
                 try
                 {
                     m_xmlDoc.parse< 0 >((char *)m_strConfigData.c_str());
-
+                    m_loaded = true;
                 }
                 catch (rapidxml::parse_error &e)
                 {
index 2a78c9d..ad47a28 100644 (file)
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "ResourceContainerBundleAPI.h"
+#include "ResourceContainerImpl.h"
 
 using namespace OIC::Service;
 
-namespace OIC{
-    namespace Service{
+namespace OIC
+{
+    namespace Service
+    {
 
         ResourceContainerBundleAPI::ResourceContainerBundleAPI()
         {
@@ -35,5 +38,9 @@ namespace OIC{
 
         }
 
+        ResourceContainerBundleAPI *ResourceContainerBundleAPI::getInstance()
+        {
+            return (ResourceContainerBundleAPI *)ResourceContainerImpl::getImplInstance();
+        }
     }
 }
diff --git a/service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerInvalidConfig.xml b/service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerInvalidConfig.xml
new file mode 100644 (file)
index 0000000..07f42b8
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<container>      
+    <bundle>
+        <id>oic.bundle.test</id>
+        <path>libTestBundle.so</path>
+        <version>1.0.0</version>
+    <!--</bundle>-->
+</container>
\ No newline at end of file
diff --git a/service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerTest.cpp b/service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerTest.cpp
new file mode 100644 (file)
index 0000000..51f610b
--- /dev/null
@@ -0,0 +1,249 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include <gtest/gtest.h>
+#include <HippoMocks/hippomocks.h>
+
+#include "Configuration.h"
+#include "BundleResource.h"
+#include "ResourceContainer.h"
+#include "ResourceContainerBundleAPI.h"
+#include "ResourceContainerImpl.h"
+
+#include "ResourceObject.h"
+
+using namespace std;
+using namespace testing;
+using namespace OIC::Service;
+
+
+string CONFIG_FILE = "ResourceContainerTestConfig.xml";
+
+typedef ResourceObject::Ptr(*resourceObjectBuild)();
+
+class TestBundleResource : public BundleResource
+{
+    public:
+        string getAttribute(string attributeName)
+        {
+            return "test";
+        };
+        void setAttribute(string attributeName, string value)
+        {};
+        void initAttributes()
+        {};
+};
+
+class ResourceContainerTest : public Test
+{
+    public:
+        ResourceContainer *m_pResourceContainer;
+
+    protected:
+        void SetUp() override
+        {
+            m_pResourceContainer = ResourceContainer::getInstance();
+        }
+};
+
+
+class ResourceContainerBundleAPITest : public Test
+{
+    public:
+        MockRepository mocks;
+        ResourceContainerBundleAPI *m_pResourceContainer;
+
+    protected:
+        void SetUp() override
+        {
+            m_pResourceContainer = ResourceContainerBundleAPI::getInstance();
+        }
+};
+
+// TC for registering resource should be implemented
+//TEST_F(ResourceContainerBundleAPITest, registerResourceTest)
+//{
+//    ResourceObject::Builder *builder = new ResourceObject::Builder("/test_resource", "oic.test", "");
+//    TestBundleResource *resource = new TestBundleResource();
+//
+//    mocks.ExpectCall(builder, ResourceObject::Builder::build).Return(nullptr);
+//
+//    m_pResourceContainer->registerResource(resource);
+//}
+
+// TC for unregistering resource should be implemented
+//TEST_F(ResourceContainerBundleAPITest, unregisterResourceTest)
+//{
+//}
+
+
+class ResourceContainerImplTest : public Test
+{
+    public:
+        ResourceContainerImpl *m_pResourceContainer;
+        BundleInfo *m_pBundleInfo;
+
+    protected:
+        void SetUp() override
+        {
+            m_pResourceContainer = ResourceContainerImpl::getImplInstance();
+            m_pBundleInfo = BundleInfo::createBundleInfo();
+        }
+};
+
+TEST_F(ResourceContainerImplTest, RegisterBundleTest)
+{
+    m_pBundleInfo->setPath("libTestBundle.so");
+    m_pBundleInfo->setVersion("1.0");
+    m_pBundleInfo->setID("oic.bundle.test");
+
+    m_pResourceContainer->registerBundle(m_pBundleInfo);
+
+    EXPECT_NE(((BundleInfoInternal *)m_pBundleInfo)->getBundleHandle(), nullptr);
+}
+
+TEST_F(ResourceContainerImplTest, RegisterBundleTestWithInvalidPath)
+{
+    m_pBundleInfo->setPath("");
+    m_pBundleInfo->setVersion("1.0");
+    m_pBundleInfo->setID("oic.bundle.test");
+
+    m_pResourceContainer->registerBundle(m_pBundleInfo);
+
+    EXPECT_EQ(((BundleInfoInternal *)m_pBundleInfo)->getBundleActivator(), nullptr);
+}
+
+TEST_F(ResourceContainerImplTest, ActivateBundle)
+{
+    m_pBundleInfo->setPath("libTestBundle.so");
+    m_pBundleInfo->setVersion("1.0");
+    m_pBundleInfo->setID("oic.bundle.test");
+
+    m_pResourceContainer->registerBundle(m_pBundleInfo);
+    m_pResourceContainer->activateBundle(m_pBundleInfo);
+
+    EXPECT_NE(((BundleInfoInternal *)m_pBundleInfo)->getBundleActivator(), nullptr);
+}
+
+TEST_F(ResourceContainerImplTest, ActivateUnregisteredBundle)
+{
+    m_pBundleInfo->setPath("libTestBundle.so");
+    m_pBundleInfo->setVersion("1.0");
+    m_pBundleInfo->setID("oic.bundle.test");
+
+    m_pResourceContainer->activateBundle(m_pBundleInfo);
+
+    EXPECT_EQ(((BundleInfoInternal *)m_pBundleInfo)->getBundleActivator(), nullptr);
+}
+
+// TC for deactivating bundle should be implemented
+
+//TEST_F(ResourceContainerImplTest, DeactivateBundle)
+//{
+//
+//}
+
+
+/* Test for Configuration */
+TEST(ConfigurationTest, LoadConfigFileWithValidPath)
+{
+    Configuration *config = new Configuration(CONFIG_FILE);
+
+    EXPECT_EQ(config->isLoaded(), true);
+}
+
+TEST(ConfigurationTest, LoadConfigFileWithInvalidPath)
+{
+    Configuration *config = new Configuration("test");
+
+    EXPECT_EQ(config->isLoaded(), false);
+}
+
+TEST(ConfigurationTest, getConfiguredBundlesTest)
+{
+    Configuration *config = new Configuration(CONFIG_FILE);
+
+    configInfo bundles;
+    map<string, string> results;
+
+    config->getConfiguredBundles(&bundles);
+
+    results = *bundles.begin();
+
+    EXPECT_STREQ(results["id"].c_str(), "oic.bundle.test");
+    EXPECT_STREQ(results["path"].c_str(), "libTestBundle.so");
+    EXPECT_STREQ(results["version"].c_str(), "1.0.0");
+}
+
+TEST(ConfigurationTest, getBundleConfigurationTest)
+{
+    Configuration *config = new Configuration(CONFIG_FILE);
+
+    configInfo bundle;
+    map<string, string> results;
+
+    config->getBundleConfiguration("oic.bundle.test", &bundle);
+
+    results = *bundle.begin();
+
+    EXPECT_STREQ(results["id"].c_str(), "oic.bundle.test");
+    EXPECT_STREQ(results["path"].c_str(), "libTestBundle.so");
+    EXPECT_STREQ(results["version"].c_str(), "1.0.0");
+}
+
+TEST(ConfigurationTest, getBundleConfigurationTestWithInvalidBundleId)
+{
+    Configuration *config = new Configuration(CONFIG_FILE);
+
+    configInfo bundles;
+    config->getBundleConfiguration("test", &bundles);
+
+    EXPECT_EQ(bundles.empty(), true);
+}
+
+TEST(ConfigurationTest, getResourceConfigurationTest)
+{
+    Configuration *config = new Configuration(CONFIG_FILE);
+
+    vector<resourceInfo> resourceConfig;
+    resourceInfo result;
+
+    config->getResourceConfiguration("oic.bundle.test", &resourceConfig);
+
+    result = *resourceConfig.begin();
+
+    EXPECT_STREQ(result.name.c_str(), "test_resource");
+    EXPECT_STREQ(result.resourceType.c_str(), "oic.test");
+}
+
+TEST(ConfigurationTest, getResourceConfigurationTestWithInvalideBundleId)
+{
+    Configuration *config = new Configuration(CONFIG_FILE);
+
+    configInfo bundles;
+    vector<resourceInfo> resourceConfig;
+    config->getResourceConfiguration("test", &resourceConfig);
+
+    EXPECT_EQ(bundles.empty(), true);
+}
\ No newline at end of file
diff --git a/service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerTestConfig.xml b/service/resource-manipulation/modules/resourceContainer/unittests/ResourceContainerTestConfig.xml
new file mode 100644 (file)
index 0000000..4904bba
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<container>      
+    <bundle>
+        <id>oic.bundle.test</id>
+        <path>libTestBundle.so</path>
+        <version>1.0.0</version>
+               <resources>
+                       <resourceInfo>
+                               <name>test_resource</name>
+                               <resourceType>oic.test</resourceType>
+                       </resourceInfo>   
+               </resources>
+    </bundle>
+</container>
diff --git a/service/resource-manipulation/modules/resourceContainer/unittests/SConscript b/service/resource-manipulation/modules/resourceContainer/unittests/SConscript
new file mode 100644 (file)
index 0000000..c959f24
--- /dev/null
@@ -0,0 +1,116 @@
+#******************************************************************
+#
+# 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.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+##
+# ResourceContainer Unit Test build script
+##
+import os
+Import('env')
+
+if env.get('RELEASE'):
+       env.AppendUnique(CCFLAGS = ['-Os'])
+       env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+else:
+       env.AppendUnique(CCFLAGS = ['-g'])
+
+if env.get('LOGGING'):
+       env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+# Add third party libraries
+lib_env = env.Clone()
+SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
+
+container_gtest_env = lib_env.Clone()
+target_os = env.get('TARGET_OS')
+
+######################### unit test setting ##########################
+src_dir = lib_env.get('SRC_DIR')
+gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
+######################################################################
+
+
+######################################################################
+# Build flags
+######################################################################
+gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
+gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
+
+container_gtest_env.AppendUnique(
+       CPPPATH = [
+               env.get('SRC_DIR')+'/extlibs', 
+               '../include',
+               '../include/internal',
+               '../bundle-api/include',
+               '../../serverBuilder/include',
+               '../../common/primitiveResource/include',
+               '/usr/lib/jvm/jdk1.8.0_40/include',
+               '/usr/lib/jvm/jdk1.8.0_40/include/linux'
+       ])
+
+if target_os not in ['windows', 'winrt']:
+       container_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
+       if target_os != 'android':
+               container_gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
+               container_gtest_env.AppendUnique(LIBS = ['pthread'])
+
+if target_os == 'android':
+    container_gtest_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+    container_gtest_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
+
+container_gtest_env.PrependUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs/hippomocks-master',
+                             gtest_dir + '/include'])
+                                                                        
+container_gtest_env.AppendUnique(LIBPATH = ['/usr/lib/jvm/jdk1.8.0_40/jre/lib/amd64/server/'])
+container_gtest_env.PrependUnique(LIBS = ['ResContainerLib', 'server_builder', 'service_common', 'oc','octbstack', 'oc_logger', 'oc_logger_core', 'connectivity_abstraction', gtest, gtest_main])
+container_gtest_env.AppendUnique(LIBS = ['dl', 'jvm']) 
+
+
+######################################################################
+# build test bundle
+######################################################################
+test_bundle_env = container_gtest_env.Clone()
+test_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
+
+TEST_BUNDLE_DIR = 'TestBundle/'
+test_bundle_env.AppendUnique(CPPPATH = [
+               TEST_BUNDLE_DIR + 'include',
+               '../include/'
+               ])              
+
+test_bundle_src = [ Glob(TEST_BUNDLE_DIR + 'src/*.cpp'), Glob('src/*.cpp')]
+
+TestBundle = test_bundle_env.SharedLibrary('TestBundle', test_bundle_src)
+test_bundle_env.InstallTarget(TestBundle, 'libTestBundle')
+
+
+######################################################################
+# Build Test
+######################################################################
+container_gtest_src = env.Glob('./*.cpp')
+
+container_test = container_gtest_env.Program('container_test', container_gtest_src)
+Alias("container_test", container_test)
+env.AppendTarget('container_test')
+
+# Copy test configuration
+Command("./ResourceContainerTestConfig.xml","./ResourceContainerTestConfig.xml", Copy("$TARGET", "$SOURCE"))
+Ignore("./ResourceContainerTestConfig.xml", "./ResourceContainerTestConfig.xml")
+Command("./ResourceContainerInvalidConfig.xml","./ResourceContainerInvalidConfig.xml", Copy("$TARGET", "$SOURCE"))
+Ignore("./ResourceContainerInvalidConfig.xml", "./ResourceContainerInvalidConfig.xml")
\ No newline at end of file
diff --git a/service/resource-manipulation/modules/resourceContainer/unittests/TestBundle/include/TestBundleActivator.h b/service/resource-manipulation/modules/resourceContainer/unittests/TestBundle/include/TestBundleActivator.h
new file mode 100644 (file)
index 0000000..4748d59
--- /dev/null
@@ -0,0 +1,42 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef TESTBUNDLE_H_
+#define TESTBUNDLE_H_
+
+#include <vector>
+
+#include "ResourceContainerBundleAPI.h"
+#include "BundleActivator.h"
+#include "BundleResource.h"
+
+using namespace OIC::Service;
+
+class TestBundleActivator : public BundleActivator
+{
+    public:
+        TestBundleActivator();
+        ~TestBundleActivator();
+
+        void activateBundle(ResourceContainerBundleAPI *resourceContainer, std::string bundleId);
+        void deactivateBundle();
+};
+
+#endif /* TESTBUNDLE_H_ */
diff --git a/service/resource-manipulation/modules/resourceContainer/unittests/TestBundle/src/TestBundleActivator.cpp b/service/resource-manipulation/modules/resourceContainer/unittests/TestBundle/src/TestBundleActivator.cpp
new file mode 100644 (file)
index 0000000..1fa1a7e
--- /dev/null
@@ -0,0 +1,57 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "TestBundleActivator.h"
+
+TestBundleActivator *bundle;
+
+TestBundleActivator::TestBundleActivator()
+{
+}
+
+TestBundleActivator::~TestBundleActivator()
+{
+}
+
+void TestBundleActivator::activateBundle(ResourceContainerBundleAPI *resourceContainer,
+        std::string bundleId)
+{
+    std::cout << "TestBundleActivator::activateBundle .. " << std::endl;
+}
+
+void TestBundleActivator::deactivateBundle()
+{
+    std::cout << "TestBundleActivator::deactivateBundle .. " << std::endl;
+}
+
+extern "C" void externalActivateBundle(ResourceContainerBundleAPI *resourceContainer,
+                                       std::string bundleId)
+{
+    bundle = new TestBundleActivator();
+    bundle->activateBundle(resourceContainer, bundleId);
+}
+
+extern "C" void externalDeactivateBundle()
+{
+    if (!bundle)
+    {
+        bundle->deactivateBundle();
+    }
+}