/**
  * バッテリーonchargingchangeを解除するテストを行う.
  *
  * <pre>
  * 【HTTP通信】
  * Method: DELETE
  * Path: /battery/onchargingchange?deviceid=xxxx&session_key=xxxx
  * </pre>
  *
  * <pre>
  * 【期待する動作】
  * ・resultに0が返ってくること。
  * </pre>
  */
 public void testDeleteBatteryOnChargingChange() {
   URIBuilder builder = TestURIBuilder.createURIBuilder();
   builder.setProfile(BatteryProfileConstants.PROFILE_NAME);
   builder.setAttribute(BatteryProfileConstants.ATTRIBUTE_ON_CHARGING_CHANGE);
   builder.addParameter(DConnectProfileConstants.PARAM_DEVICE_ID, getDeviceId());
   builder.addParameter(DConnectProfileConstants.PARAM_SESSION_KEY, getClientId());
   builder.addParameter(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN, getAccessToken());
   try {
     HttpUriRequest request = new HttpDelete(builder.toString());
     JSONObject root = sendRequest(request);
     assertResultOK(root);
   } catch (JSONException e) {
     fail("Exception in JSONObject." + e.getMessage());
   }
 }
 /**
  * バッテリーlevel属性取得テストを行う.
  *
  * <pre>
  * 【HTTP通信】
  * Method: GET
  * Path: /battery/level?deviceid=xxxx
  * </pre>
  *
  * <pre>
  * 【期待する動作】
  * ・resultに0が返ってくること。
  * ・levelが0.5で返ってくること。
  * </pre>
  */
 public void testGetBatteryLevel() {
   URIBuilder builder = TestURIBuilder.createURIBuilder();
   builder.setProfile(BatteryProfileConstants.PROFILE_NAME);
   builder.setAttribute(BatteryProfileConstants.ATTRIBUTE_LEVEL);
   builder.addParameter(DConnectProfileConstants.PARAM_DEVICE_ID, getDeviceId());
   builder.addParameter(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN, getAccessToken());
   try {
     HttpUriRequest request = new HttpGet(builder.toString());
     JSONObject root = sendRequest(request);
     assertResultOK(root);
     assertEquals(
         "level is not equals.",
         TestBatteryProfileConstants.LEVEL,
         root.getDouble(BatteryProfileConstants.ATTRIBUTE_LEVEL));
   } catch (JSONException e) {
     fail("Exception in JSONObject." + e.getMessage());
   }
 }
 /**
  * onbatterychange属性のコールバック登録テストを行う.
  *
  * <pre>
  * 【HTTP通信】
  * Method: PUT
  * Path: /battery/onbatterychange?deviceid=xxxx&session_key=xxxx
  * </pre>
  *
  * <pre>
  * 【期待する動作】
  * ・resultに0が返ってくること。
  * </pre>
  */
 public void testPutBatteryOnBatteryChange() {
   URIBuilder builder = TestURIBuilder.createURIBuilder();
   builder.setProfile(BatteryProfileConstants.PROFILE_NAME);
   builder.setAttribute(BatteryProfileConstants.ATTRIBUTE_ON_BATTERY_CHANGE);
   builder.addParameter(DConnectProfileConstants.PARAM_DEVICE_ID, getDeviceId());
   builder.addParameter(DConnectProfileConstants.PARAM_SESSION_KEY, getClientId());
   builder.addParameter(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN, getAccessToken());
   try {
     HttpUriRequest request = new HttpPut(builder.toString());
     JSONObject root = sendRequest(request);
     assertResultOK(root);
     // イベントメッセージを受け取る
     JSONObject resp = waitForEvent();
     assertNotNull("response is null.", resp);
     assertEquals(
         BatteryProfileConstants.PROFILE_NAME, resp.getString(DConnectMessage.EXTRA_PROFILE));
     assertEquals(
         BatteryProfileConstants.ATTRIBUTE_ON_BATTERY_CHANGE,
         resp.getString(DConnectMessage.EXTRA_ATTRIBUTE));
   } catch (JSONException e) {
     fail("Exception in JSONObject." + e.getMessage());
   }
 }