Skip to content

Commit

Permalink
Update to latest OkHttp 3.12.1 (#92)
Browse files Browse the repository at this point in the history
* Update to latest OkHttp 3.12.1

* Fix failing tests

In MockWebServer changes (3.11.0  / square/okhttp#4246) RecordedRequest is now looking for local address. So update what gets mocked in tests.

* Add leading / to paths for RecordedRequest

In MockWebServer (changes in 3.11.0 square/okhttp#4235) changes were made to RecordedRequest. It now expects a leading / for path. So update tests accordingly.

* Bump to latest dependencies in sample app

Since this is just the sample app there is probably not much danger in just bumping these to latest versions.
  • Loading branch information
Jason Atwood authored and andrzejchm committed Jan 20, 2019
1 parent 27a8dc3 commit af60a54
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions androidsample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ dependencies {
implementation "com.android.support:design:${supportVersion}"
implementation "com.jakewharton:butterknife:8.8.1"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "com.google.dagger:dagger:2.15"
implementation "com.squareup.retrofit2:retrofit:2.3.0"
implementation "com.squareup.retrofit2:converter-gson:2.3.0"
implementation "com.google.dagger:dagger:2.20"
implementation "com.squareup.retrofit2:retrofit:2.5.0"
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
implementation "com.squareup.okhttp3:logging-interceptor:${okHttpVersion}"
implementation "com.squareup.okhttp3:okhttp:${okHttpVersion}"

implementation "com.google.code.gson:gson:2.8.5"
implementation "com.google.code.findbugs:annotations:2.0.3"
compileOnly "javax.annotation:jsr250-api:1.0"
annotationProcessor "com.google.dagger:dagger-compiler:2.15"
annotationProcessor "com.google.dagger:dagger-compiler:2.20"

//Test dependencies
androidTestImplementation "com.android.support.test:runner:1.0.2"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ext {
targetSdk = 28
minSdk = 14
buildTools = "28.0.3"
okHttpVersion = "3.11.0"
okHttpVersion = "3.12.1"
supportVersion = "28.0.0"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RequestMatchersTest {
@Test
public void endingSlashNotTakenIntoAccount() throws IOException {
// given
RecordedRequest recordedRequest = createRecordedRequest("foo/bar/");
RecordedRequest recordedRequest = createRecordedRequest("/foo/bar/");

// when
RequestMatcher matcher = RequestMatchers.pathEndsWith("bar");
Expand All @@ -33,7 +33,7 @@ public void endingSlashNotTakenIntoAccount() throws IOException {
@Test
public void queryParamsAreTakenIntoAccount() throws IOException {
// given
RecordedRequest recordedRequest = createRecordedRequest("foo/bar?baz=boo");
RecordedRequest recordedRequest = createRecordedRequest("/foo/bar?baz=boo");

// when
RequestMatcher matcher = RequestMatchers.pathEndsWith("boo");
Expand All @@ -45,7 +45,7 @@ public void queryParamsAreTakenIntoAccount() throws IOException {
@Test
public void queryParamsAreIgnored() throws IOException {
// given
RecordedRequest recordedRequest = createRecordedRequest("foo/bar?baz=boo");
RecordedRequest recordedRequest = createRecordedRequest("/foo/bar?baz=boo");

// when
RequestMatcher matcher = RequestMatchers.pathEndsWithIgnoringQueryParams("bar");
Expand All @@ -57,7 +57,7 @@ public void queryParamsAreIgnored() throws IOException {
@Test
public void shouldRecognizeProperQueryParameters() throws IOException {
// given
RecordedRequest recordedRequest = createRecordedRequest("foo/bar?baz=ban");
RecordedRequest recordedRequest = createRecordedRequest("/foo/bar?baz=ban");

// when
RequestMatcher matcher = RequestMatchers.hasQueryParameters();
Expand All @@ -69,7 +69,7 @@ public void shouldRecognizeProperQueryParameters() throws IOException {
@Test
public void shouldMatchProperSubsetOfQueryParametersNames() throws IOException {
// given
RecordedRequest recordedRequest = createRecordedRequest("foo/?bar=bar&baz=baz&boo=boo");
RecordedRequest recordedRequest = createRecordedRequest("/foo/?bar=bar&baz=baz&boo=boo");

// when
RequestMatcher matcher = RequestMatchers.hasQueryParameterNames("bar", "baz");
Expand All @@ -81,7 +81,7 @@ public void shouldMatchProperSubsetOfQueryParametersNames() throws IOException {
@Test
public void shouldNotMatchInproperSubsetOfQueryParametersNames() throws IOException {
// given
RecordedRequest recordedRequest = createRecordedRequest("foo/?bar=bar&baz=baz&boo=boo");
RecordedRequest recordedRequest = createRecordedRequest("/foo/?bar=bar&baz=baz&boo=boo");

// when
RequestMatcher matcher = RequestMatchers.hasQueryParameterNames("bar", "ban");
Expand All @@ -93,7 +93,7 @@ public void shouldNotMatchInproperSubsetOfQueryParametersNames() throws IOExcept
@Test
public void hasHeaderNamesFailWhenNoHeaders() {
//given
RecordedRequest request = createRecordedRequest("path");
RecordedRequest request = createRecordedRequest("/path");

//when
RequestMatcher matcher = hasHeaderNames("header1");
Expand All @@ -105,7 +105,7 @@ public void hasHeaderNamesFailWhenNoHeaders() {
@Test
public void hasHeaderNamesSuccessWhenMatchesAll() {
//given
RecordedRequest request = createRecordedRequest("path", "h1", "v1", "h2", "v2", "h3", "v3");
RecordedRequest request = createRecordedRequest("/path", "h1", "v1", "h2", "v2", "h3", "v3");

//when
RequestMatcher matcher = hasHeaderNames("h1", "h2", "h3");
Expand All @@ -117,7 +117,7 @@ public void hasHeaderNamesSuccessWhenMatchesAll() {
@Test
public void hasHeaderNamesSuccessWhenMatchesAllAsSubset() {
//given
RecordedRequest request = createRecordedRequest("path", "h1", "v1", "h2", "v2", "h3", "v3");
RecordedRequest request = createRecordedRequest("/path", "h1", "v1", "h2", "v2", "h3", "v3");

//when
RequestMatcher matcher = hasHeaderNames("h1", "h2");
Expand All @@ -128,7 +128,7 @@ public void hasHeaderNamesSuccessWhenMatchesAllAsSubset() {

private RecordedRequest createRecordedRequest(String path, String... headerNamesAndValues) {
Socket socket = Mockito.mock(Socket.class);
when(socket.getInetAddress()).thenReturn(mock(InetAddress.class));
when(socket.getLocalAddress()).thenReturn(mock(InetAddress.class));
Headers headers = null;
if (headerNamesAndValues != null && headerNamesAndValues.length >= 2) {
headers = Headers.of(headerNamesAndValues);
Expand Down

0 comments on commit af60a54

Please sign in to comment.