mirror of https://github.com/apache/jclouds.git
address bug where expect-100 continue can hang things
This commit is contained in:
parent
e16c7ba40c
commit
fc39b2b92b
|
@ -18,14 +18,22 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3;
|
||||
|
||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||
import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
|
||||
import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
|
||||
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.TargetExistsException;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
import com.google.mockwebserver.MockResponse;
|
||||
import com.google.mockwebserver.MockWebServer;
|
||||
|
||||
|
@ -36,8 +44,18 @@ import com.google.mockwebserver.MockWebServer;
|
|||
@Test(singleThreaded = true)
|
||||
public class DynectApiMockTest {
|
||||
|
||||
static RestContext<DynECTApi, DynECTAsyncApi> getContext(String uri) {
|
||||
return ContextBuilder.newBuilder("dynect").credentials("jclouds:joe", "letmein").endpoint(uri).build();
|
||||
static DynECTApi mockDynectApi(String uri) {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_CONNECTION_TIMEOUT, "1000");
|
||||
// prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
|
||||
overrides.setProperty(PROPERTY_SO_TIMEOUT, "0");
|
||||
overrides.setProperty(PROPERTY_MAX_RETRIES, "1");
|
||||
return ContextBuilder.newBuilder("dynect")
|
||||
.credentials("jclouds:joe", "letmein")
|
||||
.endpoint(uri)
|
||||
.overrides(overrides)
|
||||
.modules(ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())))
|
||||
.build(DynECTApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
}
|
||||
|
||||
String session = "{\"status\": \"success\", \"data\": {\"token\": \"FFFFFFFFFF\", \"version\": \"3.3.8\"}, \"job_id\": 254417252, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}";
|
||||
|
@ -51,7 +69,7 @@ public class DynectApiMockTest {
|
|||
server.enqueue(new MockResponse().setResponseCode(200).setBody(running));
|
||||
server.play();
|
||||
|
||||
DynECTApi api = getContext(server.getUrl("/").toString()).getApi();
|
||||
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
||||
|
||||
try {
|
||||
api.getZoneApi().list();
|
||||
|
@ -70,7 +88,7 @@ public class DynectApiMockTest {
|
|||
server.enqueue(new MockResponse().setResponseCode(200).setBody(taskBlocking));
|
||||
server.play();
|
||||
|
||||
DynECTApi api = getContext(server.getUrl("/").toString()).getApi();
|
||||
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
||||
|
||||
try {
|
||||
api.getZoneApi().list();
|
||||
|
@ -88,7 +106,7 @@ public class DynectApiMockTest {
|
|||
server.enqueue(new MockResponse().setResponseCode(200).setBody(targetExists));
|
||||
server.play();
|
||||
|
||||
DynECTApi api = getContext(server.getUrl("/").toString()).getApi();
|
||||
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
||||
|
||||
try {
|
||||
api.getZoneApi().list();
|
||||
|
|
Loading…
Reference in New Issue