File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
google-http-client/src/test/java/com/google/api/client/http/javanet Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -63,17 +63,16 @@ public void testExecute_mock() throws Exception {
63
63
64
64
65
65
public void testExecute_methodUnchanged () throws Exception {
66
+ String body = "Arbitrary body" ;
67
+ byte [] buf = StringUtils .getBytesUtf8 (body );
66
68
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 ));
69
72
connection .setRequestMethod (method );
70
73
NetHttpRequest request = new NetHttpRequest (connection );
71
74
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 ();
77
76
assertEquals (method , connection .getRequestMethod ());
78
77
}
79
78
}
You can’t perform that action at this time.
0 commit comments