Skip to content

Commit

Permalink
Add method type assertions to HttpUrlFetcherServerTest.
Browse files Browse the repository at this point in the history
Related to #2636.
  • Loading branch information
sjudd committed Nov 24, 2017
1 parent 108a062 commit 7a8d5e8
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void testReturnsInputStreamOnStatusOk() throws Exception {
fetcher.loadData(Priority.HIGH, callback);
verify(callback).onDataReady(streamCaptor.capture());
TestUtil.assertStreamOf(expected, streamCaptor.getValue());
assertThat(mockWebServer.takeRequest().getMethod()).isEqualTo("GET");
}

@Test
Expand All @@ -83,6 +84,8 @@ public void testHandlesRedirect301s() throws Exception {
getFetcher().loadData(Priority.LOW, callback);
verify(callback).onDataReady(streamCaptor.capture());
TestUtil.assertStreamOf(expected, streamCaptor.getValue());
assertThat(mockWebServer.takeRequest().getMethod()).isEqualTo("GET");
assertThat(mockWebServer.takeRequest().getMethod()).isEqualTo("GET");
}

@Test
Expand All @@ -94,6 +97,8 @@ public void testHandlesRedirect302s() throws Exception {
getFetcher().loadData(Priority.LOW, callback);
verify(callback).onDataReady(streamCaptor.capture());
TestUtil.assertStreamOf(expected, streamCaptor.getValue());
assertThat(mockWebServer.takeRequest().getMethod()).isEqualTo("GET");
assertThat(mockWebServer.takeRequest().getMethod()).isEqualTo("GET");
}

@Test
Expand All @@ -106,9 +111,11 @@ public void testHandlesRelativeRedirects() throws Exception {
verify(callback).onDataReady(streamCaptor.capture());
TestUtil.assertStreamOf(expected, streamCaptor.getValue());

mockWebServer.takeRequest();
RecordedRequest first = mockWebServer.takeRequest();
assertThat(first.getMethod()).isEqualTo("GET");
RecordedRequest second = mockWebServer.takeRequest();
assertThat(second.getPath()).endsWith("/redirect");
assertThat(second.getMethod()).isEqualTo("GET");
}

@Test
Expand All @@ -126,9 +133,13 @@ public void testHandlesUpToFiveRedirects() throws Exception {
verify(callback).onDataReady(streamCaptor.capture());
TestUtil.assertStreamOf(expected, streamCaptor.getValue());

assertThat(mockWebServer.takeRequest().getPath()).contains(DEFAULT_PATH);
RecordedRequest request = mockWebServer.takeRequest();
assertThat(request.getPath()).contains(DEFAULT_PATH);
assertThat(request.getMethod()).isEqualTo("GET");
for (int i = 0; i < numRedirects; i++) {
assertThat(mockWebServer.takeRequest().getPath()).contains(redirectBase + i);
RecordedRequest current = mockWebServer.takeRequest();
assertThat(current.getPath()).contains(redirectBase + i);
assertThat(current.getMethod()).isEqualTo("GET");
}
}

Expand Down

0 comments on commit 7a8d5e8

Please sign in to comment.