From 24cda274e3050433677518b94dfb15d0bae59db5 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Thu, 24 Sep 2015 16:47:08 -0700 Subject: [PATCH] Android: fix for IOT-755 1. Moved a number of function implementations from OCResource.h into OCResource.cpp to make Android happy 2. Updated android smoke tests Change-Id: I0bf0edfae7490204d2f4ca44052066fc2dd9af12 Signed-off-by: Tim Kourt Reviewed-on: https://gerrit.iotivity.org/gerrit/3067 Tested-by: jenkins-iotivity Reviewed-by: Nagabharan Nagendran Reviewed-by: Joseph Morrow Reviewed-by: Patrick Lankswert --- .../java/org/iotivity/base/SmokeTest.java | 29 +++++-------------- resource/include/OCResource.h | 20 +++---------- resource/src/OCResource.cpp | 20 +++++++++++++ 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java b/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java index 350091eed..96453435e 100644 --- a/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java +++ b/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java @@ -1241,28 +1241,23 @@ public class SmokeTest extends InstrumentationTestCase { final String resourceType2 = "unit.test.resource" + new Date().getTime(); final CountDownLatch signal = new CountDownLatch(2); - final List resourceList = new LinkedList(); - - OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { - @Override - public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { - return EntityHandlerResult.OK; - } - }; + final List resourceList = new LinkedList<>(); OcPlatform.OnResourceFoundListener resourceFoundListener = new OcPlatform.OnResourceFoundListener() { @Override - public void onResourceFound(OcResource resource) { + public synchronized void onResourceFound(OcResource resource) { resourceList.add(resource); Log.i(TAG, "Host: " + resource.getHost()); Log.i(TAG, "Uri: " + resource.getUri()); Log.i(TAG, "Observable: " + resource.isObservable()); + assertFalse(resource.getResourceTypes().isEmpty()); for (String resourceType : resource.getResourceTypes()) { Log.i(TAG, "Type: " + resourceType); } + assertFalse(resource.getResourceTypes().isEmpty()); for (String resourceInterface : resource.getResourceInterfaces()) { Log.i(TAG, "Interface: " + resourceInterface); } @@ -1270,7 +1265,6 @@ public class SmokeTest extends InstrumentationTestCase { List headerOptionList = new LinkedList(); headerOptionList.add(new OcHeaderOption(2885, "OptionData1")); headerOptionList.add(new OcHeaderOption(2886, "OptionData2")); - resource.setHeaderOptions(headerOptionList); resource.setHeaderOptions(headerOptionList); resource.unsetHeaderOptions(); @@ -1289,7 +1283,7 @@ public class SmokeTest extends InstrumentationTestCase { "/a/unittest1", resourceType1, OcPlatform.DEFAULT_INTERFACE, - entityHandler, + null, EnumSet.of(ResourceProperty.DISCOVERABLE) ); @@ -1297,7 +1291,7 @@ public class SmokeTest extends InstrumentationTestCase { "/a/unittest2", resourceType2, OcPlatform.DEFAULT_INTERFACE, - entityHandler, + null, EnumSet.of(ResourceProperty.DISCOVERABLE) ); @@ -1336,13 +1330,6 @@ public class SmokeTest extends InstrumentationTestCase { final String resourceType = "unit.test.resource" + new Date().getTime(); final CountDownLatch signal = new CountDownLatch(1); - OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { - @Override - public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { - return EntityHandlerResult.OK; - } - }; - OcPlatform.OnResourceFoundListener resourceFoundListener = new OcPlatform.OnResourceFoundListener() { @Override @@ -1376,7 +1363,7 @@ public class SmokeTest extends InstrumentationTestCase { "/a/unittest", resourceType, OcPlatform.DEFAULT_INTERFACE, - entityHandler, + null, EnumSet.of(ResourceProperty.DISCOVERABLE) ); @@ -1403,7 +1390,7 @@ public class SmokeTest extends InstrumentationTestCase { "/a/unittest", resourceType, OcPlatform.DEFAULT_INTERFACE, - entityHandler, + null, EnumSet.of(ResourceProperty.DISCOVERABLE) ); diff --git a/resource/include/OCResource.h b/resource/include/OCResource.h index c4d1878a3..c2754a2c3 100644 --- a/resource/include/OCResource.h +++ b/resource/include/OCResource.h @@ -438,18 +438,12 @@ namespace OC * header options, they will be ignored.
* Use unsetHeaderOptions API to clear the header information. */ - void setHeaderOptions(const HeaderOptions& headerOptions) - { - m_headerOptions = headerOptions; - } + void setHeaderOptions(const HeaderOptions& headerOptions); /** * Function to unset header options. */ - void unsetHeaderOptions() - { - m_headerOptions.clear(); - } + void unsetHeaderOptions(); /** * Function to get the host address of this resource @@ -481,19 +475,13 @@ namespace OC * Function to get the list of resource types * @return vector of resource types */ - std::vector getResourceTypes() const - { - return m_resourceTypes; - } + std::vector getResourceTypes() const; /** * Function to get the list of resource interfaces * @return vector of resource interface */ - std::vector getResourceInterfaces(void) const - { - return m_interfaces; - } + std::vector getResourceInterfaces(void) const; // TODO-CA Revisit this since we are exposing two identifiers /** diff --git a/resource/src/OCResource.cpp b/resource/src/OCResource.cpp index e38512b84..8467fc781 100644 --- a/resource/src/OCResource.cpp +++ b/resource/src/OCResource.cpp @@ -407,6 +407,16 @@ OCStackResult OCResource::cancelObserve(QualityOfService QoS) return result; } +void OCResource::setHeaderOptions(const HeaderOptions& headerOptions) +{ + m_headerOptions = headerOptions; +} + +void OCResource::unsetHeaderOptions() +{ + m_headerOptions.clear(); +} + std::string OCResource::host() const { std::ostringstream ss; @@ -455,6 +465,16 @@ bool OCResource::isObservable() const return m_isObservable; } +std::vector OCResource::getResourceTypes() const +{ + return m_resourceTypes; +} + +std::vector OCResource::getResourceInterfaces(void) const +{ + return m_interfaces; +} + OCResourceIdentifier OCResource::uniqueIdentifier() const { return m_resourceId; -- 2.34.1