From c2b5c6561939017b1bc36d6845a405f64b34234d Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Mon, 5 Oct 2020 13:26:07 +0200 Subject: Remove unused Utf8 methods In-lined in the tests that used them. --- vespajlib/src/main/java/com/yahoo/text/Utf8.java | 14 +------------- .../src/test/java/com/yahoo/io/SlowInflateTestCase.java | 16 ++++++++-------- .../test/java/com/yahoo/slime/JsonFormatTestCase.java | 9 ++++----- vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java | 8 ++++---- 4 files changed, 17 insertions(+), 30 deletions(-) (limited to 'vespajlib/src') diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8.java b/vespajlib/src/main/java/com/yahoo/text/Utf8.java index b81f0447d04..e882353469e 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Utf8.java +++ b/vespajlib/src/main/java/com/yahoo/text/Utf8.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.IOException; @@ -31,11 +31,6 @@ public final class Utf8 { return StandardCharsets.UTF_8; } - /** To be used instead of String.String(byte[] bytes) */ - public static String toStringStd(byte[] data) { - return new String(data, StandardCharsets.UTF_8); - } - /** * Utility method as toString(byte[]). * @@ -65,13 +60,6 @@ public final class Utf8 { return c.toString(); } - /** - * Uses String.getBytes directly. - */ - public static byte[] toBytesStd(String str) { - return str.getBytes(StandardCharsets.UTF_8); - } - /** * Encode a long as its decimal representation, i.e. toAsciiBytes(15L) will * return "15" encoded as UTF-8. In other words it is an optimized version diff --git a/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java b/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java index 7726cd7ea68..7f374441a18 100644 --- a/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java @@ -1,20 +1,20 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.io; -import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.zip.Deflater; -import org.junit.Before; -import org.junit.Test; - -import com.yahoo.text.Utf8; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertTrue; /** * Check decompressor used among other things for packed summary fields. * - * @author Steinar Knutsen + * @author Steinar Knutsen */ public class SlowInflateTestCase { @@ -27,7 +27,7 @@ public class SlowInflateTestCase { @Before public void setUp() throws Exception { value = "000000000000000000000000000000000000000000000000000000000000000"; - raw = Utf8.toBytesStd(value); + raw = value.getBytes(StandardCharsets.UTF_8); output = new byte[raw.length * 2]; Deflater compresser = new Deflater(); compresser.setInput(raw); diff --git a/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java b/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java index 44aa4ab2ff7..3b31c2b559e 100644 --- a/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java @@ -1,8 +1,7 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.slime; import com.yahoo.text.Utf8; -import org.junit.Ignore; import org.junit.Test; import java.io.ByteArrayOutputStream; @@ -201,7 +200,7 @@ public class JsonFormatTestCase { public void testDecodeUnicodeAmp() { final String json = "{\"body\":\"some text\\u0026more text\"}"; Slime slime = new Slime(); - new JsonDecoder().decode(slime, Utf8.toBytesStd(json)); + new JsonDecoder().decode(slime, json.getBytes(StandardCharsets.UTF_8)); Cursor a = slime.get().field("body"); assertThat(a.asString(), is("some text&more text")); } @@ -224,7 +223,7 @@ public class JsonFormatTestCase { " }\n"; Slime slime = new Slime(); - slime = new JsonDecoder().decode(slime, Utf8.toBytesStd(json)); + slime = new JsonDecoder().decode(slime, json.getBytes(StandardCharsets.UTF_8)); Cursor a = slime.get().field("rules"); assertThat(a.asString(), is(str)); } @@ -261,7 +260,7 @@ public class JsonFormatTestCase { private void verifyEncodeDecode(String json, boolean compact) { try { Slime slime = new Slime(); - new JsonDecoder().decode(slime, Utf8.toBytesStd(json)); + new JsonDecoder().decode(slime, json.getBytes(StandardCharsets.UTF_8)); ByteArrayOutputStream a = new ByteArrayOutputStream(); new JsonFormat(compact).encode(a, slime); assertEquals(json, Utf8.toString(a.toByteArray())); diff --git a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java index 97d0717dc0b..8293554140d 100644 --- a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java +++ b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import com.google.common.collect.ImmutableMap; @@ -24,8 +24,8 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** - * @author Bjorn Borud - * @author Steinar Knutsen + * @author Bjorn Borud + * @author Steinar Knutsen */ public class Utf8TestCase { @@ -322,7 +322,7 @@ public class Utf8TestCase { for (char c=0; c < i; c++) { sb.append(c); } - assertTrue(Arrays.equals(Utf8.toBytesStd(sb.toString()), Utf8.toBytes(sb.toString()))); + assertTrue(Arrays.equals(sb.toString().getBytes(StandardCharsets.UTF_8), Utf8.toBytes(sb.toString()))); } } -- cgit v1.2.3