19
19
import static org .junit .Assert .assertNotNull ;
20
20
import static org .junit .Assert .assertTrue ;
21
21
import static org .junit .Assert .fail ;
22
- import static org .junit .Assume .assumeFalse ;
23
22
import static org .junit .Assume .assumeTrue ;
24
23
25
24
import com .google .api .client .googleapis .auth .oauth2 .GoogleCredential ;
@@ -83,8 +82,7 @@ public void testRequest(HttpTransport transport) throws IOException {
83
82
assumeTrue (credentials != null );
84
83
GsonFactory jsonFactory = GsonFactory .getDefaultInstance ();
85
84
CloudResourceManager .Builder resourceManagerBuilder =
86
- new CloudResourceManager .Builder (
87
- transport , jsonFactory , credentials )
85
+ new CloudResourceManager .Builder (transport , jsonFactory , credentials )
88
86
.setApplicationName ("Example Java App" );
89
87
CloudResourceManager cloudResourceManager = resourceManagerBuilder .build ();
90
88
@@ -148,12 +146,7 @@ private void checkHttpClient(HttpClient client) {
148
146
149
147
@ Test
150
148
public void testRequestsWithContent () throws IOException {
151
- // This test ensures that requests that have content are rejected, as opposed to those with an
152
- // entity set.
153
- // It is currently failing because we don't perform this check in Apache5HttpRequest.execute();
154
- // TODO(diegomarquezp): find out whether this check is necessary in Apache 5.
155
- // skip for now
156
- assumeFalse (true );
149
+ // This test confirms that we can set the content on any type of request
157
150
HttpClient mockClient =
158
151
new MockHttpClient () {
159
152
@ Override
@@ -165,14 +158,11 @@ public ClassicHttpResponse executeOpen(
165
158
Apache5HttpTransport transport = new Apache5HttpTransport (mockClient );
166
159
167
160
// Test GET.
168
- subtestUnsupportedRequestsWithContent (
169
- transport .buildRequest ("GET" , "http://www.test.url" ), "GET" );
161
+ execute (transport .buildRequest ("GET" , "http://www.test.url" ));
170
162
// Test DELETE.
171
- subtestUnsupportedRequestsWithContent (
172
- transport .buildRequest ("DELETE" , "http://www.test.url" ), "DELETE" );
163
+ execute (transport .buildRequest ("DELETE" , "http://www.test.url" ));
173
164
// Test HEAD.
174
- subtestUnsupportedRequestsWithContent (
175
- transport .buildRequest ("HEAD" , "http://www.test.url" ), "HEAD" );
165
+ execute (transport .buildRequest ("HEAD" , "http://www.test.url" ));
176
166
177
167
// Test PATCH.
178
168
execute (transport .buildRequest ("PATCH" , "http://www.test.url" ));
@@ -184,19 +174,6 @@ public ClassicHttpResponse executeOpen(
184
174
execute (transport .buildRequest ("PATCH" , "http://www.test.url" ));
185
175
}
186
176
187
- private void subtestUnsupportedRequestsWithContent (Apache5HttpRequest request , String method )
188
- throws IOException {
189
- try {
190
- execute (request );
191
- fail ("expected " + IllegalStateException .class );
192
- } catch (IllegalStateException e ) {
193
- // expected
194
- assertEquals (
195
- e .getMessage (),
196
- "Apache HTTP client does not support " + method + " requests with content." );
197
- }
198
- }
199
-
200
177
private void execute (Apache5HttpRequest request ) throws IOException {
201
178
byte [] bytes = "abc" .getBytes (StandardCharsets .UTF_8 );
202
179
request .setStreamingContent (new ByteArrayStreamingContent (bytes ));
0 commit comments