use of org.openhab.habdroid.util.MyHttpClient in project openhab-android by openhab.
the class DefaultConnectionTest method testAsyncHasUsernamePassword.
@Test
public void testAsyncHasUsernamePassword() {
Connection connection = new DefaultConnection(mockContext, mockSettings, Connection.TYPE_LOCAL, TEST_BASE_URL, "Test-User", "Test-Password");
MyHttpClient httpClient = connection.getAsyncHttpClient();
assertTrue(httpClient.getHeaders().containsKey("Authorization"));
assertEquals(Credentials.basic("Test-User", "Test-Password"), httpClient.getHeaders().get("Authorization"));
}
use of org.openhab.habdroid.util.MyHttpClient in project openhab-android by openhab.
the class DefaultConnectionTest method testAsyncHasNoUsernamePassword.
@Test
public void testAsyncHasNoUsernamePassword() {
MyHttpClient httpClient = testConnection.getAsyncHttpClient();
assertFalse(httpClient.getHeaders().containsKey("Authorization"));
}
use of org.openhab.habdroid.util.MyHttpClient in project openhab-android by openhab.
the class DefaultConnectionTest method testSyncResolveAbsoluteUrl.
@Test
public void testSyncResolveAbsoluteUrl() {
MyHttpClient httpClient = testConnection.getSyncHttpClient();
httpClient.get("http://mylocalmachine.local/rest/test", new MyHttpClient.TextResponseHandler() {
@Override
public void onFailure(Call call, int statusCode, Headers headers, String responseBody, Throwable error) {
assertEquals("http://mylocalmachine.local/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.");
}
});
}
use of org.openhab.habdroid.util.MyHttpClient in project openhab-android by openhab.
the class DefaultConnectionTest method testSyncHasNoUsernamePassword.
@Test
public void testSyncHasNoUsernamePassword() {
MyHttpClient httpClient = testConnection.getSyncHttpClient();
assertFalse(httpClient.getHeaders().containsKey("Authorization"));
}
use of org.openhab.habdroid.util.MyHttpClient in project openhab-android by openhab.
the class DefaultConnectionTest method testSyncHasUsernamePassword.
@Test
public void testSyncHasUsernamePassword() {
Connection connection = new DefaultConnection(mockContext, mockSettings, Connection.TYPE_LOCAL, TEST_BASE_URL, "Test-User", "Test-Password");
MyHttpClient httpClient = connection.getSyncHttpClient();
assertTrue(httpClient.getHeaders().containsKey("Authorization"));
assertEquals(Credentials.basic("Test-User", "Test-Password"), httpClient.getHeaders().get("Authorization"));
}
Aggregations