mirror of https://github.com/apache/jclouds.git
Rather than rely on or work around JRE behavior based, lock S3ClientMockTest using OkHttp.
This commit is contained in:
parent
2f0725c832
commit
f238e697a0
|
@ -80,6 +80,12 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-okhttp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Set;
|
|||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.s3.domain.S3Object;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -44,13 +45,11 @@ import com.squareup.okhttp.mockwebserver.RecordedRequest;
|
|||
@Test(singleThreaded = true)
|
||||
public class S3ClientMockTest {
|
||||
|
||||
private static final Set<Module> modules = ImmutableSet.<Module> of(
|
||||
private static final Set<Module> modules = ImmutableSet.<Module> of(new OkHttpCommandExecutorServiceModule(),
|
||||
new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
|
||||
|
||||
static S3Client getS3Client(URL server) {
|
||||
Properties overrides = new Properties();
|
||||
// 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("s3")
|
||||
.credentials("accessKey", "secretKey")
|
||||
|
@ -63,8 +62,6 @@ public class S3ClientMockTest {
|
|||
public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
|
||||
MockWebServer server = new MockWebServer();
|
||||
server.enqueue(new MockResponse().addHeader(ETAG, "ABCDEF"));
|
||||
// hangs on Java 7 without this additional response ?!?
|
||||
server.enqueue(new MockResponse().addHeader(ETAG, "ABCDEF"));
|
||||
server.play();
|
||||
|
||||
S3Client client = getS3Client(server.getUrl("/"));
|
||||
|
@ -77,7 +74,6 @@ public class S3ClientMockTest {
|
|||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getRequestLine(), "PUT /bucket/object HTTP/1.1");
|
||||
assertEquals(request.getHeaders(CONTENT_LENGTH), ImmutableList.of("0"));
|
||||
// will fail unless -Dsun.net.http.allowRestrictedHeaders=true is set
|
||||
assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));
|
||||
server.shutdown();
|
||||
}
|
||||
|
@ -96,7 +92,6 @@ public class S3ClientMockTest {
|
|||
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getRequestLine(), "PUT /bucket/someDir/fileName HTTP/1.1");
|
||||
// will fail unless -Dsun.net.http.allowRestrictedHeaders=true is set
|
||||
assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));
|
||||
|
||||
server.shutdown();
|
||||
|
|
Loading…
Reference in New Issue