Android: fix for IOT-755
authorTim Kourt <tim.a.kourt@intel.com>
Thu, 24 Sep 2015 23:47:08 +0000 (16:47 -0700)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Mon, 28 Sep 2015 16:48:50 +0000 (16:48 +0000)
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 <tim.a.kourt@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3067
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Nagabharan Nagendran <nagabharan.nagendran@intel.com>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
(cherry picked from commit 24cda274e3050433677518b94dfb15d0bae59db5)
Reviewed-on: https://gerrit.iotivity.org/gerrit/3131

android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java
resource/include/OCResource.h
resource/src/OCResource.cpp

index 350091e..9645343 100644 (file)
@@ -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<OcResource> resourceList = new LinkedList<OcResource>();
-
-        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
-            @Override
-            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
-                return EntityHandlerResult.OK;
-            }
-        };
+        final List<OcResource> 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<OcHeaderOption> headerOptionList = new LinkedList<OcHeaderOption>();
                         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)
             );
 
index c4d1878..c2754a2 100644 (file)
@@ -438,18 +438,12 @@ namespace OC
         * header options, they will be ignored. <br>
         * 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<std::string> getResourceTypes() const
-        {
-            return m_resourceTypes;
-        }
+        std::vector<std::string> getResourceTypes() const;
 
         /**
         * Function to get the list of resource interfaces
         * @return vector of resource interface
         */
-        std::vector<std::string> getResourceInterfaces(void) const
-        {
-            return m_interfaces;
-        }
+        std::vector<std::string> getResourceInterfaces(void) const;
 
         // TODO-CA Revisit this since we are exposing two identifiers
         /**
index 9e152d9..204b0da 100644 (file)
@@ -400,6 +400,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;
@@ -448,6 +458,16 @@ bool OCResource::isObservable() const
     return m_isObservable;
 }
 
+std::vector<std::string> OCResource::getResourceTypes() const
+{
+    return m_resourceTypes;
+}
+
+std::vector<std::string> OCResource::getResourceInterfaces(void) const
+{
+    return m_interfaces;
+}
+
 OCResourceIdentifier OCResource::uniqueIdentifier() const
 {
     return m_resourceId;