From: Markus Jung Date: Thu, 23 Jul 2015 02:26:37 +0000 (+0900) Subject: Require explicit scons argument (containerJavaSupport=1) to include Java related... X-Git-Tag: 1.2.0+RC1~1367 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9b5cf0c8052c066a4af29cf0d50179428d58367;p=platform%2Fupstream%2Fiotivity.git Require explicit scons argument (containerJavaSupport=1) to include Java related code in resource container. Further, added a fix of the ResoureContainerTest to be compatible with gcc 4.6. Removed virtual override usage. More uniform API for whole resource-encapsulation module (using const string refererences). Use test helper class to avoid gcc version problems. Change-Id: I338ee7a7305a83f70babb7b07f9a542644f0c111 Signed-off-by: Markus Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/1838 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi Tested-by: Uze Choi --- diff --git a/service/resource-manipulation/include/BundleInfo.h b/service/resource-manipulation/include/BundleInfo.h index 29f5e2c..2d3905c 100644 --- a/service/resource-manipulation/include/BundleInfo.h +++ b/service/resource-manipulation/include/BundleInfo.h @@ -51,7 +51,7 @@ namespace OIC * @param name - Id of the bundle in string form * */ - virtual void setID(std::string name) = 0; + virtual void setID(const std::string &name) = 0; /** * API for getting the Id of the bundle @@ -59,7 +59,7 @@ namespace OIC * @return string - Id of the bundle * */ - virtual std::string getID() = 0; + virtual const std::string &getID() = 0; /** * API for setting the path of the bundle @@ -67,7 +67,7 @@ namespace OIC * @param path - path of the bundle in string form * */ - virtual void setPath(std::string path) = 0; + virtual void setPath(const std::string &path) = 0; /** * API for getting the path of the bundle @@ -75,7 +75,7 @@ namespace OIC * @return path - path of the bundle * */ - virtual std::string getPath() = 0; + virtual const std::string &getPath() = 0; /** * API for setting the Activator name for the bundle @@ -83,7 +83,7 @@ namespace OIC * @param activator - Activator name in string form * */ - virtual void setActivatorName(std::string activator) = 0; + virtual void setActivatorName(const std::string &activator) = 0; /** * API for setting the Activator name for the bundle @@ -91,7 +91,7 @@ namespace OIC * @return string - Name of the activator * */ - virtual std::string getActivatorName() = 0; + virtual const std::string &getActivatorName() = 0; /** * API for setting the library path for the bundle @@ -99,7 +99,7 @@ namespace OIC * @param libpath - Library path in string form * */ - virtual void setLibraryPath(std::string libpath) = 0; + virtual void setLibraryPath(const std::string &libpath) = 0; /** * API for getting the library path for the bundle @@ -107,7 +107,7 @@ namespace OIC * @return string - Library path in string form * */ - virtual std::string getLibraryPath() = 0; + virtual const std::string& getLibraryPath() = 0; /** * API for setting the version of the bundle @@ -115,7 +115,7 @@ namespace OIC * @param version - version of the bundle in string form * */ - virtual void setVersion(std::string version) = 0; + virtual void setVersion(const std::string &version) = 0; /** * API for getting the version of the bundle @@ -123,7 +123,7 @@ namespace OIC * @return string - version of the bundle * */ - virtual std::string getVersion() = 0; + virtual const std::string &getVersion() = 0; /** * API for creating new bundle information diff --git a/service/resource-manipulation/include/ResourceContainer.h b/service/resource-manipulation/include/ResourceContainer.h index e76b7a1..11112b9 100644 --- a/service/resource-manipulation/include/ResourceContainer.h +++ b/service/resource-manipulation/include/ResourceContainer.h @@ -66,7 +66,7 @@ namespace OIC * @param configFile - configuration File that contains the Bundle/Bundles information. * */ - virtual void startContainer(std::string configFile) = 0; + virtual void startContainer(const std::string &configFile) = 0; /** * API for stopping the Container */ @@ -86,14 +86,14 @@ namespace OIC * @param bundleId - Id of the Bundle * */ - virtual void startBundle(std::string bundleId) = 0; + virtual void startBundle(const std::string &bundleId) = 0; /** * API for Stopping the bundle * * @param bundleId - Id of the Bundle * */ - virtual void stopBundle(std::string bundleId) = 0; + virtual void stopBundle(const std::string &bundleId) = 0; // dynamic configuration /** @@ -105,7 +105,7 @@ namespace OIC * @param params - key-value pairs in string form for other Bundle parameters * */ - virtual void addBundle(std::string bundleId, std::string bundleUri, std::string bundlePath, + virtual void addBundle(const std::string &bundleId, const std::string &bundleUri, const std::string &bundlePath, std::map params) = 0; /** * API for removing the bundle from the container @@ -113,7 +113,7 @@ namespace OIC * @param bundleId - Id of the Bundle * */ - virtual void removeBundle(std::string bundleId) = 0; + virtual void removeBundle(const std::string &bundleId) = 0; /** * API for adding the Resource configuration information to the bundle @@ -123,7 +123,7 @@ namespace OIC * @param params - key-value pairs in string form for other Bundle parameters * */ - virtual void addResourceConfig(std::string bundleId, std::string resourceUri, + virtual void addResourceConfig(const std::string &bundleId, const std::string &esourceUri, std::map params) = 0; /** * API for removing the Resource configuration information from the bundle @@ -132,7 +132,7 @@ namespace OIC * @param resourceUri - URI of the resource * */ - virtual void removeResourceConfig(std::string bundleId, std::string resourceUri) = 0; + virtual void removeResourceConfig(const std::string &bundleId, const std::string &resourceUri) = 0; /** * API for getting the list of Bundle Resources @@ -140,7 +140,7 @@ namespace OIC * @param bundleId - Id of the Bundle * */ - virtual std::list listBundleResources(std::string bundleId) = 0; + virtual std::list listBundleResources(const std::string &bundleId) = 0; /** * API for getting the Instance of ResourceContainer class diff --git a/service/resource-manipulation/src/resourceContainer/SConscript b/service/resource-manipulation/src/resourceContainer/SConscript index a875802..241af81 100644 --- a/service/resource-manipulation/src/resourceContainer/SConscript +++ b/service/resource-manipulation/src/resourceContainer/SConscript @@ -25,6 +25,8 @@ import os Import('env') import os.path +containerJavaSupport = ARGUMENTS.get('containerJavaSupport',0) + def filtered_glob(env, pattern, omit=[], ondisk=True, source=False, strings=False): return filter( @@ -43,21 +45,22 @@ target_os = env.get('TARGET_OS') # Build flags ###################################################################### -try: - print 'Java Home: ', os.environ['JAVA_HOME'] - print 'Java Lib: ', os.environ['JAVA_LIB'] - resource_container_env.Append(CPPDEFINES={'JAVA_SUPPORT':1}) -except KeyError: - print ''' -*********************************** Error ************************************* -* Building resource container without Java support. JAVA_HOME or JAVA_LIB are not set properly -* Please configure JAVA_HOME to point to your Java 7 JDK and -* JAVA_LIB to your folder containing libjvm -* Example: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 -* export JAVA_LIB=/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server -******************************************************************************* - ''' - resource_container_env.Append(CPPDEFINES={'JAVA_SUPPORT':0}) +if int(containerJavaSupport): + try: + print 'Java Home: ', os.environ['JAVA_HOME'] + print 'Java Lib: ', os.environ['JAVA_LIB'] + resource_container_env.Append(CPPDEFINES={'JAVA_SUPPORT':1}) + except KeyError: + print ''' + *********************************** Error ************************************* + * Building resource container without Java support. JAVA_HOME or JAVA_LIB are not set properly + * Please configure JAVA_HOME to point to your Java 7 JDK and + * JAVA_LIB to your folder containing libjvm + * Example: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 + * export JAVA_LIB=/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server + ******************************************************************************* + ''' + resource_container_env.Append(CPPDEFINES={'JAVA_SUPPORT':0}) resource_container_env.AppendUnique( @@ -69,16 +72,16 @@ resource_container_env.AppendUnique( 'src' ]) -try: - resource_container_env.AppendUnique( - CPPPATH = [ - os.environ['JAVA_HOME']+'/include', - os.environ['JAVA_HOME']+'/include/linux' - ]) -except KeyError: - print '' - - +if int(containerJavaSupport): + try: + resource_container_env.AppendUnique( + CPPPATH = [ + os.environ['JAVA_HOME']+'/include', + os.environ['JAVA_HOME']+'/include/linux' + ]) + except KeyError: + print '' + if target_os not in ['windows', 'winrt']: resource_container_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall']) @@ -101,11 +104,12 @@ except KeyError: resource_container_env.PrependUnique(LIBS = ['rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'oc_logger_core', 'connectivity_abstraction']) resource_container_env.AppendUnique(LIBS = ['dl']) -try: - print 'Java Lib: ', os.environ['JAVA_LIB'] - resource_container_env.AppendUnique(LIBS = ['jvm']) -except KeyError: - print '' +if int(containerJavaSupport): + try: + print 'Java Lib: ', os.environ['JAVA_LIB'] + resource_container_env.AppendUnique(LIBS = ['jvm']) + except KeyError: + print '' ###################################################################### # Source files and Targets diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h index 8c378ca..d4d3515 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h @@ -55,7 +55,7 @@ namespace OIC * * @return void */ - virtual void onNotificationReceived(std::string strResourceUri) = 0; + virtual void onNotificationReceived(const std::string &strResourceUri) = 0; }; } } diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h index c7a869c..dda8a8f 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h @@ -79,7 +79,7 @@ namespace OIC * * @return void */ - virtual void getBundleConfiguration(std::string bundleId, configInfo *configOutput) = 0; + virtual void getBundleConfiguration(const std::string &bundleId, configInfo *configOutput) = 0; /** * Get the list of Configuration data of resources that certain bundle has @@ -90,7 +90,7 @@ namespace OIC * * @return void */ - virtual void getResourceConfiguration(std::string bundleId, + virtual void getResourceConfiguration(const std::string &bundleId, std::vector< resourceInfo > *configOutput) = 0; /** diff --git a/service/resource-manipulation/src/resourceContainer/include/BundleInfoInternal.h b/service/resource-manipulation/src/resourceContainer/include/BundleInfoInternal.h index 6bad441..95b6203 100644 --- a/service/resource-manipulation/src/resourceContainer/include/BundleInfoInternal.h +++ b/service/resource-manipulation/src/resourceContainer/include/BundleInfoInternal.h @@ -47,23 +47,23 @@ namespace OIC BundleInfoInternal(); BundleInfoInternal(BundleInfo *info); virtual ~BundleInfoInternal(); - void setID(string id); - string getID(); - void setPath(string path); - string getPath(); - void setVersion(string version); - string getVersion(); + void setID(const std::string &id); + const std::string &getID(); + void setPath(const std::string &path); + const std::string &getPath(); + void setVersion(const std::string &version); + const std::string &getVersion(); void setLoaded(bool loaded); bool isLoaded(); void setActivated(bool activated); bool isActivated(); - virtual void setLibraryPath(string libpath); - virtual string getLibraryPath(); + virtual void setLibraryPath(const std::string &libpath); + virtual const std::string &getLibraryPath(); - void setActivatorName(string activatorName); - string getActivatorName(); + void setActivatorName(const std::string &activatorName); + const std::string &getActivatorName(); void setBundleActivator(activator_t *); activator_t *getBundleActivator(); diff --git a/service/resource-manipulation/src/resourceContainer/include/ResourceContainerImpl.h b/service/resource-manipulation/src/resourceContainer/include/ResourceContainerImpl.h index 631aac6..1e04067 100644 --- a/service/resource-manipulation/src/resourceContainer/include/ResourceContainerImpl.h +++ b/service/resource-manipulation/src/resourceContainer/include/ResourceContainerImpl.h @@ -51,23 +51,23 @@ namespace OIC virtual ~ResourceContainerImpl(); // methods from ResourceContainer - void startContainer(string configFile); + void startContainer(const std::string &configFile); void stopContainer(); void activateBundle(BundleInfo *bundleInfo); void deactivateBundle(BundleInfo *bundleInfo); - void activateBundle(string bundleId); - void deactivateBundle(string bundleId); + void activateBundle(const std::string &bundleId); + void deactivateBundle(const std::string &bundleId); void registerBundle(BundleInfo *bundleinfo); void unregisterBundle(BundleInfo *bundleinfo); - void unregisterBundleSo(string id); + void unregisterBundleSo(const std::string &id); // methods from ResourceContainerBundleAPI void registerResource(BundleResource *resource); void unregisterResource(BundleResource *resource); - void getBundleConfiguration(std::string bundleId, configInfo *configOutput); - void getResourceConfiguration(std::string bundleId, + void getBundleConfiguration(const std::string &bundleId, configInfo *configOutput); + void getResourceConfiguration(const std::string &bundleId, std::vector< resourceInfo > *configOutput); RCSGetResponse getRequestHandler(const RCSRequest &request, @@ -75,24 +75,24 @@ namespace OIC RCSSetResponse setRequestHandler(const RCSRequest &request, const ResourceAttributes &attributes); - void onNotificationReceived(std::string strResourceUri); + void onNotificationReceived(const std::string &strResourceUri); static ResourceContainerImpl *getImplInstance(); - static ResourceObject::Ptr buildResourceObject(string strUri, string strResourceType); + static ResourceObject::Ptr buildResourceObject(const std::string &strUri, const std::string &strResourceType); - void startBundle(string bundleId); - void stopBundle(string bundleId); + void startBundle(const std::string &bundleId); + void stopBundle(const std::string &bundleId); - void addBundle(string bundleId, string bundleUri, string bundlePath, + void addBundle(const std::string &bundleId, const std::string &bundleUri, const std::string &bundlePath, std::map params); - void removeBundle(string bundleId); + void removeBundle(const std::string &bundleId); std::list listBundles(); - void addResourceConfig(string bundleId, string resourceUri, std::map params); - void removeResourceConfig(string bundleId, string resourceUri); + void addResourceConfig(const std::string &bundleId, const std::string &resourceUri, std::map params); + void removeResourceConfig(const std::string &bundleId, const std::string &resourceUri); - std::list listBundleResources(string bundleId); + std::list listBundleResources(const std::string &bundleId); #if(JAVA_SUPPORT) JavaVM *getJavaVM(string bundleId); @@ -109,10 +109,10 @@ namespace OIC Configuration *m_config; - void activateSoBundle(string bundleId); - void deactivateSoBundle(string bundleId); - void addSoBundleResource(string bundleId, resourceInfo newResourceInfo); - void removeSoBundleResource(string bundleId, string resourceUri); + void activateSoBundle(const std::string &bundleId); + void deactivateSoBundle(const std::string &bundleId); + void addSoBundleResource(const std::string &bundleId, resourceInfo newResourceInfo); + void removeSoBundleResource(const std::string &bundleId, const std::string &resourceUri); void registerSoBundle(BundleInfo *bundleInfo); #if(JAVA_SUPPORT) diff --git a/service/resource-manipulation/src/resourceContainer/src/BundleInfoInternal.cpp b/service/resource-manipulation/src/resourceContainer/src/BundleInfoInternal.cpp index 9a14ef2..79c993a 100644 --- a/service/resource-manipulation/src/resourceContainer/src/BundleInfoInternal.cpp +++ b/service/resource-manipulation/src/resourceContainer/src/BundleInfoInternal.cpp @@ -42,31 +42,31 @@ namespace OIC m_bundleHandle = nullptr; } - void BundleInfoInternal::setID(string id) + void BundleInfoInternal::setID(const std::string &id) { m_ID = id; } - string BundleInfoInternal::getID() + const std::string &BundleInfoInternal::getID() { return m_ID; } - void BundleInfoInternal::setPath(string path) + void BundleInfoInternal::setPath( const std::string &path) { m_path = path; } - string BundleInfoInternal::getPath() + const std::string &BundleInfoInternal::getPath() { return m_path; } - void BundleInfoInternal::setVersion(string version) + void BundleInfoInternal::setVersion( const std::string &version) { m_version = version; } - string BundleInfoInternal::getVersion() + const std::string &BundleInfoInternal::getVersion() { return m_version; } @@ -151,22 +151,22 @@ namespace OIC return m_java_bundle; } - void BundleInfoInternal::setActivatorName(string activatorName) + void BundleInfoInternal::setActivatorName( const std::string &activatorName) { m_activator_name = activatorName; } - string BundleInfoInternal::getActivatorName() + const std::string &BundleInfoInternal::getActivatorName() { return m_activator_name; } - void BundleInfoInternal::setLibraryPath(string libpath) + void BundleInfoInternal::setLibraryPath( const std::string &libpath) { m_library_path = libpath; } - string BundleInfoInternal::getLibraryPath() + const std::string &BundleInfoInternal::getLibraryPath() { return m_library_path; } diff --git a/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp b/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp index 01f986a..16ce833 100644 --- a/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp +++ b/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp @@ -79,7 +79,7 @@ namespace OIC && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } - void ResourceContainerImpl::startContainer(string configFile) + void ResourceContainerImpl::startContainer(const std::string &configFile) { info_logger() << "Starting resource container " << endl; #if (JAVA_SUPPORT) @@ -167,7 +167,7 @@ namespace OIC } } - void ResourceContainerImpl::activateBundle(string id) + void ResourceContainerImpl::activateBundle(const std::string &id) { info_logger() << "Activating bundle: " << m_bundles[id]->getID() << endl; @@ -187,7 +187,7 @@ namespace OIC } - void ResourceContainerImpl::deactivateBundle(string id) + void ResourceContainerImpl::deactivateBundle(const std::string &id) { if (m_bundles[id]->getJavaBundle()) @@ -239,7 +239,7 @@ namespace OIC } } - void ResourceContainerImpl::unregisterBundleSo(string id) + void ResourceContainerImpl::unregisterBundleSo(const std::string &id) { void *bundleHandle = m_bundles[id]->getBundleHandle(); info_logger() << "Unregister bundle: " << m_bundles[id]->getID() << ", " @@ -312,7 +312,7 @@ namespace OIC } } - void ResourceContainerImpl::getBundleConfiguration(std::string bundleId, + void ResourceContainerImpl::getBundleConfiguration(const std::string &bundleId, configInfo *configOutput) { if (m_config) @@ -321,7 +321,7 @@ namespace OIC } } - void ResourceContainerImpl::getResourceConfiguration(std::string bundleId, + void ResourceContainerImpl::getResourceConfiguration(const std::string &bundleId, std::vector< resourceInfo > *configOutput) { if (m_config) @@ -369,7 +369,7 @@ namespace OIC return RCSSetResponse::create(attr); } - void ResourceContainerImpl::onNotificationReceived(std::string strResourceUri) + void ResourceContainerImpl::onNotificationReceived(const std::string &strResourceUri) { info_logger() << "ResourceContainerImpl::onNotificationReceived\n\tnotification from " << strResourceUri << ".\n"; @@ -386,14 +386,14 @@ namespace OIC return &m_instance; } - ResourceObject::Ptr ResourceContainerImpl::buildResourceObject(string strUri, - string strResourceType) + ResourceObject::Ptr ResourceContainerImpl::buildResourceObject(const std::string & strUri, + const std::string & strResourceType) { return ResourceObject::Builder(strUri, strResourceType, "DEFAULT_INTERFACE").setObservable( true).setDiscoverable(true).build(); } - void ResourceContainerImpl::startBundle(string bundleId) + void ResourceContainerImpl::startBundle(const std::string &bundleId) { if (m_bundles.find(bundleId) != m_bundles.end()) { @@ -408,7 +408,7 @@ namespace OIC } } - void ResourceContainerImpl::stopBundle(string bundleId) + void ResourceContainerImpl::stopBundle(const std::string &bundleId) { if (m_bundles.find(bundleId) != m_bundles.end()) { @@ -423,7 +423,7 @@ namespace OIC } } - void ResourceContainerImpl::addBundle(string bundleId, string bundleUri, string bundlePath, + void ResourceContainerImpl::addBundle(const std::string &bundleId, const std::string &bundleUri, const std::string &bundlePath, std::map< string, string > params) { if (m_bundles.find(bundleId) != m_bundles.end()) @@ -449,7 +449,7 @@ namespace OIC } } - void ResourceContainerImpl::removeBundle(string bundleId) + void ResourceContainerImpl::removeBundle(const std::string &bundleId) { if (m_bundles.find(bundleId) != m_bundles.end()) { @@ -482,7 +482,7 @@ namespace OIC return ret; } - void ResourceContainerImpl::addResourceConfig(string bundleId, string resourceUri, + void ResourceContainerImpl::addResourceConfig(const std::string &bundleId, const std::string &resourceUri, std::map< string, string > params) { if (m_bundles.find(bundleId) != m_bundles.end()) @@ -509,7 +509,7 @@ namespace OIC } } - void ResourceContainerImpl::removeResourceConfig(string bundleId, string resourceUri) + void ResourceContainerImpl::removeResourceConfig(const std::string &bundleId, const std::string &resourceUri) { if (m_bundles.find(bundleId) != m_bundles.end()) { @@ -525,7 +525,7 @@ namespace OIC } } - std::list< string > ResourceContainerImpl::listBundleResources(string bundleId) + std::list< string > ResourceContainerImpl::listBundleResources(const std::string &bundleId) { std::list< string > ret; @@ -587,7 +587,7 @@ namespace OIC } } - void ResourceContainerImpl::activateSoBundle(string bundleId) + void ResourceContainerImpl::activateSoBundle(const std::string &bundleId) { activator_t *bundleActivator = m_bundles[bundleId]->getBundleActivator(); @@ -606,7 +606,7 @@ namespace OIC bundleInfoInternal->setActivated(true); } - void ResourceContainerImpl::deactivateSoBundle(string id) + void ResourceContainerImpl::deactivateSoBundle(const std::string &id) { deactivator_t *bundleDeactivator = m_bundles[id]->getBundleDeactivator(); info_logger() << "De-activating bundle: " << m_bundles[id]->getID() << endl; @@ -623,7 +623,7 @@ namespace OIC } } - void ResourceContainerImpl::addSoBundleResource(string bundleId, + void ResourceContainerImpl::addSoBundleResource(const std::string &bundleId, resourceInfo newResourceInfo) { resourceCreator_t *resourceCreator; @@ -640,7 +640,7 @@ namespace OIC } } - void ResourceContainerImpl::removeSoBundleResource(string bundleId, string resourceUri) + void ResourceContainerImpl::removeSoBundleResource(const std::string &bundleId, const std::string &resourceUri) { if (m_mapResources.find(resourceUri) != m_mapResources.end()) { diff --git a/service/resource-manipulation/src/resourceContainer/unittests/ResourceContainerTest.cpp b/service/resource-manipulation/src/resourceContainer/unittests/ResourceContainerTest.cpp index c4c7aae..237d936 100644 --- a/service/resource-manipulation/src/resourceContainer/unittests/ResourceContainerTest.cpp +++ b/service/resource-manipulation/src/resourceContainer/unittests/ResourceContainerTest.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include #include @@ -40,6 +42,7 @@ using namespace OIC::Service; string CONFIG_FILE = "ResourceContainerTestConfig.xml"; + /*Fake bundle resource class for testing*/ class TestBundleResource: public BundleResource { @@ -60,22 +63,23 @@ class TestBundleResource: public BundleResource ; }; -class ResourceContainerTest: public Test +class ResourceContainerTest: public TestWithMock { + public: ~ResourceContainerTest() noexcept(true) { } - public: MockRepository mocks; ResourceContainer *m_pResourceContainer; protected: - void SetUp() override + void SetUp() { + TestWithMock::SetUp(); m_pResourceContainer = ResourceContainer::getInstance(); } }; @@ -222,15 +226,15 @@ TEST_F(ResourceContainerTest, TryAddingSoBundleResourceToNotRegisteredBundle) m_pResourceContainer->addResourceConfig("unvalidBundleId", "", resourceParams); } -class ResourceContainerBundleAPITest: public Test +class ResourceContainerBundleAPITest: public TestWithMock { - public: ~ResourceContainerBundleAPITest() noexcept(true) { } + public: MockRepository mocks; ResourceObject *m_pResourceObject; @@ -238,8 +242,9 @@ class ResourceContainerBundleAPITest: public Test TestBundleResource *m_pBundleResource; protected: - void SetUp() override + void SetUp() { + TestWithMock::SetUp(); m_pResourceObject = mocks.Mock(); m_pResourceContainer = ResourceContainerBundleAPI::getInstance(); @@ -346,8 +351,9 @@ TEST_F(ResourceContainerBundleAPITest, BundleResourceConfigurationListParsed) ((ResourceContainerImpl *)m_pResourceContainer)->stopContainer(); } -class ResourceContainerImplTest: public Test +class ResourceContainerImplTest: public TestWithMock { + public: ~ResourceContainerImplTest() noexcept(true) { @@ -360,8 +366,9 @@ class ResourceContainerImplTest: public Test BundleInfo *m_pBundleInfo; protected: - void SetUp() override + void SetUp() { + TestWithMock::SetUp(); m_pResourceContainer = ResourceContainerImpl::getImplInstance(); m_pBundleInfo = BundleInfo::build(); } @@ -588,4 +595,4 @@ TEST(ConfigurationTest, BundleResourceConfigurationNotParsedWithInvalidBundleId) config->getResourceConfiguration("test", &resourceConfig); EXPECT_TRUE(bundles.empty()); -} \ No newline at end of file +} diff --git a/service/resource-manipulation/src/resourceContainer/unittests/SConscript b/service/resource-manipulation/src/resourceContainer/unittests/SConscript index 5d000f9..e245815 100644 --- a/service/resource-manipulation/src/resourceContainer/unittests/SConscript +++ b/service/resource-manipulation/src/resourceContainer/unittests/SConscript @@ -26,6 +26,8 @@ Import('env') import os.path +containerJavaSupport = ARGUMENTS.get('containerJavaSupport',0) + def filtered_glob(env, pattern, omit=[], ondisk=True, source=False, strings=False): return filter( @@ -52,21 +54,22 @@ SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env') container_gtest_env = lib_env.Clone() -try: - print 'Java Home: ', os.environ['JAVA_HOME'] - print 'Java Lib: ', os.environ['JAVA_LIB'] - container_gtest_env.Append(CPPDEFINES={'JAVA_SUPPORT_TEST':1}) -except KeyError: - print ''' -*********************************** Error ************************************* -* Building resource container without Java support. JAVA_HOME or JAVA_LIB are not set properly -* Please configure JAVA_HOME to point to your Java 7 JDK and -* JAVA_LIB to your folder containing libjvm -* Example: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 -* export JAVA_LIB=/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server/ -******************************************************************************* - ''' - container_gtest_env.Append(CPPDEFINES={'JAVA_SUPPORT_TEST':0}) +if int(containerJavaSupport): + try: + print 'Java Home: ', os.environ['JAVA_HOME'] + print 'Java Lib: ', os.environ['JAVA_LIB'] + container_gtest_env.Append(CPPDEFINES={'JAVA_SUPPORT_TEST':1}) + except KeyError: + print ''' + *********************************** Error ************************************* + * Building resource container without Java support. JAVA_HOME or JAVA_LIB are not set properly + * Please configure JAVA_HOME to point to your Java 7 JDK and + * JAVA_LIB to your folder containing libjvm + * Example: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 + * export JAVA_LIB=/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server/ + ******************************************************************************* + ''' + container_gtest_env.Append(CPPDEFINES={'JAVA_SUPPORT_TEST':0}) target_os = env.get('TARGET_OS') @@ -89,17 +92,19 @@ container_gtest_env.AppendUnique( '../include', '../../../include', '../include/internal', + '../../common/utils/include', '../bundle-api/include' ]) - -try: - container_gtest_env.AppendUnique( - CPPPATH = [ - os.environ['JAVA_HOME']+'/include', - os.environ['JAVA_HOME']+'/include/linux' - ]) -except KeyError: - print '' + +if int(containerJavaSupport): + try: + container_gtest_env.AppendUnique( + CPPPATH = [ + os.environ['JAVA_HOME']+'/include', + os.environ['JAVA_HOME']+'/include/linux' + ]) + except KeyError: + print '' if target_os not in ['windows', 'winrt']: container_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall']) @@ -113,11 +118,12 @@ if target_os == 'android': container_gtest_env.PrependUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs/hippomocks-master', gtest_dir + '/include']) - -try: - container_gtest_env.AppendUnique(LIBPATH = [os.environ['JAVA_LIB']]) -except KeyError: - print '' + +if int(containerJavaSupport): + try: + container_gtest_env.AppendUnique(LIBPATH = [os.environ['JAVA_LIB']]) + except KeyError: + print '' container_gtest_env.AppendUnique(CCFLAGS = ['-Wnoexcept']) @@ -125,12 +131,12 @@ container_gtest_env.PrependUnique(LIBS = ['rcs_container', 'rcs_server', 'rcs_co container_gtest_env.AppendUnique(LIBS = ['dl']) - -try: - print 'Java Lib: ', os.environ['JAVA_LIB'] - container_gtest_env.AppendUnique(LIBS = ['jvm']) -except KeyError: - print '' +if int(containerJavaSupport): + try: + print 'Java Lib: ', os.environ['JAVA_LIB'] + container_gtest_env.AppendUnique(LIBS = ['jvm']) + except KeyError: + print '' ###################################################################### # build test bundle @@ -168,4 +174,4 @@ Ignore("./ResourceContainerTestConfig.xml", "./ResourceContainerTestConfig.xml") Command("./ResourceContainerInvalidConfig.xml","./ResourceContainerInvalidConfig.xml", Copy("$TARGET", "$SOURCE")) Ignore("./ResourceContainerInvalidConfig.xml", "./ResourceContainerInvalidConfig.xml") Command("./TestBundleJava/hue-0.1-jar-with-dependencies.jar","./TestBundleJava/hue-0.1-jar-with-dependencies.jar", Copy("$TARGET", "$SOURCE")) -Ignore("./TestBundleJava/hue-0.1-jar-with-dependencies.jar", "./TestBundleJava/hue-0.1-jar-with-dependencies.jar") \ No newline at end of file +Ignore("./TestBundleJava/hue-0.1-jar-with-dependencies.jar", "./TestBundleJava/hue-0.1-jar-with-dependencies.jar")