Skip to content
Permalink
Browse files
Upgrade OKHttp dependency
The JClouds project module upgrades the okhttp server library and related dependencies such as mockwebserver from 2.2.0 to 3.14.9. The vendor switched the groupId declaration from com.squareup.okhttp to com.squareup.okhttp3.

Adjust imports and api calls for newer okhttp vers
  • Loading branch information
markus-gritsch authored and gaul committed Feb 12, 2021
1 parent 2e9ae3b commit 4539cb731e540d59735f3329a40bc2505010ff8f
Showing 43 changed files with 63 additions and 63 deletions.
@@ -77,7 +77,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
<exclusions>
@@ -17,7 +17,7 @@
package org.jclouds.aliyun.ecs.compute.features;

import com.google.common.collect.Iterables;
import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import org.jclouds.aliyun.ecs.compute.internal.BaseECSComputeServiceApiMockTest;
import org.jclouds.aliyun.ecs.domain.AvailableZone;
import org.jclouds.aliyun.ecs.domain.Instance;
@@ -23,9 +23,9 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Resources;
import com.google.inject.Module;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.jclouds.ContextBuilder;
import org.jclouds.aliyun.ecs.ECSComputeServiceApi;
import org.jclouds.aliyun.ecs.ECSComputeServiceProviderMetadata;
@@ -61,7 +61,7 @@ public class BaseECSComputeServiceApiMockTest {
@BeforeMethod
public void start() throws IOException {
server = new MockWebServer();
server.play();
server.start();
ctx = ContextBuilder.newBuilder("alibaba-ecs").credentials("user", "password").endpoint(url("")).modules(modules)
.overrides(overrides()).build();
json = ctx.utils().injector().getInstance(Json.class);
@@ -81,7 +81,7 @@ protected Properties overrides() {
}

protected String url(String path) {
return server.getUrl(path).toString();
return server.url(path).toString();
}

protected MockResponse jsonResponse(String resource) {
@@ -83,7 +83,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
<exclusions>
@@ -16,7 +16,7 @@
*/
package org.jclouds.dimensiondata.cloudcontrol.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import org.jclouds.dimensiondata.cloudcontrol.internal.BaseAccountAwareCloudControlMockTest;
import org.testng.annotations.Test;

@@ -17,8 +17,8 @@
package org.jclouds.dimensiondata.cloudcontrol.features;

import com.google.common.collect.Lists;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.RecordedRequest;
import org.jclouds.dimensiondata.cloudcontrol.domain.FirewallRule;
import org.jclouds.dimensiondata.cloudcontrol.domain.FirewallRuleTarget;
import org.jclouds.dimensiondata.cloudcontrol.domain.IpRange;
@@ -17,7 +17,7 @@
package org.jclouds.dimensiondata.cloudcontrol.features;

import com.google.common.collect.Lists;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.RecordedRequest;
import org.jclouds.dimensiondata.cloudcontrol.domain.CPU;
import org.jclouds.dimensiondata.cloudcontrol.domain.Disk;
import org.jclouds.dimensiondata.cloudcontrol.domain.NIC;
@@ -17,7 +17,7 @@
package org.jclouds.dimensiondata.cloudcontrol.features;

import com.google.common.collect.ImmutableList;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.RecordedRequest;
import org.jclouds.dimensiondata.cloudcontrol.domain.Tag;
import org.jclouds.dimensiondata.cloudcontrol.domain.TagInfo;
import org.jclouds.dimensiondata.cloudcontrol.domain.TagKey;
@@ -16,7 +16,7 @@
*/
package org.jclouds.dimensiondata.cloudcontrol.internal;

import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.RecordedRequest;
import org.testng.annotations.BeforeMethod;

import javax.ws.rs.HttpMethod;
@@ -23,9 +23,9 @@
import com.google.common.io.Resources;
import com.google.gson.JsonParser;
import com.google.inject.Module;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.jclouds.ContextBuilder;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.dimensiondata.cloudcontrol.DimensionDataCloudControlApi;
@@ -79,7 +79,7 @@ public class BaseDimensionDataCloudControlMockTest implements IHookable {
@BeforeMethod
public void start() throws IOException {
server = new MockWebServer();
server.play();
server.start();
ctx = ContextBuilder.newBuilder(DimensionDataCloudControlProviderMetadata.builder().build()).credentials("", "")
.endpoint(url("")).modules(modules).overrides(new Properties()).build();
json = ctx.utils().injector().getInstance(Json.class);
@@ -135,7 +135,7 @@ public void stop() throws IOException {
}

protected String url(String path) {
return server.getUrl(path).toString();
return server.url(path).toString();
}

protected MockResponse jsonResponse(String resource) {
@@ -236,9 +236,9 @@ protected Uris.UriBuilder addZonesToUriBuilder(String zoneQueryParameter, Uris.U
return uriBuilder;
}

public byte[] payloadFromResource(String resource) {
public String payloadFromResource(String resource) {
try {
return toStringAndClose(getClass().getResourceAsStream(resource)).getBytes(Charsets.UTF_8);
return toStringAndClose(getClass().getResourceAsStream(resource));
} catch (IOException e) {
throw Throwables.propagate(e);
}
@@ -86,7 +86,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<exclusions>
<!-- Already provided by jclouds-sshj -->
@@ -24,7 +24,7 @@
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.name.Names;
import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.compute.function;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import org.apache.jclouds.oneandone.rest.domain.SingleServerAppliance;
import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneApiMockTest;
import org.jclouds.compute.domain.Image;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import org.apache.jclouds.oneandone.rest.domain.BlockStorage;
import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneApiMockTest;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.DataCenter;
import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.FirewallPolicy;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.Image;
import org.apache.jclouds.oneandone.rest.domain.Image.CreateImage;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.LoadBalancer;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.MonitoringPolicy;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.PrivateNetwork;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.PublicIp;
import org.apache.jclouds.oneandone.rest.domain.Types;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.Dvd;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.ServerAppliance;
import org.apache.jclouds.oneandone.rest.domain.SingleServerAppliance;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.ArrayList;
import java.util.List;
import org.apache.jclouds.oneandone.rest.domain.SharedStorage;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import org.apache.jclouds.oneandone.rest.domain.SshKey;
import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneApiMockTest;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.oneandone.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.List;
import java.util.zip.ZipInputStream;
import org.apache.jclouds.oneandone.rest.domain.Vpn;
@@ -23,8 +23,8 @@
import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService;
import com.google.gson.JsonParser;
import com.google.inject.Module;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
@@ -53,7 +53,7 @@ public class BaseOneAndOneApiMockTest {
@BeforeMethod
public void start() throws IOException {
server = new MockWebServer();
server.play();
server.start();
ApiContext<OneAndOneApi> ctx = ContextBuilder.newBuilder("oneandone")
.credentials("token", "token")
.endpoint(url(""))
@@ -75,7 +75,7 @@ protected Properties overrides() {
}

protected String url(String path) {
return server.getUrl(path).toString();
return server.url(path).toString();
}

protected String stringFromResource(String resourceName) {
@@ -104,7 +104,7 @@ protected RecordedRequest assertSent(MockWebServer server, String method, String
String expectedContentType = "application/json";

assertEquals(request.getHeader("Content-Type"), expectedContentType);
assertEquals(parser.parse(new String(request.getBody(), Charsets.UTF_8)), parser.parse(json));
assertEquals(parser.parse(request.getBody().readUtf8()), parser.parse(json));
return request;
}
}
@@ -86,7 +86,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<exclusions>
<!-- Already provided by jclouds-sshj -->
@@ -17,7 +17,7 @@
package org.apache.jclouds.profitbricks.rest.compute.config;

import com.google.common.base.Predicate;
import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.concurrent.TimeUnit;
import org.apache.jclouds.profitbricks.rest.compute.config.ProfitBricksComputeServiceContextModule.DataCenterProvisioningStatePredicate;
import org.apache.jclouds.profitbricks.rest.compute.config.ProfitBricksComputeServiceContextModule.ServerStatusPredicate;
@@ -18,7 +18,7 @@

import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableSet;
import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.Set;
import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest;
import org.jclouds.compute.domain.Image;
@@ -23,7 +23,7 @@
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.name.Names;
import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import java.util.Set;
import org.apache.jclouds.profitbricks.rest.ProfitBricksApi;
import org.apache.jclouds.profitbricks.rest.ProfitBricksApiMetadata;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.profitbricks.rest.compute.function;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;
import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest;
import org.jclouds.compute.domain.Volume;
import org.jclouds.compute.domain.VolumeBuilder;
@@ -16,7 +16,7 @@
*/
package org.apache.jclouds.profitbricks.rest.features;

import com.squareup.okhttp.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockResponse;

import java.net.URI;
import java.util.List;