From 6c1ff4c26be1d6f3aa6c17dc9e2c4048b08966b8 Mon Sep 17 00:00:00 2001 From: Larry Sachs Date: Tue, 13 Dec 2016 12:41:13 -0800 Subject: [PATCH] Platform ID must be UUID 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/15573 Reviewed-by: George Nash Tested-by: jenkins-iotivity Reviewed-by: Rick Bell --- .../androidTest/java/org/iotivity/base/SmokeTest.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java b/java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java index 7668d77..5f50521 100644 --- a/java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java +++ b/java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java @@ -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"); -- 2.7.4