mirror of https://github.com/apache/jclouds.git
Prefer Charsets.UTF_8 over string literal
Found with modernizer-maven-plugin.
This commit is contained in:
parent
2db654fbe3
commit
dc3011469b
|
@ -34,6 +34,7 @@ import org.jclouds.ContextBuilder;
|
|||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.util.Strings2;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
|
@ -223,7 +224,7 @@ public class BaseOpenStackMockTest<A extends Closeable> {
|
|||
JsonElement requestJson = null; // to be compared
|
||||
JsonElement resourceJson; // to be compared
|
||||
try {
|
||||
requestJson = parser.parse(new String(request.getBody(), "UTF-8"));
|
||||
requestJson = parser.parse(new String(request.getBody(), Charsets.UTF_8));
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.testng.annotations.BeforeClass;
|
|||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
@ -299,7 +300,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
String result = client.post("", "foo");
|
||||
// Verify that the body is properly populated
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
assertEquals(result, "fooPOST");
|
||||
} finally {
|
||||
close(client, true);
|
||||
|
@ -315,7 +316,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
client.postNothing("");
|
||||
assertEquals(server.getRequestCount(), 1);
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "");
|
||||
} finally {
|
||||
close(client, true);
|
||||
server.shutdown();
|
||||
|
@ -333,9 +334,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
assertEquals(result, "fooPOST");
|
||||
// Verify that the body was properly sent in the two requests
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
} finally {
|
||||
close(client, true);
|
||||
server.shutdown();
|
||||
|
@ -356,9 +357,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
assertEquals(redirectTarget.getRequestCount(), 1);
|
||||
// Verify that the body was populated after the redirect
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
request = redirectTarget.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
} finally {
|
||||
close(client, true);
|
||||
redirectTarget.shutdown();
|
||||
|
@ -374,7 +375,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
String result = client.postAsInputStream("", "foo");
|
||||
// Verify that the body is properly populated
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
assertEquals(result, "fooPOST");
|
||||
} finally {
|
||||
close(client, true);
|
||||
|
@ -405,7 +406,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
String result = client.postJson("", "foo");
|
||||
// Verify that the body is properly populated
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "{\"key\":\"foo\"}");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "{\"key\":\"foo\"}");
|
||||
assertEquals(result, "fooPOSTJSON");
|
||||
} finally {
|
||||
close(client, true);
|
||||
|
@ -491,7 +492,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
String result = client.upload("", "foo");
|
||||
// Verify that the body is properly populated
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
assertEquals(result, "fooPUT");
|
||||
} finally {
|
||||
close(client, true);
|
||||
|
@ -513,9 +514,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
assertEquals(redirectTarget.getRequestCount(), 1);
|
||||
// Verify that the body was populated after the redirect
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
request = redirectTarget.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
} finally {
|
||||
close(client, true);
|
||||
redirectTarget.shutdown();
|
||||
|
@ -531,7 +532,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
client.putNothing("");
|
||||
assertEquals(server.getRequestCount(), 1);
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "");
|
||||
} finally {
|
||||
close(client, true);
|
||||
server.shutdown();
|
||||
|
@ -549,9 +550,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
assertEquals(result, "fooPUT");
|
||||
// Verify that the body was properly sent in the two requests
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
request = server.takeRequest();
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
} finally {
|
||||
close(client, true);
|
||||
server.shutdown();
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.jclouds.rest.annotations.PATCH;
|
|||
import org.jclouds.rest.binders.BindToStringPayload;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.Module;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
||||
|
@ -80,7 +81,7 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
|
|||
// Verify that the body is properly populated
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getMethod(), "PATCH");
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
assertEquals(result, "fooPATCH");
|
||||
} finally {
|
||||
close(api, true);
|
||||
|
@ -100,10 +101,10 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
|
|||
// Verify that the body was properly sent in the two requests
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getMethod(), "PATCH");
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
request = server.takeRequest();
|
||||
assertEquals(request.getMethod(), "PATCH");
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
} finally {
|
||||
close(api, true);
|
||||
server.shutdown();
|
||||
|
@ -125,10 +126,10 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
|
|||
// Verify that the body was populated after the redirect
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getMethod(), "PATCH");
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
request = redirectTarget.takeRequest();
|
||||
assertEquals(request.getMethod(), "PATCH");
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "foo");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "foo");
|
||||
} finally {
|
||||
close(api, true);
|
||||
redirectTarget.shutdown();
|
||||
|
@ -145,7 +146,7 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
|
|||
assertEquals(server.getRequestCount(), 1);
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getMethod(), "PATCH");
|
||||
assertEquals(new String(request.getBody(), "UTF-8"), "");
|
||||
assertEquals(new String(request.getBody(), Charsets.UTF_8), "");
|
||||
} finally {
|
||||
close(api, true);
|
||||
server.shutdown();
|
||||
|
|
Loading…
Reference in New Issue