-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/test/java/com/squareup/shipfaster/okhttp/OkHttpTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.squareup.shipfaster.okhttp; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
import retrofit.RestAdapter; | ||
import retrofit.client.Client; | ||
import retrofit.client.OkClient; | ||
|
||
import static org.fest.assertions.api.Assertions.assertThat; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
public class OkHttpTest { | ||
|
||
/** | ||
* This test relies on the internals of RetroFit. It's not really needed, but it demonstrates | ||
* that RetroFit uses OkHttp when it's in the classpath. | ||
*/ | ||
@Test public void retrofit_uses_okhttp() throws Exception { | ||
Field clientProviderField = RestAdapter.class.getDeclaredField("clientProvider"); | ||
clientProviderField.setAccessible(true); | ||
Method get = Client.Provider.class.getDeclaredMethod("get"); | ||
|
||
RestAdapter adapter = new RestAdapter.Builder().setServer("https://squareup.com").build(); | ||
Object clientProvider = clientProviderField.get(adapter); | ||
Object client = get.invoke(clientProvider); | ||
|
||
assertThat(client).isInstanceOf(OkClient.class); | ||
} | ||
} |