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>
Fri, 25 Sep 2015 16:00:08 +0000 (16:00 +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>
android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java
resource/include/OCResource.h
resource/src/OCResource.cpp

index 350091eed7135248003ce9a28f209e305bf1fbf0..96453435ebc35bb2a36fc47563db2c4bbdb3de1d 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 c4d1878a3499c37b7fafe706574decbbdd6d2067..c2754a2c36ba8d147d6aa3acf13018aaca33f7bb 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 e38512b8432330bc06703f2a403203993078c461..8467fc781914abca2a566a42848bf957d20eac98 100644 (file)
@@ -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<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;