Skip to content

Commit 7896e93

Browse files
committed
Convert unnecessary large test to small.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=107271660
1 parent 57b3e74 commit 7896e93

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

google-http-client/src/test/java/com/google/api/client/http/javanet/NetHttpTransportTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,16 @@ public void testExecute_mock() throws Exception {
6363

6464

6565
public void testExecute_methodUnchanged() throws Exception {
66+
String body = "Arbitrary body";
67+
byte[] buf = StringUtils.getBytesUtf8(body);
6668
for (String method : METHODS) {
67-
HttpURLConnection connection =
68-
(HttpURLConnection) new URL("http://www.google.com").openConnection();
69+
HttpURLConnection connection = new MockHttpURLConnection(new URL(HttpTesting.SIMPLE_URL))
70+
.setResponseCode(200)
71+
.setInputStream(new ByteArrayInputStream(buf));
6972
connection.setRequestMethod(method);
7073
NetHttpRequest request = new NetHttpRequest(connection);
7174
setContent(request, "text/html", "");
72-
try {
73-
request.execute().getContent().close();
74-
} catch (IOException e) {
75-
// expected when not connected to network
76-
}
75+
request.execute().getContent().close();
7776
assertEquals(method, connection.getRequestMethod());
7877
}
7978
}

0 commit comments

Comments
 (0)