if (ex instanceof OcException) {
OcException ocEx = (OcException) ex;
ErrorCode errCode = ocEx.getErrorCode();
+ if(ErrorCode.NO_RESOURCE != errCode){
+ Log.e(TAG, ocEx.getMessage());
+ assertTrue(false);
+ }
+ }
+ else{
+ Log.e(TAG, ex.getMessage());
+ assertTrue(false);
}
- Log.e(TAG, ex.toString());
- assertTrue(false);
}
};
if (ex instanceof OcException) {
OcException ocEx = (OcException) ex;
ErrorCode errCode = ocEx.getErrorCode();
+ if(ErrorCode.NO_RESOURCE != errCode){
+ Log.e(TAG, ocEx.getMessage());
+ assertTrue(false);
+ }
+ }
+ else{
+ Log.e(TAG, ex.getMessage());
+ assertTrue(false);
}
- Log.e(TAG, ex.toString());
- assertTrue(false);
}
};
if (ex instanceof OcException) {
OcException ocEx = (OcException) ex;
ErrorCode errCode = ocEx.getErrorCode();
+ if(ErrorCode.NO_RESOURCE != errCode){
+ Log.e(TAG, ocEx.getMessage());
+ assertTrue(false);
+ }
+ }
+ else{
+ Log.e(TAG, ex.getMessage());
+ assertTrue(false);
}
- Log.e(TAG, ex.toString());
- assertTrue(false);
}
});
if (ex instanceof OcException) {
OcException ocEx = (OcException) ex;
ErrorCode errCode = ocEx.getErrorCode();
+ if(ErrorCode.NO_RESOURCE != errCode){
+ Log.e(TAG, ocEx.getMessage());
+ assertTrue(false);
+ }
+ }
+ else{
+ Log.e(TAG, ex.getMessage());
+ assertTrue(false);
}
- Log.e(TAG, ex.toString());
- assertTrue(false);
}
};
if (ex instanceof OcException) {
OcException ocEx = (OcException) ex;
ErrorCode errCode = ocEx.getErrorCode();
+ if(ErrorCode.NO_RESOURCE != errCode){
+ Log.e(TAG, ocEx.getMessage());
+ assertTrue(false);
+ }
+ }
+ else{
+ Log.e(TAG, ex.getMessage());
+ assertTrue(false);
}
- Log.e(TAG, ex.toString());
- assertTrue(false);
}
});
if (ex instanceof OcException) {
OcException ocEx = (OcException) ex;
ErrorCode errCode = ocEx.getErrorCode();
+ if(ErrorCode.NO_RESOURCE != errCode){
+ Log.e(TAG, ocEx.getMessage());
+ assertTrue(false);
+ }
+ }
+ else{
+ Log.e(TAG, ex.getMessage());
+ assertTrue(false);
}
- Log.e(TAG, ex.toString());
- assertTrue(false);
}
};
}
}
- public void testRegisterDeviceInfoGetDeviceInfo() throws InterruptedException {
- final String resourceType = "unit.test.resource" + new Date().getTime();
- final CountDownLatch signal = new CountDownLatch(1);
-
- OcPlatform.OnDeviceFoundListener deviceFoundListener = new OcPlatform.OnDeviceFoundListener() {
- @Override
- public void onDeviceFound(OcRepresentation ocRepresentation) {
- try {
- Log.i(TAG, "Device Name: " + ocRepresentation.getValue("dn"));
- } catch (OcException e) {
- Log.e(TAG, e.toString());
- assertTrue(false);
- }
- boolean hasDeviceNameAtr = ocRepresentation.hasAttribute("dn");
- assertTrue(hasDeviceNameAtr);
- boolean hasNonExistingAtr = ocRepresentation.hasAttribute("NonExisting");
- assertFalse(hasNonExistingAtr);
- Log.i(TAG, "URI: " + ocRepresentation.getUri());
- signal.countDown();
- }
- };
-
- OcDeviceInfo devInfo = new OcDeviceInfo();
-
- devInfo.setContentType("myContentType");
- devInfo.setDateOfManufacture("myDateOfManufacture");
- devInfo.setDeviceName("myDeviceName");
- devInfo.setDeviceUuid("myDeviceUUID");
- devInfo.setFirmwareVersion("myFirmwareVersion");
- devInfo.setHostName("myHostName");
- devInfo.setManufacturerName("myManufacturerNa");
- devInfo.setManufacturerUrl("myManufacturerUrl");
- devInfo.setModelNumber("myModelNumber");
- devInfo.setPlatformVersion("myPlatformVersion");
- devInfo.setSupportUrl("mySupportUrl");
- devInfo.setVersion("myVersion");
-
- try {
- //server
- OcPlatform.registerDeviceInfo(devInfo);
-
- //client
- OcPlatform.getDeviceInfo(
- "",
- OcPlatform.WELL_KNOWN_QUERY + "/d",
- OcConnectivityType.IPV4,
- deviceFoundListener);
-
- //wait for onDeviceFound event
- assertTrue(signal.await(60, TimeUnit.SECONDS));
-
- } catch (OcException e) {
- Log.e(TAG, e.getMessage());
- assertTrue(false);
- }
- }
+// public void testRegisterDeviceInfoGetDeviceInfo() throws InterruptedException {
+// final String resourceType = "unit.test.resource" + new Date().getTime();
+// final CountDownLatch signal = new CountDownLatch(1);
+//
+// OcPlatform.OnDeviceFoundListener deviceFoundListener = new OcPlatform.OnDeviceFoundListener() {
+// @Override
+// public void onDeviceFound(OcRepresentation ocRepresentation) {
+// try {
+// Log.i(TAG, "Device Name: " + ocRepresentation.getValue("dn"));
+// } catch (OcException e) {
+// Log.e(TAG, e.toString());
+// assertTrue(false);
+// }
+// boolean hasDeviceNameAtr = ocRepresentation.hasAttribute("dn");
+// assertTrue(hasDeviceNameAtr);
+// boolean hasNonExistingAtr = ocRepresentation.hasAttribute("NonExisting");
+// assertFalse(hasNonExistingAtr);
+// Log.i(TAG, "URI: " + ocRepresentation.getUri());
+// signal.countDown();
+// }
+// };
+//
+// OcDeviceInfo devInfo = new OcDeviceInfo();
+//
+// devInfo.setContentType("myContentType");
+// devInfo.setDateOfManufacture("myDateOfManufacture");
+// devInfo.setDeviceName("myDeviceName");
+// devInfo.setDeviceUuid("myDeviceUUID");
+// devInfo.setFirmwareVersion("myFirmwareVersion");
+// devInfo.setHostName("myHostName");
+// devInfo.setManufacturerName("myManufacturerNa");
+// devInfo.setManufacturerUrl("myManufacturerUrl");
+// devInfo.setModelNumber("myModelNumber");
+// devInfo.setPlatformVersion("myPlatformVersion");
+// devInfo.setSupportUrl("mySupportUrl");
+// devInfo.setVersion("myVersion");
+//
+// try {
+// //server
+// OcPlatform.registerDeviceInfo(devInfo);
+//
+// //client
+// OcPlatform.getDeviceInfo(
+// "",
+// OcPlatform.MULTICAST_PREFIX + "/oc/d",
+// OcConnectivityType.IPV4,
+// deviceFoundListener);
+//
+// //wait for onDeviceFound event
+// assertTrue(signal.await(60, TimeUnit.SECONDS));
+//
+// } catch (OcException e) {
+// Log.e(TAG, e.getMessage());
+// assertTrue(false);
+// }
+// }
public void testBindUnbindResources() throws InterruptedException {
final String resourceType = "unit.test.resource" + new Date().getTime();