Search in sources :

Example 6 with MyHttpClient

use of org.openhab.habdroid.util.MyHttpClient in project openhab-android by openhab.

the class DefaultConnectionTest method testSyncResolveRelativeUrl.

@Test
public void testSyncResolveRelativeUrl() {
    MyHttpClient httpClient = testConnection.getSyncHttpClient();
    httpClient.get("/rest/test", new MyHttpClient.TextResponseHandler() {

        @Override
        public void onFailure(Call call, int statusCode, Headers headers, String responseBody, Throwable error) {
            assertEquals(TEST_BASE_URL + "/rest/test", call.request().url().toString());
        }

        @Override
        public void onSuccess(Call call, int statusCode, Headers headers, String responseBody) {
            fail("The request should never succeed in tests.");
        }
    });
}
Also used : Call(okhttp3.Call) MyHttpClient(org.openhab.habdroid.util.MyHttpClient) Headers(okhttp3.Headers) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 MyHttpClient (org.openhab.habdroid.util.MyHttpClient)6 Call (okhttp3.Call)2 Headers (okhttp3.Headers)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2