mirror of https://github.com/apache/jclouds.git
JCLOUDS-417: Test closing a stream w/o reading it
This commit is contained in:
parent
afc0ca557d
commit
1d218b1705
|
@ -35,6 +35,7 @@ import java.io.InputStream;
|
|||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import org.jclouds.io.ByteSources;
|
||||
|
@ -616,6 +617,27 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterruptThrottledGet() throws Exception {
|
||||
long timeoutMillis = 10 * 1000;
|
||||
MockWebServer server = mockWebServer(new MockResponse().setBody(XML).throttleBody(XML.length() / 2, timeoutMillis, TimeUnit.MILLISECONDS));
|
||||
IntegrationTestClient client = client(server.getUrl("/").toString());
|
||||
try {
|
||||
HttpResponse response = client.invoke(HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint(server.getUrl("/").toURI())
|
||||
.build());
|
||||
InputStream is = response.getPayload().getInput();
|
||||
long now = System.currentTimeMillis();
|
||||
is.close();
|
||||
long diff = System.currentTimeMillis() - now;
|
||||
assertTrue(diff < timeoutMillis / 2, "expected " + diff + " to be less than " + (timeoutMillis / 2));
|
||||
} finally {
|
||||
close(client, true);
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ByteSource getTestDataSupplier() throws IOException {
|
||||
byte[] oneConstitution = toByteArray(new GZIPInputStream(
|
||||
|
|
Loading…
Reference in New Issue