diff --git a/pom.xml b/pom.xml index c851389c..7a431128 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 1.80 0.12.0 8.5.15 - 33.3.1-jre + 33.4.8-jre 7.0.0 2.18.3 3.30.2-GA diff --git a/src/main/java/com/arpnetworking/http/Routes.java b/src/main/java/com/arpnetworking/http/Routes.java index 70dda997..a32522a2 100644 --- a/src/main/java/com/arpnetworking/http/Routes.java +++ b/src/main/java/com/arpnetworking/http/Routes.java @@ -30,7 +30,6 @@ import com.arpnetworking.steno.LogBuilder; import com.arpnetworking.steno.Logger; import com.arpnetworking.steno.LoggerFactory; -import com.google.common.base.Charsets; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; @@ -62,6 +61,7 @@ import org.apache.pekko.util.Timeout; import java.io.Serial; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Objects; import java.util.Optional; @@ -388,7 +388,7 @@ private String createMetricName(final HttpRequest request, final int responseSta static { String statusJson = "{}"; try { - statusJson = Resources.toString(Resources.getResource("status.json"), Charsets.UTF_8); + statusJson = Resources.toString(Resources.getResource("status.json"), StandardCharsets.UTF_8); // CHECKSTYLE.OFF: IllegalCatch - Prevent program shutdown } catch (final Exception e) { // CHECKSTYLE.ON: IllegalCatch diff --git a/src/main/java/com/arpnetworking/metrics/mad/Main.java b/src/main/java/com/arpnetworking/metrics/mad/Main.java index e4f232b8..688d2782 100644 --- a/src/main/java/com/arpnetworking/metrics/mad/Main.java +++ b/src/main/java/com/arpnetworking/metrics/mad/Main.java @@ -43,7 +43,6 @@ import com.arpnetworking.utility.Launchable; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -81,6 +80,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -290,7 +290,7 @@ private HttpsConnectionContext createHttpsContext() { final PrivateKey privateKey; try (PEMParser keyReader = new PEMParser( new InputStreamReader( - new FileInputStream(_configuration.getHttpsKeyPath()), Charsets.UTF_8))) { + new FileInputStream(_configuration.getHttpsKeyPath()), StandardCharsets.UTF_8))) { final Object keyObject = keyReader.readObject(); if (keyObject instanceof PrivateKeyInfo) { @@ -309,7 +309,7 @@ private HttpsConnectionContext createHttpsContext() { final X509Certificate cert; try (PEMParser certReader = new PEMParser( new InputStreamReader( - new FileInputStream(_configuration.getHttpsCertificatePath()), Charsets.UTF_8))) { + new FileInputStream(_configuration.getHttpsCertificatePath()), StandardCharsets.UTF_8))) { final PemObject certObject = certReader.readPemObject(); final CertificateFactory cf = CertificateFactory.getInstance("X.509"); cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(certObject.getContent())); diff --git a/src/main/java/com/arpnetworking/metrics/mad/parsers/GraphitePlaintextToRecordParser.java b/src/main/java/com/arpnetworking/metrics/mad/parsers/GraphitePlaintextToRecordParser.java index 38057803..c77a7171 100644 --- a/src/main/java/com/arpnetworking/metrics/mad/parsers/GraphitePlaintextToRecordParser.java +++ b/src/main/java/com/arpnetworking/metrics/mad/parsers/GraphitePlaintextToRecordParser.java @@ -24,7 +24,6 @@ import com.arpnetworking.metrics.mad.model.DefaultRecord; import com.arpnetworking.metrics.mad.model.MetricType; import com.arpnetworking.metrics.mad.model.Record; -import com.google.common.base.Charsets; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -33,6 +32,7 @@ import net.sf.oval.constraint.NotNull; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.text.NumberFormat; import java.text.ParseException; import java.time.Instant; @@ -95,14 +95,14 @@ public final class GraphitePlaintextToRecordParser implements Parser parse(final ByteBuffer record) throws ParsingException { // CHECKSTYLE.OFF: IllegalInstantiation - This is the recommended way - final String line = new String(record.array(), Charsets.UTF_8); + final String line = new String(record.array(), StandardCharsets.UTF_8); // CHECKSTYLE.ON: IllegalInstantiation final ImmutableList.Builder recordListBuilder = ImmutableList.builder(); final ZonedDateTime now = ZonedDateTime.now(); final Matcher matcher = GRAPHITE_PATTERN.matcher(line); if (!matcher.matches()) { - throw new ParsingException("Invalid graphite line", line.getBytes(Charsets.UTF_8)); + throw new ParsingException("Invalid graphite line", line.getBytes(StandardCharsets.UTF_8)); } // Annotations diff --git a/src/main/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParser.java b/src/main/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParser.java index 1bf39885..bea1dfe0 100644 --- a/src/main/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParser.java +++ b/src/main/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParser.java @@ -24,7 +24,6 @@ import com.arpnetworking.metrics.mad.model.MetricType; import com.arpnetworking.metrics.mad.model.Record; import com.arpnetworking.metrics.mad.model.Unit; -import com.google.common.base.Charsets; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; @@ -34,6 +33,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.text.NumberFormat; import java.text.ParseException; import java.time.Clock; @@ -76,14 +76,14 @@ public final class StatsdToRecordParser implements Parser, ByteBuff @Override public List parse(final ByteBuffer datagram) throws ParsingException { // CHECKSTYLE.OFF: IllegalInstantiation - This is the recommended way - final String datagramAsString = new String(datagram.array(), Charsets.UTF_8); + final String datagramAsString = new String(datagram.array(), StandardCharsets.UTF_8); final ImmutableList.Builder recordListBuilder = ImmutableList.builder(); try { for (final String line : LINE_SPLITTER.split(datagramAsString)) { // CHECKSTYLE.ON: IllegalInstantiation final Matcher matcher = STATSD_PATTERN.matcher(line); if (!matcher.matches()) { - throw new ParsingException("Invalid statsd line", line.getBytes(Charsets.UTF_8)); + throw new ParsingException("Invalid statsd line", line.getBytes(StandardCharsets.UTF_8)); } // Parse the name diff --git a/src/main/java/com/arpnetworking/metrics/proxy/models/messages/LogLine.java b/src/main/java/com/arpnetworking/metrics/proxy/models/messages/LogLine.java index 3cbf4ec5..69874048 100644 --- a/src/main/java/com/arpnetworking/metrics/proxy/models/messages/LogLine.java +++ b/src/main/java/com/arpnetworking/metrics/proxy/models/messages/LogLine.java @@ -18,12 +18,12 @@ import com.arpnetworking.logback.annotations.Loggable; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.google.common.base.Charsets; import com.google.common.base.MoreObjects; import com.google.common.primitives.Bytes; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.Collections; import java.util.List; @@ -68,7 +68,7 @@ public List getLine() { * @return The line data as a {@link String} interpreted as UTF-8. */ public String convertLineToString() { - return convertLineToString(Charsets.UTF_8); + return convertLineToString(StandardCharsets.UTF_8); } /** diff --git a/src/main/java/com/arpnetworking/tsdcore/sinks/HttpPostSinkActor.java b/src/main/java/com/arpnetworking/tsdcore/sinks/HttpPostSinkActor.java index 7a4d3ec5..b468f170 100644 --- a/src/main/java/com/arpnetworking/tsdcore/sinks/HttpPostSinkActor.java +++ b/src/main/java/com/arpnetworking/tsdcore/sinks/HttpPostSinkActor.java @@ -23,7 +23,6 @@ import com.arpnetworking.steno.LoggerFactory; import com.arpnetworking.tsdcore.model.PeriodicData; import com.arpnetworking.tsdcore.model.RequestEntry; -import com.google.common.base.Charsets; import com.google.common.collect.EvictingQueue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -37,6 +36,7 @@ import org.asynchttpclient.Response; import scala.concurrent.duration.FiniteDuration; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.Instant; import java.util.Collection; @@ -233,7 +233,7 @@ private void processRejectedRequest(final PostRejected rejected) { final Optional responseBody = Optional.ofNullable(response.getResponseBody()); final byte[] requestBodyBytes = rejected.getRequest().getByteData(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - final String requestBody = requestBodyBytes == null ? null : new String(requestBodyBytes, Charsets.UTF_8); + final String requestBody = requestBodyBytes == null ? null : new String(requestBodyBytes, StandardCharsets.UTF_8); // CHECKSTYLE.ON: IllegalInstantiation LOGGER.warn() .setMessage("Post rejected") diff --git a/src/test/java/com/arpnetworking/configuration/DirectoryTriggerTest.java b/src/test/java/com/arpnetworking/configuration/DirectoryTriggerTest.java index bb28e54c..a36d09ea 100644 --- a/src/test/java/com/arpnetworking/configuration/DirectoryTriggerTest.java +++ b/src/test/java/com/arpnetworking/configuration/DirectoryTriggerTest.java @@ -16,13 +16,13 @@ package com.arpnetworking.configuration; import com.arpnetworking.configuration.triggers.DirectoryTrigger; -import com.google.common.base.Charsets; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Optional; import java.util.regex.Pattern; @@ -112,7 +112,7 @@ public void testDirectoryChangedFileCreated() throws IOException { Assert.assertTrue(trigger.evaluateAndReset()); Assert.assertFalse(trigger.evaluateAndReset()); - Files.write(directory.toPath().resolve("foo.txt"), "bar".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.txt"), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertTrue(trigger.evaluateAndReset()); } @@ -134,7 +134,7 @@ public void testDirectoryChangedFileModified() throws IOException, InterruptedEx // Ensure file system modified time reflects the change Thread.sleep(1000); - Files.write(file.toPath(), "bar".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertTrue(trigger.evaluateAndReset()); } @@ -145,7 +145,7 @@ public void testDirectoryChangedFileDeleted() throws IOException { deleteDirectory(directory); Files.createDirectory(directory.toPath()); final File file = directory.toPath().resolve("foo.txt").toFile(); - Files.write(file.toPath(), "bar".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "bar".getBytes(StandardCharsets.UTF_8)); final Trigger trigger = new DirectoryTrigger.Builder() .setDirectory(directory) @@ -173,10 +173,10 @@ public void testOnlyMatchedName() throws IOException { Assert.assertTrue(trigger.evaluateAndReset()); Assert.assertFalse(trigger.evaluateAndReset()); - Files.write(directory.toPath().resolve("foo.txt"), "bar".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.txt"), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertFalse(trigger.evaluateAndReset()); - Files.write(directory.toPath().resolve("bar.txt"), "bar".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("bar.txt"), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertTrue(trigger.evaluateAndReset()); } @@ -194,10 +194,10 @@ public void testOnlyMatchedNamePattern() throws IOException { Assert.assertTrue(trigger.evaluateAndReset()); Assert.assertFalse(trigger.evaluateAndReset()); - Files.write(directory.toPath().resolve("foo.txt"), "bar".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.txt"), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertFalse(trigger.evaluateAndReset()); - Files.write(directory.toPath().resolve("foo.json"), "bar".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.json"), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertTrue(trigger.evaluateAndReset()); } diff --git a/src/test/java/com/arpnetworking/configuration/FileTriggerTest.java b/src/test/java/com/arpnetworking/configuration/FileTriggerTest.java index 160afa48..bee63785 100644 --- a/src/test/java/com/arpnetworking/configuration/FileTriggerTest.java +++ b/src/test/java/com/arpnetworking/configuration/FileTriggerTest.java @@ -16,13 +16,13 @@ package com.arpnetworking.configuration; import com.arpnetworking.configuration.triggers.FileTrigger; -import com.google.common.base.Charsets; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.attribute.FileTime; @@ -116,7 +116,7 @@ public void testFileCreated() throws IOException { public void testFileChanged() throws IOException, InterruptedException { final File file = new File("./target/tmp/filter/FileTriggerTest/testFileChanged"); Files.deleteIfExists(file.toPath()); - Files.write(file.toPath(), "foo".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "foo".getBytes(StandardCharsets.UTF_8)); final Trigger trigger = new FileTrigger.Builder() .setFile(file) @@ -127,7 +127,7 @@ public void testFileChanged() throws IOException, InterruptedException { // Ensure file system modified time reflects the change Thread.sleep(1000); - Files.write(file.toPath(), "bar".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "bar".getBytes(StandardCharsets.UTF_8)); Assert.assertTrue(trigger.evaluateAndReset()); } @@ -136,7 +136,7 @@ public void testFileChanged() throws IOException, InterruptedException { public void testFileChangedLastModifiedOnly() throws IOException { final File file = new File("./target/tmp/filter/FileTriggerTest/testFileChangedLastModifiedOnly"); Files.deleteIfExists(file.toPath()); - Files.write(file.toPath(), "foo".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "foo".getBytes(StandardCharsets.UTF_8)); Files.setLastModifiedTime(file.toPath(), FileTime.fromMillis(1418112007000L)); final Trigger trigger = new FileTrigger.Builder() diff --git a/src/test/java/com/arpnetworking/configuration/jackson/HoconFileSourceTest.java b/src/test/java/com/arpnetworking/configuration/jackson/HoconFileSourceTest.java index ecf6ce84..e28da14f 100644 --- a/src/test/java/com/arpnetworking/configuration/jackson/HoconFileSourceTest.java +++ b/src/test/java/com/arpnetworking/configuration/jackson/HoconFileSourceTest.java @@ -15,7 +15,6 @@ */ package com.arpnetworking.configuration.jackson; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableSet; import com.typesafe.config.impl.ConfigImpl; import org.junit.Assert; @@ -24,6 +23,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.attribute.PosixFilePermission; @@ -54,7 +54,7 @@ public void testFileDoesNotExist() throws IOException { @Test public void testFileUnreadable() throws IOException { final File file = new File("./target/tmp/filter/HoconFileSourceTest/testFileUnreadable.json"); - Files.write(file.toPath(), "foo=\"bar\"".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "foo=\"bar\"".getBytes(StandardCharsets.UTF_8)); Files.setPosixFilePermissions(file.toPath(), ImmutableSet.of(PosixFilePermission.OWNER_WRITE)); final HoconFileSource source = new HoconFileSource.Builder() .setFile(file) @@ -65,7 +65,7 @@ public void testFileUnreadable() throws IOException { @Test public void testValidHocon() throws IOException { final File file = new File("./target/tmp/filter/HoconFileSourceTest/testValidHocon.conf"); - Files.write(file.toPath(), "foo:\"bar\"".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "foo:\"bar\"".getBytes(StandardCharsets.UTF_8)); final HoconFileSource source = new HoconFileSource.Builder() .setFile(file) .build(); @@ -77,7 +77,7 @@ public void testValidHocon() throws IOException { @Test public void testSystemPropertyDirect() throws IOException { final File file = new File("./target/tmp/filter/HoconFileSourceTest/testSystemPropertyDirect.hocon"); - Files.write(file.toPath(), "".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "".getBytes(StandardCharsets.UTF_8)); final HoconFileSource source = new HoconFileSource.Builder() .setFile(file) .build(); @@ -88,7 +88,7 @@ public void testSystemPropertyDirect() throws IOException { @Test public void testSystemPropertyReference() throws IOException { final File file = new File("./target/tmp/filter/HoconFileSourceTest/testSystemPropertyReference.hocon"); - Files.write(file.toPath(), "foo:${HoconFileSourceTest_testSystemPropertyReference_foo}".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "foo:${HoconFileSourceTest_testSystemPropertyReference_foo}".getBytes(StandardCharsets.UTF_8)); final HoconFileSource source = new HoconFileSource.Builder() .setFile(file) .build(); @@ -99,7 +99,7 @@ public void testSystemPropertyReference() throws IOException { @Test(expected = RuntimeException.class) public void testInvalidHocon() throws IOException { final File file = new File("./target/tmp/filter/HoconFileSourceTest/testInvalidHocon.json"); - Files.write(file.toPath(), "This=\"not-hocon".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "This=\"not-hocon".getBytes(StandardCharsets.UTF_8)); new HoconFileSource.Builder() .setFile(file) .build(); diff --git a/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeDirectorySourceTest.java b/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeDirectorySourceTest.java index 92cca2fa..f0471766 100644 --- a/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeDirectorySourceTest.java +++ b/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeDirectorySourceTest.java @@ -17,13 +17,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.google.common.base.Charsets; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Objects; import java.util.Optional; @@ -66,8 +66,8 @@ public void testDirectoryAll() throws IOException { final File directory = new File("./target/tmp/filter/JsonNodeDirectorySourceTest/testDirectoryAll"); deleteDirectory(directory); Files.createDirectory(directory.toPath()); - Files.write(directory.toPath().resolve("foo.json"), "[\"one\"]".getBytes(Charsets.UTF_8)); - Files.write(directory.toPath().resolve("bar.txt"), "[\"two\"]".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.json"), "[\"one\"]".getBytes(StandardCharsets.UTF_8)); + Files.write(directory.toPath().resolve("bar.txt"), "[\"two\"]".getBytes(StandardCharsets.UTF_8)); final JsonNodeDirectorySource source = new JsonNodeDirectorySource.Builder() .setDirectory(directory) .build(); @@ -84,8 +84,8 @@ public void testDirectoryOnlyMatchingNames() throws IOException { final File directory = new File("./target/tmp/filter/JsonNodeDirectorySourceTest/testDirectoryOnlyMatchingNames"); deleteDirectory(directory); Files.createDirectory(directory.toPath()); - Files.write(directory.toPath().resolve("foo.json"), "[\"one\"]".getBytes(Charsets.UTF_8)); - Files.write(directory.toPath().resolve("bar.txt"), "[\"two\"]".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.json"), "[\"one\"]".getBytes(StandardCharsets.UTF_8)); + Files.write(directory.toPath().resolve("bar.txt"), "[\"two\"]".getBytes(StandardCharsets.UTF_8)); final JsonNodeDirectorySource source = new JsonNodeDirectorySource.Builder() .setDirectory(directory) .addFileName("foo.json") @@ -102,8 +102,8 @@ public void testDirectoryOnlyMatchingNamePatterns() throws IOException { final File directory = new File("./target/tmp/filter/JsonNodeDirectorySourceTest/testDirectoryOnlyMatchingNamePatterns"); deleteDirectory(directory); Files.createDirectory(directory.toPath()); - Files.write(directory.toPath().resolve("foo.json"), "[\"one\"]".getBytes(Charsets.UTF_8)); - Files.write(directory.toPath().resolve("bar.txt"), "[\"two\"]".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.json"), "[\"one\"]".getBytes(StandardCharsets.UTF_8)); + Files.write(directory.toPath().resolve("bar.txt"), "[\"two\"]".getBytes(StandardCharsets.UTF_8)); final JsonNodeDirectorySource source = new JsonNodeDirectorySource.Builder() .setDirectory(directory) .addFileNamePattern(Pattern.compile(".*\\.json")) @@ -120,8 +120,8 @@ public void testInvalidJson() throws IOException { final File directory = new File("./target/tmp/filter/JsonNodeDirectorySourceTest/testInvalidJson.json"); deleteDirectory(directory); Files.createDirectory(directory.toPath()); - Files.write(directory.toPath().resolve("foo.json"), "this=not-json".getBytes(Charsets.UTF_8)); - Files.write(directory.toPath().resolve("bar.txt"), "\"two\"".getBytes(Charsets.UTF_8)); + Files.write(directory.toPath().resolve("foo.json"), "this=not-json".getBytes(StandardCharsets.UTF_8)); + Files.write(directory.toPath().resolve("bar.txt"), "\"two\"".getBytes(StandardCharsets.UTF_8)); new JsonNodeDirectorySource.Builder() .setDirectory(directory) .build(); diff --git a/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeFileSourceTest.java b/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeFileSourceTest.java index 03035b33..e9b0fc1b 100644 --- a/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeFileSourceTest.java +++ b/src/test/java/com/arpnetworking/configuration/jackson/JsonNodeFileSourceTest.java @@ -15,7 +15,6 @@ */ package com.arpnetworking.configuration.jackson; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableSet; import org.junit.Assert; import org.junit.BeforeClass; @@ -23,6 +22,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.attribute.PosixFilePermission; @@ -50,7 +50,7 @@ public void testFileDoesNotExist() throws IOException { @Test public void testFileUnreadable() throws IOException { final File file = new File("./target/tmp/filter/JsonNodeFileSourceTest/testFileUnreadable.json"); - Files.write(file.toPath(), "{\"foo\":\"bar\"}".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "{\"foo\":\"bar\"}".getBytes(StandardCharsets.UTF_8)); Files.setPosixFilePermissions(file.toPath(), ImmutableSet.of(PosixFilePermission.OWNER_WRITE)); final JsonNodeFileSource source = new JsonNodeFileSource.Builder() .setFile(file) @@ -61,7 +61,7 @@ public void testFileUnreadable() throws IOException { @Test public void testValidJson() throws IOException { final File file = new File("./target/tmp/filter/JsonNodeFileSourceTest/testValidJson.json"); - Files.write(file.toPath(), "{\"foo\":\"bar\"}".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "{\"foo\":\"bar\"}".getBytes(StandardCharsets.UTF_8)); final JsonNodeFileSource source = new JsonNodeFileSource.Builder() .setFile(file) .build(); @@ -73,7 +73,7 @@ public void testValidJson() throws IOException { @Test(expected = RuntimeException.class) public void testInvalidJson() throws IOException { final File file = new File("./target/tmp/filter/JsonNodeFileSourceTest/testInvalidJson.json"); - Files.write(file.toPath(), "This=not-json".getBytes(Charsets.UTF_8)); + Files.write(file.toPath(), "This=not-json".getBytes(StandardCharsets.UTF_8)); new JsonNodeFileSource.Builder() .setFile(file) .build(); diff --git a/src/test/java/com/arpnetworking/metrics/common/sources/CollectdHttpSourceV1Test.java b/src/test/java/com/arpnetworking/metrics/common/sources/CollectdHttpSourceV1Test.java index f0e1bf9c..e72625c1 100644 --- a/src/test/java/com/arpnetworking/metrics/common/sources/CollectdHttpSourceV1Test.java +++ b/src/test/java/com/arpnetworking/metrics/common/sources/CollectdHttpSourceV1Test.java @@ -22,7 +22,6 @@ import com.arpnetworking.metrics.incubator.PeriodicMetrics; import com.arpnetworking.metrics.mad.model.Record; import com.arpnetworking.test.TestBeanFactory; -import com.google.common.base.Charsets; import com.google.common.collect.Lists; import org.apache.pekko.actor.ActorRef; import org.apache.pekko.http.javadsl.model.HttpRequest; @@ -37,6 +36,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -72,7 +72,7 @@ public void after() throws Exception { @Test public void testParsesEntity() throws ParsingException { - final byte[] entity = "not a json document".getBytes(Charsets.UTF_8); + final byte[] entity = "not a json document".getBytes(StandardCharsets.UTF_8); Mockito.when(_parser.parse(Mockito.any())).thenThrow(new ParsingException("test exception", new byte[0])); dispatchRequest(HttpRequest.create().withEntity(entity).addHeader(RawHeader.create("x-tag-foo", "bar"))); final ArgumentCaptor captor = diff --git a/src/test/java/com/arpnetworking/metrics/common/sources/FileSourceTest.java b/src/test/java/com/arpnetworking/metrics/common/sources/FileSourceTest.java index 856812a2..62752efe 100644 --- a/src/test/java/com/arpnetworking/metrics/common/sources/FileSourceTest.java +++ b/src/test/java/com/arpnetworking/metrics/common/sources/FileSourceTest.java @@ -21,7 +21,6 @@ import com.arpnetworking.metrics.common.tailer.InitialPosition; import com.arpnetworking.steno.LogBuilder; import com.arpnetworking.steno.Logger; -import com.google.common.base.Charsets; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.Assert; import org.junit.Before; @@ -32,6 +31,7 @@ import java.io.IOException; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -80,7 +80,7 @@ public void testParseData() throws IOException, InterruptedException, ParsingExc Files.deleteIfExists(state); final String expectedData = "Expected Data"; - Mockito.when(_parser.parse(expectedData.getBytes(Charsets.UTF_8))).thenReturn(expectedData); + Mockito.when(_parser.parse(expectedData.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -95,10 +95,10 @@ public void testParseData() throws IOException, InterruptedException, ParsingExc Files.write( file, - (expectedData + "\n").getBytes(Charsets.UTF_8), + (expectedData + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); - Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(Charsets.UTF_8)); + Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(StandardCharsets.UTF_8)); Mockito.verify(_observer, Mockito.timeout(TIMEOUT)).notify(source, expectedData); source.stop(); } @@ -113,13 +113,13 @@ public void testTailFromEnd() throws IOException, InterruptedException, ParsingE final String unexpectedData = "Unexpected Data"; Files.write( file, - (unexpectedData + "\n").getBytes(Charsets.UTF_8), + (unexpectedData + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); - Mockito.when(_parser.parse(unexpectedData.getBytes(Charsets.UTF_8))) + Mockito.when(_parser.parse(unexpectedData.getBytes(StandardCharsets.UTF_8))) .thenThrow(new AssertionError("should not tail from beginning of file")); - Mockito.when(_parser.parse(expectedData.getBytes(Charsets.UTF_8))).thenReturn(expectedData); + Mockito.when(_parser.parse(expectedData.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -136,13 +136,13 @@ public void testTailFromEnd() throws IOException, InterruptedException, ParsingE Files.write( file, - (expectedData + "\n").getBytes(Charsets.UTF_8), + (expectedData + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); - Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(Charsets.UTF_8)); + Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(StandardCharsets.UTF_8)); Mockito.verify(_observer, Mockito.timeout(TIMEOUT)).notify(source, expectedData); source.stop(); - Mockito.verify(_parser, Mockito.never()).parse(unexpectedData.getBytes(Charsets.UTF_8)); + Mockito.verify(_parser, Mockito.never()).parse(unexpectedData.getBytes(StandardCharsets.UTF_8)); } @Test @@ -196,7 +196,7 @@ public void testTailerLogRotationRename() throws IOException, InterruptedExcepti Files.createFile(file); Files.deleteIfExists(state); - Files.write(file, "Existing data in the log file\n".getBytes(Charsets.UTF_8)); + Files.write(file, "Existing data in the log file\n".getBytes(StandardCharsets.UTF_8)); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -227,7 +227,7 @@ public void testTailerLogRotationRenameSameDataLength() throws IOException, Inte final String data1 = "Existing data in the log file\n"; final String data2 = "new data in the log file \n"; - Files.write(file, data1.getBytes(Charsets.UTF_8)); + Files.write(file, data1.getBytes(StandardCharsets.UTF_8)); Files.setLastModifiedTime(file, FileTime.from(Instant.now().minus(10, ChronoUnit.DAYS))); final FileSource source = new FileSource<>( @@ -245,7 +245,7 @@ public void testTailerLogRotationRenameSameDataLength() throws IOException, Inte renameRotate(file); Files.createFile(file); - Files.write(file, data2.getBytes(Charsets.UTF_8)); + Files.write(file, data2.getBytes(StandardCharsets.UTF_8)); Files.setLastModifiedTime(file, FileTime.from(Instant.now())); Mockito.verify(_logBuilder, Mockito.timeout(TIMEOUT)).setMessage("Tailer file rotate"); @@ -288,7 +288,7 @@ public void testTailerLogRotationCopyTruncate() throws IOException, InterruptedE Files.createFile(file); Files.deleteIfExists(state); - Files.write(file, "Existing data in the log file\n".getBytes(Charsets.UTF_8)); + Files.write(file, "Existing data in the log file\n".getBytes(StandardCharsets.UTF_8)); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -348,7 +348,7 @@ public void testTailerLogRotationRenameWithData() throws IOException, Interrupte Files.deleteIfExists(state); final String expectedData = "Expected Data"; - Mockito.when(_parser.parse(expectedData.getBytes(Charsets.UTF_8))).thenReturn(expectedData); + Mockito.when(_parser.parse(expectedData.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -365,12 +365,12 @@ public void testTailerLogRotationRenameWithData() throws IOException, Interrupte Files.write( file, - (expectedData + "\n").getBytes(Charsets.UTF_8), + (expectedData + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); renameRotate(file); Files.createFile(file); - Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(Charsets.UTF_8)); + Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(StandardCharsets.UTF_8)); Mockito.verify(_observer, Mockito.timeout(TIMEOUT)).notify(source, expectedData); Mockito.verify(_logBuilder, Mockito.timeout(TIMEOUT)).setMessage(Mockito.contains("Tailer file rotate")); source.stop(); @@ -392,7 +392,7 @@ public void testTailerLogRotationCopyTruncateWithData() throws IOException, Inte Files.deleteIfExists(state); final String expectedData = "Expected Data"; - Mockito.when(_parser.parse(expectedData.getBytes(Charsets.UTF_8))).thenReturn(expectedData); + Mockito.when(_parser.parse(expectedData.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -408,7 +408,7 @@ public void testTailerLogRotationCopyTruncateWithData() throws IOException, Inte Thread.sleep(sleepInterval); Files.write( file, - (expectedData + "\n").getBytes(Charsets.UTF_8), + (expectedData + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); copyRotate(file); truncate(file); @@ -416,7 +416,7 @@ public void testTailerLogRotationCopyTruncateWithData() throws IOException, Inte Mockito.verifyNoInteractions(_observer); Thread.sleep(3 * sleepInterval); - Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(Charsets.UTF_8)); + Mockito.verify(_parser, Mockito.timeout(TIMEOUT)).parse(expectedData.getBytes(StandardCharsets.UTF_8)); Mockito.verify(_observer, Mockito.timeout(TIMEOUT)).notify(source, expectedData); Mockito.verify(_logBuilder, Mockito.timeout(TIMEOUT)).setMessage(Mockito.contains("Tailer file rotate")); source.stop(); @@ -432,8 +432,8 @@ public void testTailerLogRotationRenameWithDataToOldAndNew() throws IOException, final String expectedData1 = "Expected Data 1 must be larger"; final String expectedData2 = "Expected Data 2"; - Mockito.when(_parser.parse(expectedData1.getBytes(Charsets.UTF_8))).thenReturn(expectedData1); - Mockito.when(_parser.parse(expectedData2.getBytes(Charsets.UTF_8))).thenReturn(expectedData2); + Mockito.when(_parser.parse(expectedData1.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData1); + Mockito.when(_parser.parse(expectedData2.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData2); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -450,13 +450,13 @@ public void testTailerLogRotationRenameWithDataToOldAndNew() throws IOException, Files.write( file, - (expectedData1 + "\n").getBytes(Charsets.UTF_8), + (expectedData1 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); renameRotate(file); Files.createFile(file); Files.write( file, - (expectedData2 + "\n").getBytes(Charsets.UTF_8), + (expectedData2 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); final ArgumentCaptor parserCapture = ArgumentCaptor.forClass(byte[].class); @@ -465,10 +465,10 @@ public void testTailerLogRotationRenameWithDataToOldAndNew() throws IOException, Mockito.verify(_parser, Mockito.timeout(TIMEOUT).times(2)).parse(parserCapture.capture()); final List parserValues = parserCapture.getAllValues(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - Assert.assertTrue("actual=" + new String(parserValues.get(0), Charsets.UTF_8), - Arrays.equals(expectedData1.getBytes(Charsets.UTF_8), parserValues.get(0))); - Assert.assertTrue("actual=" + new String(parserValues.get(1), Charsets.UTF_8), - Arrays.equals(expectedData2.getBytes(Charsets.UTF_8), parserValues.get(1))); + Assert.assertTrue("actual=" + new String(parserValues.get(0), StandardCharsets.UTF_8), + Arrays.equals(expectedData1.getBytes(StandardCharsets.UTF_8), parserValues.get(0))); + Assert.assertTrue("actual=" + new String(parserValues.get(1), StandardCharsets.UTF_8), + Arrays.equals(expectedData2.getBytes(StandardCharsets.UTF_8), parserValues.get(1))); // CHECKSTYLE.ON: IllegalInstantiation Mockito.verify(_observer, Mockito.timeout(TIMEOUT).times(2)).notify(Mockito.eq(source), notifyCapture.capture()); @@ -498,8 +498,8 @@ public void testTailerLogRotationCopyTruncateWithDataToOldAndNew() throws IOExce final String expectedData1 = "Expected Data 1 must be larger"; final String expectedData2 = "Expected Data 2"; - Mockito.when(_parser.parse(expectedData1.getBytes(Charsets.UTF_8))).thenReturn(expectedData1); - Mockito.when(_parser.parse(expectedData2.getBytes(Charsets.UTF_8))).thenReturn(expectedData2); + Mockito.when(_parser.parse(expectedData1.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData1); + Mockito.when(_parser.parse(expectedData2.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData2); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -516,13 +516,13 @@ public void testTailerLogRotationCopyTruncateWithDataToOldAndNew() throws IOExce Files.write( file, - (expectedData1 + "\n").getBytes(Charsets.UTF_8), + (expectedData1 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); copyRotate(file); truncate(file); Files.write( file, - (expectedData2 + "\n").getBytes(Charsets.UTF_8), + (expectedData2 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); final ArgumentCaptor parserCapture = ArgumentCaptor.forClass(byte[].class); @@ -531,10 +531,10 @@ public void testTailerLogRotationCopyTruncateWithDataToOldAndNew() throws IOExce Mockito.verify(_parser, Mockito.timeout(TIMEOUT).times(2)).parse(parserCapture.capture()); final List parserValues = parserCapture.getAllValues(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - Assert.assertTrue("actual=" + new String(parserValues.get(0), Charsets.UTF_8), - Arrays.equals(expectedData1.getBytes(Charsets.UTF_8), parserValues.get(0))); - Assert.assertTrue("actual=" + new String(parserValues.get(1), Charsets.UTF_8), - Arrays.equals(expectedData2.getBytes(Charsets.UTF_8), parserValues.get(1))); + Assert.assertTrue("actual=" + new String(parserValues.get(0), StandardCharsets.UTF_8), + Arrays.equals(expectedData1.getBytes(StandardCharsets.UTF_8), parserValues.get(0))); + Assert.assertTrue("actual=" + new String(parserValues.get(1), StandardCharsets.UTF_8), + Arrays.equals(expectedData2.getBytes(StandardCharsets.UTF_8), parserValues.get(1))); // CHECKSTYLE.ON: IllegalInstantiation Mockito.verify(_observer, Mockito.timeout(TIMEOUT).times(2)).notify(source, notifyCapture.capture()); @@ -557,9 +557,9 @@ public void testTailerLogRotationRenameDroppedData() throws IOException, Interru final String expectedData1 = "Expected Data 1 must be larger"; final String expectedData2 = "Expected Data 2 plus"; final String expectedData3 = "Expected Data 3"; - Mockito.when(_parser.parse(expectedData1.getBytes(Charsets.UTF_8))).thenReturn(expectedData1); - Mockito.when(_parser.parse(expectedData2.getBytes(Charsets.UTF_8))).thenReturn(expectedData2); - Mockito.when(_parser.parse(expectedData3.getBytes(Charsets.UTF_8))).thenReturn(expectedData3); + Mockito.when(_parser.parse(expectedData1.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData1); + Mockito.when(_parser.parse(expectedData2.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData2); + Mockito.when(_parser.parse(expectedData3.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData3); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -576,17 +576,17 @@ public void testTailerLogRotationRenameDroppedData() throws IOException, Interru Files.write( file, - (expectedData1 + "\n").getBytes(Charsets.UTF_8), + (expectedData1 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); Files.write( file, - (expectedData2 + "\n").getBytes(Charsets.UTF_8), + (expectedData2 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); renameRotate(file); Files.createFile(file); Files.write( file, - (expectedData3 + "\n").getBytes(Charsets.UTF_8), + (expectedData3 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); final ArgumentCaptor parserCapture = ArgumentCaptor.forClass(byte[].class); @@ -595,12 +595,12 @@ public void testTailerLogRotationRenameDroppedData() throws IOException, Interru Mockito.verify(_parser, Mockito.timeout(TIMEOUT).times(3)).parse(parserCapture.capture()); final List parserValues = parserCapture.getAllValues(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - Assert.assertTrue("actual=" + new String(parserValues.get(0), Charsets.UTF_8), - Arrays.equals(expectedData1.getBytes(Charsets.UTF_8), parserValues.get(0))); - Assert.assertTrue("actual=" + new String(parserValues.get(1), Charsets.UTF_8), - Arrays.equals(expectedData2.getBytes(Charsets.UTF_8), parserValues.get(1))); - Assert.assertTrue("actual=" + new String(parserValues.get(2), Charsets.UTF_8), - Arrays.equals(expectedData3.getBytes(Charsets.UTF_8), parserValues.get(2))); + Assert.assertTrue("actual=" + new String(parserValues.get(0), StandardCharsets.UTF_8), + Arrays.equals(expectedData1.getBytes(StandardCharsets.UTF_8), parserValues.get(0))); + Assert.assertTrue("actual=" + new String(parserValues.get(1), StandardCharsets.UTF_8), + Arrays.equals(expectedData2.getBytes(StandardCharsets.UTF_8), parserValues.get(1))); + Assert.assertTrue("actual=" + new String(parserValues.get(2), StandardCharsets.UTF_8), + Arrays.equals(expectedData3.getBytes(StandardCharsets.UTF_8), parserValues.get(2))); // CHECKSTYLE.ON: IllegalInstantiation Mockito.verify(_observer, Mockito.timeout(TIMEOUT).times(3)).notify(Mockito.eq(source), notifyCapture.capture()); @@ -633,9 +633,9 @@ public void testTailerLogCopyTruncateRenameDroppedData() throws IOException, Int final String expectedData1 = "Expected Data 1 must be larger"; final String expectedData2 = "Expected Data 2 plus"; final String expectedData3 = "Expected Data 3"; - Mockito.when(_parser.parse(expectedData1.getBytes(Charsets.UTF_8))).thenReturn(expectedData1); - Mockito.when(_parser.parse(expectedData2.getBytes(Charsets.UTF_8))).thenReturn(expectedData2); - Mockito.when(_parser.parse(expectedData3.getBytes(Charsets.UTF_8))).thenReturn(expectedData3); + Mockito.when(_parser.parse(expectedData1.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData1); + Mockito.when(_parser.parse(expectedData2.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData2); + Mockito.when(_parser.parse(expectedData3.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData3); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -650,18 +650,18 @@ public void testTailerLogCopyTruncateRenameDroppedData() throws IOException, Int Files.write( file, - (expectedData1 + "\n").getBytes(Charsets.UTF_8), + (expectedData1 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); Thread.sleep(sleepInterval); Files.write( file, - (expectedData2 + "\n").getBytes(Charsets.UTF_8), + (expectedData2 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); copyRotate(file); truncate(file); Files.write( file, - (expectedData3 + "\n").getBytes(Charsets.UTF_8), + (expectedData3 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); Thread.sleep(3 * sleepInterval); @@ -671,12 +671,12 @@ public void testTailerLogCopyTruncateRenameDroppedData() throws IOException, Int Mockito.verify(_parser, Mockito.timeout(TIMEOUT).times(3)).parse(parserCapture.capture()); final List parserValues = parserCapture.getAllValues(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - Assert.assertTrue("actual=" + new String(parserValues.get(0), Charsets.UTF_8), - Arrays.equals(expectedData1.getBytes(Charsets.UTF_8), parserValues.get(0))); - Assert.assertTrue("actual=" + new String(parserValues.get(1), Charsets.UTF_8), - Arrays.equals(expectedData2.getBytes(Charsets.UTF_8), parserValues.get(1))); - Assert.assertTrue("actual=" + new String(parserValues.get(2), Charsets.UTF_8), - Arrays.equals(expectedData3.getBytes(Charsets.UTF_8), parserValues.get(2))); + Assert.assertTrue("actual=" + new String(parserValues.get(0), StandardCharsets.UTF_8), + Arrays.equals(expectedData1.getBytes(StandardCharsets.UTF_8), parserValues.get(0))); + Assert.assertTrue("actual=" + new String(parserValues.get(1), StandardCharsets.UTF_8), + Arrays.equals(expectedData2.getBytes(StandardCharsets.UTF_8), parserValues.get(1))); + Assert.assertTrue("actual=" + new String(parserValues.get(2), StandardCharsets.UTF_8), + Arrays.equals(expectedData3.getBytes(StandardCharsets.UTF_8), parserValues.get(2))); // CHECKSTYLE.ON: IllegalInstantiation Mockito.verify(_observer, Mockito.timeout(TIMEOUT).times(3)).notify(Mockito.eq(source), notifyCapture.capture()); @@ -699,8 +699,8 @@ public void testTailerLogRotationRenameSmallToLarge() throws IOException, Interr final String expectedData1 = "Expected Data 1 small"; final String expectedData2 = "Expected Data 2 must be larger"; - Mockito.when(_parser.parse(expectedData1.getBytes(Charsets.UTF_8))).thenReturn(expectedData1); - Mockito.when(_parser.parse(expectedData2.getBytes(Charsets.UTF_8))).thenReturn(expectedData2); + Mockito.when(_parser.parse(expectedData1.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData1); + Mockito.when(_parser.parse(expectedData2.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData2); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -717,13 +717,13 @@ public void testTailerLogRotationRenameSmallToLarge() throws IOException, Interr Files.write( file, - (expectedData1 + "\n").getBytes(Charsets.UTF_8), + (expectedData1 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); renameRotate(file); Files.createFile(file); Files.write( file, - (expectedData2 + "\n").getBytes(Charsets.UTF_8), + (expectedData2 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); final ArgumentCaptor parserCapture = ArgumentCaptor.forClass(byte[].class); @@ -732,10 +732,10 @@ public void testTailerLogRotationRenameSmallToLarge() throws IOException, Interr Mockito.verify(_parser, Mockito.timeout(TIMEOUT).times(2)).parse(parserCapture.capture()); final List parserValues = parserCapture.getAllValues(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - Assert.assertTrue("actual=" + new String(parserCapture.getValue(), Charsets.UTF_8), - Arrays.equals(expectedData1.getBytes(Charsets.UTF_8), parserValues.get(0))); - Assert.assertTrue("actual=" + new String(parserCapture.getValue(), Charsets.UTF_8), - Arrays.equals(expectedData2.getBytes(Charsets.UTF_8), parserValues.get(1))); + Assert.assertTrue("actual=" + new String(parserCapture.getValue(), StandardCharsets.UTF_8), + Arrays.equals(expectedData1.getBytes(StandardCharsets.UTF_8), parserValues.get(0))); + Assert.assertTrue("actual=" + new String(parserCapture.getValue(), StandardCharsets.UTF_8), + Arrays.equals(expectedData2.getBytes(StandardCharsets.UTF_8), parserValues.get(1))); // CHECKSTYLE.ON: IllegalInstantiation Mockito.verify(_observer, Mockito.timeout(TIMEOUT).times(2)).notify(Mockito.eq(source), notifyCapture.capture()); @@ -768,8 +768,8 @@ public void testTailerLogRotationCopyTruncateSmallToLarge() throws IOException, final String expectedData1 = "Expected Data 1 small"; final String expectedData2 = "Expected Data 2 must be larger"; - Mockito.when(_parser.parse(expectedData1.getBytes(Charsets.UTF_8))).thenReturn(expectedData1); - Mockito.when(_parser.parse(expectedData2.getBytes(Charsets.UTF_8))).thenReturn(expectedData2); + Mockito.when(_parser.parse(expectedData1.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData1); + Mockito.when(_parser.parse(expectedData2.getBytes(StandardCharsets.UTF_8))).thenReturn(expectedData2); final FileSource source = new FileSource<>( new FileSource.Builder<>() @@ -784,14 +784,14 @@ public void testTailerLogRotationCopyTruncateSmallToLarge() throws IOException, Files.write( file, - (expectedData1 + "\n").getBytes(Charsets.UTF_8), + (expectedData1 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); Thread.sleep(sleepInterval); copyRotate(file); truncate(file); Files.write( file, - (expectedData2 + "\n").getBytes(Charsets.UTF_8), + (expectedData2 + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND, StandardOpenOption.WRITE, StandardOpenOption.SYNC); Thread.sleep(3 * sleepInterval); @@ -801,10 +801,10 @@ public void testTailerLogRotationCopyTruncateSmallToLarge() throws IOException, Mockito.verify(_parser, Mockito.timeout(TIMEOUT).times(2)).parse(parserCapture.capture()); final List parserValues = parserCapture.getAllValues(); // CHECKSTYLE.OFF: IllegalInstantiation - This is ok for String from byte[] - Assert.assertTrue("actual=" + new String(parserValues.get(0), Charsets.UTF_8), - Arrays.equals(expectedData1.getBytes(Charsets.UTF_8), parserValues.get(0))); - Assert.assertTrue("actual=" + new String(parserValues.get(1), Charsets.UTF_8), - Arrays.equals(expectedData2.getBytes(Charsets.UTF_8), parserValues.get(1))); + Assert.assertTrue("actual=" + new String(parserValues.get(0), StandardCharsets.UTF_8), + Arrays.equals(expectedData1.getBytes(StandardCharsets.UTF_8), parserValues.get(0))); + Assert.assertTrue("actual=" + new String(parserValues.get(1), StandardCharsets.UTF_8), + Arrays.equals(expectedData2.getBytes(StandardCharsets.UTF_8), parserValues.get(1))); // CHECKSTYLE.ON: IllegalInstantiation Mockito.verify(_observer, Mockito.timeout(TIMEOUT).times(2)).notify(Mockito.eq(source), notifyCapture.capture()); diff --git a/src/test/java/com/arpnetworking/metrics/common/sources/KafkaSourceTest.java b/src/test/java/com/arpnetworking/metrics/common/sources/KafkaSourceTest.java index 0dd04750..69cb6ace 100644 --- a/src/test/java/com/arpnetworking/metrics/common/sources/KafkaSourceTest.java +++ b/src/test/java/com/arpnetworking/metrics/common/sources/KafkaSourceTest.java @@ -23,7 +23,6 @@ import com.arpnetworking.steno.Logger; import com.arpnetworking.test.CollectorPeriodicMetrics; import com.arpnetworking.test.StringToRecordParser; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -41,6 +40,7 @@ import org.mockito.stubbing.Answer; import java.io.Serial; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.ArrayList; import java.util.Collections; @@ -222,7 +222,7 @@ public void testSourceRuntimeExceptionBackoffSuccess() { @Test public void testSourceParsingException() throws ParsingException { final ParsingException exception = - new ParsingException("Could not parse data", "bad_data".getBytes(Charsets.UTF_8)); + new ParsingException("Could not parse data", "bad_data".getBytes(StandardCharsets.UTF_8)); createBadParsingSource(exception); final Observer observer = Mockito.mock(Observer.class); _source.attach(observer); diff --git a/src/test/java/com/arpnetworking/metrics/common/tailer/StatefulTailerTest.java b/src/test/java/com/arpnetworking/metrics/common/tailer/StatefulTailerTest.java index 64ae0ac6..6e17b269 100644 --- a/src/test/java/com/arpnetworking/metrics/common/tailer/StatefulTailerTest.java +++ b/src/test/java/com/arpnetworking/metrics/common/tailer/StatefulTailerTest.java @@ -17,7 +17,6 @@ package com.arpnetworking.metrics.common.tailer; import com.arpnetworking.utility.ManualSingleThreadedTrigger; -import com.google.common.base.Charsets; import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; @@ -28,6 +27,7 @@ import java.io.BufferedWriter; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -70,7 +70,7 @@ public void setUp() throws IOException { @Test public void testReadData() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 10, expectedValues); } @@ -87,7 +87,7 @@ public void testReadData() throws IOException, InterruptedException { Mockito.verify(_listener, Mockito.never()).handle(Mockito.any(Throwable.class)); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @@ -98,7 +98,7 @@ public void testReadDataAfterFileCreation() throws IOException, InterruptedExcep _readTrigger.waitForWait(); final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 10, expectedValues); } @@ -116,14 +116,14 @@ public void testReadDataAfterFileCreation() throws IOException, InterruptedExcep Mockito.verify(_listener, Mockito.atLeastOnce()).fileNotFound(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testReadDataDifferentLineTerminators() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { for (int i = 0; i < 12; ++i) { final String value = UUID.randomUUID().toString(); expectedValues.add(value); @@ -150,13 +150,13 @@ public void testReadDataDifferentLineTerminators() throws IOException, Interrupt Mockito.verify(_listener).initialize(_tailer); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testTailData() throws IOException, InterruptedException { - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { _executor.execute(_tailer); Mockito.verify(_listener).initialize(_tailer); @@ -169,7 +169,7 @@ public void testTailData() throws IOException, InterruptedException { writer.flush(); _readTrigger.releaseTrigger(); _readTrigger.waitForWait(); - Mockito.verify(_listener).handle(value.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(value.getBytes(StandardCharsets.UTF_8)); } _readTrigger.disable(); @@ -188,7 +188,7 @@ public void testTailData() throws IOException, InterruptedException { public void testReadDataWithZeroOffset() throws IOException, InterruptedException { Mockito.when(_positionStore.getPosition(Mockito.anyString())).thenReturn(Optional.of(0L)); - final BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW); + final BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW); final List expectedValues = Lists.newArrayList(); writeUuids(writer, 5, expectedValues); @@ -209,13 +209,13 @@ public void testReadDataWithZeroOffset() throws IOException, InterruptedExceptio _executor.awaitTermination(EXECUTOR_TERMINATE_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testReadDataWithNonZeroOffsetInSmallFile() throws IOException, InterruptedException { - final BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW); + final BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW); // Insufficient data for hash; 5 * (36 + 1) = 185 bytes; 20 UUIDs of 36 characters plus line break final List expectedValues = Lists.newArrayList(); @@ -241,7 +241,7 @@ public void testReadDataWithNonZeroOffsetInSmallFile() throws IOException, Inter Mockito.verify(_listener).initialize(_tailer); Mockito.verify(_listener).fileOpened(); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } Mockito.verifyNoMoreInteractions(_listener); } @@ -252,7 +252,7 @@ public void testReadDataWithNonZeroOffsetInLargeFile() throws IOException, Inter Mockito.when(_positionStore.getPosition(Mockito.anyString())).thenReturn(Optional.of(555L)); Mockito.doNothing().when(_positionStore).setPosition(Mockito.anyString(), Mockito.anyLong()); - final BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW); + final BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW); final List expectedValues = Lists.newArrayList(); for (int i = 0; i < 15; ++i) { @@ -280,7 +280,7 @@ public void testReadDataWithNonZeroOffsetInLargeFile() throws IOException, Inter Mockito.verify(_listener).initialize(_tailer); Mockito.verify(_listener).fileOpened(); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } Mockito.verifyNoMoreInteractions(_listener); } @@ -288,7 +288,7 @@ public void testReadDataWithNonZeroOffsetInLargeFile() throws IOException, Inter @Test public void testRotateCopyTruncateLessData() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } @@ -304,7 +304,7 @@ public void testRotateCopyTruncateLessData() throws IOException, InterruptedExce // NOTE: This ensures the reader does not read duplicate data either from the old or new file // Write _less_ data to the new file - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { writeUuids(writer, 4, expectedValues); } @@ -325,14 +325,14 @@ public void testRotateCopyTruncateLessData() throws IOException, InterruptedExce Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateCopyTruncateEqualLengthData() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } final BasicFileAttributes attributes = Files.readAttributes(_file, BasicFileAttributes.class); @@ -353,7 +353,7 @@ public void testRotateCopyTruncateEqualLengthData() throws IOException, Interrup _readTrigger.waitForWait(); // Write _same length_ of data to the new file - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { writeUuids(writer, 5, expectedValues); } @@ -377,7 +377,7 @@ public void testRotateCopyTruncateEqualLengthData() throws IOException, Interrup Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @@ -393,7 +393,7 @@ public void testRotateCopyTruncateMoreData() throws IOException, InterruptedExce // ** IMPORTANT ** final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } @@ -413,7 +413,7 @@ public void testRotateCopyTruncateMoreData() throws IOException, InterruptedExce _readTrigger.waitForWait(); // Write _same_ data to the new file - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { for (int i = 0; i < 5; ++i) { writer.write(UUID.randomUUID().toString() + "\n"); } @@ -436,14 +436,14 @@ public void testRotateCopyTruncateMoreData() throws IOException, InterruptedExce Mockito.verify(_listener).initialize(_tailer); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateLessData() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } @@ -463,7 +463,7 @@ public void testRotateRenameRecreateLessData() throws IOException, InterruptedEx _readTrigger.waitForWait(); // Write _less_ data to the new file - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 4, expectedValues); } @@ -484,13 +484,13 @@ public void testRotateRenameRecreateLessData() throws IOException, InterruptedEx Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateLessDataWriteToOldAfterRotate() throws IOException, InterruptedException { - final BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW); + final BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW); final List expectedValues = Lists.newArrayList(); writeUuids(writerOld, 5, expectedValues); @@ -511,7 +511,7 @@ public void testRotateRenameRecreateLessDataWriteToOldAfterRotate() throws IOExc writerOld.close(); // Write _less_ data to the new file - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerNew, 4, expectedValues); } @@ -532,13 +532,13 @@ public void testRotateRenameRecreateLessDataWriteToOldAfterRotate() throws IOExc Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateLessDataWriteToOldAfterRotateNoDelay() throws IOException, InterruptedException { - final BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW); + final BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW); final List expectedValues = Lists.newArrayList(); writeUuids(writerOld, 5, expectedValues); @@ -555,7 +555,7 @@ public void testRotateRenameRecreateLessDataWriteToOldAfterRotateNoDelay() throw writerOld.close(); // Write _less_ data to the new file - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerNew, 4, expectedValues); } @@ -580,14 +580,14 @@ public void testRotateRenameRecreateLessDataWriteToOldAfterRotateNoDelay() throw Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateEqualData() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } final BasicFileAttributes attributes = Files.readAttributes(_file, BasicFileAttributes.class); @@ -608,7 +608,7 @@ public void testRotateRenameRecreateEqualData() throws IOException, InterruptedE _readTrigger.waitForWait(); // Write _less_ data to the new file - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } @@ -633,14 +633,14 @@ public void testRotateRenameRecreateEqualData() throws IOException, InterruptedE Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateEqualDataWriteToOldAfterRotate() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerOld, 5, expectedValues); _executor.execute(_tailer); @@ -660,7 +660,7 @@ public void testRotateRenameRecreateEqualDataWriteToOldAfterRotate() throws IOEx } // Write _equal_ data to the new file - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerNew, 10, expectedValues); } @@ -681,14 +681,14 @@ public void testRotateRenameRecreateEqualDataWriteToOldAfterRotate() throws IOEx Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateEqualDataWriteToOldAfterRotateNoDelay() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerOld, 5, expectedValues); _executor.execute(_tailer); @@ -704,7 +704,7 @@ public void testRotateRenameRecreateEqualDataWriteToOldAfterRotateNoDelay() thro } // Write _equal_ data to the new file - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerNew, 10, expectedValues); } @@ -725,14 +725,14 @@ public void testRotateRenameRecreateEqualDataWriteToOldAfterRotateNoDelay() thro Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateMoreData() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } @@ -753,7 +753,7 @@ public void testRotateRenameRecreateMoreData() throws IOException, InterruptedEx _readTrigger.waitForWait(); // Write _more_ data to the new file - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 10, expectedValues); } @@ -774,14 +774,14 @@ public void testRotateRenameRecreateMoreData() throws IOException, InterruptedEx Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateMoreDataWithCheckpointing() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 5, expectedValues); } @@ -801,7 +801,7 @@ public void testRotateRenameRecreateMoreDataWithCheckpointing() throws IOExcepti _readTrigger.waitForWait(); // Write data to the new file sufficient to checkpoint - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writer, 15, expectedValues); } @@ -822,14 +822,14 @@ public void testRotateRenameRecreateMoreDataWithCheckpointing() throws IOExcepti Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.atLeastOnce()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateMoreDataWriteToOldAfterRotate() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerOld, 5, expectedValues); _executor.execute(_tailer); @@ -846,7 +846,7 @@ public void testRotateRenameRecreateMoreDataWriteToOldAfterRotate() throws IOExc } // Write data to the new file - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerNew, 11, expectedValues); } @@ -866,14 +866,14 @@ public void testRotateRenameRecreateMoreDataWriteToOldAfterRotate() throws IOExc Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @Test public void testRotateRenameRecreateMoreDataWriteToOldAfterRotateNoDelay() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerOld, 5, expectedValues); _executor.execute(_tailer); @@ -889,7 +889,7 @@ public void testRotateRenameRecreateMoreDataWriteToOldAfterRotateNoDelay() throw writeUuids(writerOld, 5, expectedValues); } - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { // Write _more_ data to the new file writeUuids(writerNew, 11, expectedValues); } @@ -910,7 +910,7 @@ public void testRotateRenameRecreateMoreDataWriteToOldAfterRotateNoDelay() throw Mockito.verify(_listener).fileRotated(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } } @@ -927,7 +927,7 @@ public void testFailureToRotate() throws IOException, InterruptedException { // ** IMPORTANT ** final List expectedValues = Lists.newArrayList(); - try (BufferedWriter writerOld = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerOld = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(writerOld, 5, expectedValues); } final BasicFileAttributes attributes = Files.readAttributes(_file, BasicFileAttributes.class); @@ -942,7 +942,7 @@ public void testFailureToRotate() throws IOException, InterruptedException { Files.move(_file, oldFile.toPath()); // Write _exact same_ data to the new file - try (BufferedWriter writerNew = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writerNew = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { for (int i = 0; i < 5; ++i) { writerNew.write(expectedValues.get(i) + "\n"); } @@ -966,7 +966,7 @@ public void testFailureToRotate() throws IOException, InterruptedException { Mockito.verify(_listener).fileOpened(); Mockito.verify(_positionStore, Mockito.never()).getPosition(Mockito.anyString()); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } // BUG 1: File rotation is not detected @@ -996,7 +996,7 @@ public void testTailFromEnd() throws IOException, InterruptedException { final List expectedValues = Lists.newArrayList(); _tailer = new StatefulTailer(builder, _readTrigger); Mockito.doNothing().when(_positionStore).setPosition(Mockito.anyString(), Mockito.anyLong()); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { for (int i = 0; i < 15; ++i) { writer.write(UUID.randomUUID().toString() + "\n"); } @@ -1021,7 +1021,7 @@ public void testTailFromEnd() throws IOException, InterruptedException { Mockito.verify(_listener).fileOpened(); Mockito.verify(_listener).initialize(_tailer); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } Mockito.verifyNoMoreInteractions(_listener); } @@ -1041,7 +1041,7 @@ public void testTailFromEndFirstFileOnly() throws IOException, InterruptedExcept _tailer = new StatefulTailer(builder, _readTrigger); Mockito.doNothing().when(_positionStore).setPosition(Mockito.anyString(), Mockito.anyLong()); - try (BufferedWriter writer = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter writer = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { for (int i = 0; i < 15; ++i) { writer.write(UUID.randomUUID().toString() + "\n"); @@ -1060,7 +1060,7 @@ public void testTailFromEndFirstFileOnly() throws IOException, InterruptedExcept Files.move(_file, oldFile.toPath()); // Write _more_ data to the new file - try (BufferedWriter newWriter = Files.newBufferedWriter(_file, Charsets.UTF_8, StandardOpenOption.CREATE_NEW)) { + try (BufferedWriter newWriter = Files.newBufferedWriter(_file, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { writeUuids(newWriter, 10, expectedValues); } @@ -1085,7 +1085,7 @@ public void testTailFromEndFirstFileOnly() throws IOException, InterruptedExcept Mockito.verify(_listener, Mockito.times(2)).fileOpened(); Mockito.verify(_listener).fileRotated(); for (final String expectedValue : expectedValues) { - Mockito.verify(_listener).handle(expectedValue.getBytes(Charsets.UTF_8)); + Mockito.verify(_listener).handle(expectedValue.getBytes(StandardCharsets.UTF_8)); } Mockito.verifyNoMoreInteractions(_listener); } diff --git a/src/test/java/com/arpnetworking/metrics/mad/parsers/LineDataTest.java b/src/test/java/com/arpnetworking/metrics/mad/parsers/LineDataTest.java index fd78d1c9..abb7c9f7 100644 --- a/src/test/java/com/arpnetworking/metrics/mad/parsers/LineDataTest.java +++ b/src/test/java/com/arpnetworking/metrics/mad/parsers/LineDataTest.java @@ -17,10 +17,11 @@ package com.arpnetworking.metrics.mad.parsers; import com.arpnetworking.metrics.common.parsers.exceptions.ParsingException; -import com.google.common.base.Charsets; import org.junit.Assert; import org.junit.Test; +import java.nio.charset.StandardCharsets; + /** * Tests for query line parsing. * @@ -37,7 +38,7 @@ public void constructTest() { @Test(expected = ParsingException.class) public void parseUnknownVersion() throws ParsingException { final JsonToRecordParser data = new JsonToRecordParser.Builder().build(); - data.parse(UNKNOWN_VERSION_JSON.getBytes(Charsets.UTF_8)); + data.parse(UNKNOWN_VERSION_JSON.getBytes(StandardCharsets.UTF_8)); } private static final String UNKNOWN_VERSION_JSON = "{" diff --git a/src/test/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParserTest.java b/src/test/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParserTest.java index a4bde96e..7666e7d4 100644 --- a/src/test/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParserTest.java +++ b/src/test/java/com/arpnetworking/metrics/mad/parsers/StatsdToRecordParserTest.java @@ -22,7 +22,6 @@ import com.arpnetworking.metrics.mad.model.DefaultRecord; import com.arpnetworking.metrics.mad.model.MetricType; import com.arpnetworking.metrics.mad.model.Record; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -35,6 +34,7 @@ import org.mockito.MockitoAnnotations; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.time.Clock; import java.time.ZoneId; import java.time.ZoneOffset; @@ -81,7 +81,7 @@ public void testExampleCounter() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("page.views:1|c".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("page.views:1|c".getBytes(StandardCharsets.UTF_8))))); } @Test @@ -104,7 +104,7 @@ public void testExampleGauge() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("fuel.level:0.5|g".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("fuel.level:0.5|g".getBytes(StandardCharsets.UTF_8))))); } @Test @@ -128,13 +128,13 @@ public void testExampleSamplingAccept() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("song.length:240|h|@0.5".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("song.length:240|h|@0.5".getBytes(StandardCharsets.UTF_8))))); } @Test public void testExampleSamplingReject() throws ParsingException { Mockito.doReturn(0.51).when(_random).nextDouble(); - Assert.assertTrue(_parser.parse(ByteBuffer.wrap("song.length:240|h|@0.5".getBytes(Charsets.UTF_8))).isEmpty()); + Assert.assertTrue(_parser.parse(ByteBuffer.wrap("song.length:240|h|@0.5".getBytes(StandardCharsets.UTF_8))).isEmpty()); } @Test @@ -158,18 +158,18 @@ public void testSamplingAlwaysAccept() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("song.length:240|h|@1".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("song.length:240|h|@1".getBytes(StandardCharsets.UTF_8))))); } @Test public void testSamplingAlwaysReject() throws ParsingException { Mockito.doReturn(0.0).when(_random).nextDouble(); - Assert.assertTrue(_parser.parse(ByteBuffer.wrap("song.length:240|h|@0".getBytes(Charsets.UTF_8))).isEmpty()); + Assert.assertTrue(_parser.parse(ByteBuffer.wrap("song.length:240|h|@0".getBytes(StandardCharsets.UTF_8))).isEmpty()); } @Test(expected = ParsingException.class) public void testExampleSetsNotSupported() throws ParsingException { - _parser.parse(ByteBuffer.wrap("users.uniques:1234|s".getBytes(Charsets.UTF_8))); + _parser.parse(ByteBuffer.wrap("users.uniques:1234|s".getBytes(StandardCharsets.UTF_8))); } @Test @@ -193,7 +193,7 @@ public void testExampleTags() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("users.online:1|c|#country:china".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("users.online:1|c|#country:china".getBytes(StandardCharsets.UTF_8))))); } @Test @@ -218,19 +218,20 @@ public void testExampleTagsSampledAccept() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("users.online:1|c|@0.5|#country:china".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("users.online:1|c|@0.5|#country:china".getBytes(StandardCharsets.UTF_8))))); } @Test(expected = ParsingException.class) public void testExampleTagsInvalid() throws ParsingException { Mockito.doReturn(0.50).when(_random).nextDouble(); - _parser.parse(ByteBuffer.wrap("users.online:1|c|@0.5|#country:china,anotherTag".getBytes(Charsets.UTF_8))); + _parser.parse(ByteBuffer.wrap("users.online:1|c|@0.5|#country:china,anotherTag".getBytes(StandardCharsets.UTF_8))); } @Test public void testExampleTagsSampledReject() throws ParsingException { Mockito.doReturn(0.51).when(_random).nextDouble(); - Assert.assertTrue(_parser.parse(ByteBuffer.wrap("users.online:1|c|@0.5|#country:china".getBytes(Charsets.UTF_8))).isEmpty()); + Assert.assertTrue( + _parser.parse(ByteBuffer.wrap("users.online:1|c|@0.5|#country:china".getBytes(StandardCharsets.UTF_8))).isEmpty()); } @Test @@ -254,21 +255,21 @@ public void testInfluxStyleTagFormat() throws ParsingException { )) .build(), Iterables.getOnlyElement( - _parser.parse(ByteBuffer.wrap("users.online,service=statsd:1|c".getBytes(Charsets.UTF_8))))); + _parser.parse(ByteBuffer.wrap("users.online,service=statsd:1|c".getBytes(StandardCharsets.UTF_8))))); } @Test(expected = ParsingException.class) public void testInfluxStyleTagFormatInvalid() throws ParsingException { Mockito.doReturn(0.52).when(_random).nextDouble(); - _parser.parse(ByteBuffer.wrap("users.online,service=statsd,tag2:1|c".getBytes(Charsets.UTF_8))); + _parser.parse(ByteBuffer.wrap("users.online,service=statsd,tag2:1|c".getBytes(StandardCharsets.UTF_8))); } @Test(expected = ParsingException.class) public void testInfluxStyleTagFormatInvalid2() throws ParsingException { Mockito.doReturn(0.53).when(_random).nextDouble(); - _parser.parse(ByteBuffer.wrap("users.online,:,service=statsd|c".getBytes(Charsets.UTF_8))); + _parser.parse(ByteBuffer.wrap("users.online,:,service=statsd|c".getBytes(StandardCharsets.UTF_8))); } private void assertRecordEquality(final Record expected, final Record actual) { diff --git a/src/test/java/com/arpnetworking/metrics/mad/performance/FilePerfTestBase.java b/src/test/java/com/arpnetworking/metrics/mad/performance/FilePerfTestBase.java index 81f2d199..a3722587 100644 --- a/src/test/java/com/arpnetworking/metrics/mad/performance/FilePerfTestBase.java +++ b/src/test/java/com/arpnetworking/metrics/mad/performance/FilePerfTestBase.java @@ -22,7 +22,6 @@ import com.arpnetworking.metrics.mad.Pipeline; import com.arpnetworking.metrics.mad.configuration.PipelineConfiguration; import com.arpnetworking.tsdcore.sinks.Sink; -import com.google.common.base.Charsets; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -34,6 +33,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.List; import java.util.Map; @@ -62,7 +62,7 @@ protected void benchmark( final ImmutableMap variables) throws IOException { // Replace any variables in the configuration file - String configuration = Resources.toString(Resources.getResource(pipelineConfigurationFile), Charsets.UTF_8); + String configuration = Resources.toString(Resources.getResource(pipelineConfigurationFile), StandardCharsets.UTF_8); for (final Map.Entry entry : variables.entrySet()) { configuration = configuration.replace(entry.getKey(), entry.getValue()); }