summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo')
-rw-r--r--vespajlib/src/test/java/com/yahoo/io/ByteWriterTestCase.java22
-rw-r--r--vespajlib/src/test/java/com/yahoo/io/FileReadTestCase.java10
-rw-r--r--vespajlib/src/test/java/com/yahoo/io/HexDumpTestCase.java19
3 files changed, 21 insertions, 30 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/io/ByteWriterTestCase.java b/vespajlib/src/test/java/com/yahoo/io/ByteWriterTestCase.java
index c6278133d4c..77967bb08fa 100644
--- a/vespajlib/src/test/java/com/yahoo/io/ByteWriterTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/io/ByteWriterTestCase.java
@@ -1,23 +1,23 @@
-// 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.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import com.yahoo.text.Utf8;
+import com.yahoo.text.Utf8Array;
+import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.IdentityHashMap;
-import com.yahoo.text.Utf8;
-import com.yahoo.text.Utf8Array;
-import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Test the ByteWriter class. ByteWriter is also implicitly tested in
@@ -27,7 +27,7 @@ import org.junit.Test;
*/
public class ByteWriterTestCase {
- private final CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
+ private final CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
private final ByteArrayOutputStream stream = new ByteArrayOutputStream();
/**
@@ -281,7 +281,7 @@ public class ByteWriterTestCase {
@Test
public void testUnMappableCharacter() throws java.io.IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- ByteWriter writer = new ByteWriter(stream, Charset.forName("ascii").newEncoder());
+ ByteWriter writer = new ByteWriter(stream, StandardCharsets.US_ASCII.newEncoder());
writer.write("yahoo\u9999bahoo");
writer.close();
assertTrue(stream.toString("ascii").contains("yahoo"));
diff --git a/vespajlib/src/test/java/com/yahoo/io/FileReadTestCase.java b/vespajlib/src/test/java/com/yahoo/io/FileReadTestCase.java
index 1acd225b18a..4769562db89 100644
--- a/vespajlib/src/test/java/com/yahoo/io/FileReadTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/io/FileReadTestCase.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.io;
import org.junit.Test;
@@ -6,7 +6,7 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -16,15 +16,15 @@ public class FileReadTestCase {
@Test
public void testReadByteArray() throws IOException {
byte[] thisFile = IOUtils.readFileBytes(new File("src/test/java/com/yahoo/io/FileReadTestCase.java"));
- String str = new String(thisFile, Charset.forName("US-ASCII"));
- assertTrue(str.startsWith("// Copyright 2017 Yahoo Holdings."));
+ String str = new String(thisFile, StandardCharsets.US_ASCII);
+ assertTrue(str.startsWith("// Copyright Verizon Media."));
assertTrue(str.endsWith("// Yeppers\n"));
}
@Test
public void testReadString() throws IOException {
String str = IOUtils.readFile(new File("src/test/java/com/yahoo/io/FileReadTestCase.java"));
- assertTrue(str.startsWith("// Copyright 2017 Yahoo Holdings."));
+ assertTrue(str.startsWith("// Copyright Verizon Media."));
assertTrue(str.endsWith("// Yeppers\n"));
}
diff --git a/vespajlib/src/test/java/com/yahoo/io/HexDumpTestCase.java b/vespajlib/src/test/java/com/yahoo/io/HexDumpTestCase.java
index dcea8101d9c..d250338b8fe 100644
--- a/vespajlib/src/test/java/com/yahoo/io/HexDumpTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/io/HexDumpTestCase.java
@@ -1,28 +1,19 @@
-// 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 org.junit.Test;
-import com.yahoo.text.Utf8;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* @author Simon Thoresen Hult
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class HexDumpTestCase {
- private static final Charset UTF8 = Charset.forName("UTF-8");
- private static final Charset UTF16 = Charset.forName("UTF-16");
-
@Test
public void requireThatToHexStringAcceptsNull() {
assertNull(HexDump.toHexString(null));
@@ -31,10 +22,10 @@ public class HexDumpTestCase {
@Test
public void requireThatToHexStringIsUnformatted() {
assertEquals("6162636465666768696A6B6C6D6E6F707172737475767778797A",
- HexDump.toHexString("abcdefghijklmnopqrstuvwxyz".getBytes(UTF8)));
+ HexDump.toHexString("abcdefghijklmnopqrstuvwxyz".getBytes(StandardCharsets.UTF_8)));
assertEquals("FEFF006100620063006400650066006700680069006A006B006C00" +
"6D006E006F0070007100720073007400750076007700780079007A",
- HexDump.toHexString("abcdefghijklmnopqrstuvwxyz".getBytes(UTF16)));
+ HexDump.toHexString("abcdefghijklmnopqrstuvwxyz".getBytes(StandardCharsets.UTF_16)));
}
}