Platform ID must be UUID
authorLarry Sachs <larry.j.sachs@intel.com>
Tue, 13 Dec 2016 20:41:13 +0000 (12:41 -0800)
committerRick Bell <richard.s.bell@intel.com>
Tue, 13 Dec 2016 22:08:44 +0000 (22:08 +0000)
Change sleep() to wait()/notify()

Platform ID change was due to this commit https://gerrit.iotivity.org/gerrit/#/c/14991/
wait()/notify() improves performance

Change-Id: I5c1bca6939243eec9cbb52893c7e376ac422cb7c
Signed-off-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15573
Reviewed-by: George Nash <george.nash@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java

index 7668d77..5f50521 100644 (file)
@@ -123,6 +123,7 @@ public class SmokeTest extends InstrumentationTestCase {
         final String resourceType = "unit.test.resource" +
                 new Date().getTime();
         final CountDownLatch signal = new CountDownLatch(1);
+        final Object waitLock = new Object();
 
         OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
             @Override
@@ -151,6 +152,10 @@ public class SmokeTest extends InstrumentationTestCase {
                                     presenceListener
                             );
 
+                            synchronized (waitLock) {
+                                waitLock.notify();
+                            }
+
                             //wait for onPresence event
                             assertTrue(signal.await(60, TimeUnit.SECONDS));
 
@@ -186,13 +191,12 @@ public class SmokeTest extends InstrumentationTestCase {
                     resourceFoundListener);
 
             //server
-            //wait 2 seconds for the client's resourceFoundListener to set the presenceListener.
+            //wait for the client's resourceFoundListener to set the presenceListener.
             //the presenceListener must be set before startPresence() is called to get notified.
-            try {
-                Thread.sleep(2000);
-            } catch (InterruptedException e) {
-                Log.e(TAG, e.getMessage());
+            synchronized (waitLock) {
+                waitLock.wait(2000);
             }
+
             OcPlatform.startPresence(OcPlatform.DEFAULT_PRESENCE_TTL);
 
             //wait for onPresence event
@@ -1030,9 +1034,8 @@ public class SmokeTest extends InstrumentationTestCase {
         };
 
         OcPlatformInfo platformInfo = null;
-
-        platformInfo = new OcPlatformInfo("myPlatformID", "myManuName", "myManuUrl");
-
+        String myPlatformId = "00112233-4455-6677-8899-AABBCCDDEEFF"; // platform id must be a uuid
+        platformInfo = new OcPlatformInfo(myPlatformId, "myManuName", "myManuUrl");
         platformInfo.setModelNumber("myModelNumber");
         platformInfo.setDateOfManufacture("myDateOfManufacture");
         platformInfo.setPlatformVersion("myPlatformVersion");