mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Remove implicit uses of platform default charset
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=173419389
This commit is contained in:
parent
51326a1a5c
commit
996095aed3
5 changed files with 33 additions and 36 deletions
|
@ -15,7 +15,6 @@
|
||||||
package google.registry.util;
|
package google.registry.util;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import google.registry.testing.ExceptionRule;
|
import google.registry.testing.ExceptionRule;
|
||||||
|
@ -37,7 +36,7 @@ public class HexDumperTest {
|
||||||
String input = "";
|
String input = "";
|
||||||
String output = "[0 bytes total]\n";
|
String output = "[0 bytes total]\n";
|
||||||
assertThat(input).isEmpty();
|
assertThat(input).isEmpty();
|
||||||
assertThat(HexDumper.dumpHex(input.getBytes())).isEqualTo(output);
|
assertThat(HexDumper.dumpHex(input.getBytes(UTF_8))).isEqualTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -46,7 +45,7 @@ public class HexDumperTest {
|
||||||
String output = "[11 bytes total]\n"
|
String output = "[11 bytes total]\n"
|
||||||
+ "00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 hello world \n";
|
+ "00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 hello world \n";
|
||||||
assertThat(input).hasLength(11);
|
assertThat(input).hasLength(11);
|
||||||
assertThat(HexDumper.dumpHex(input.getBytes())).isEqualTo(output);
|
assertThat(HexDumper.dumpHex(input.getBytes(UTF_8))).isEqualTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -64,7 +63,7 @@ public class HexDumperTest {
|
||||||
+ "00000064 65 20 62 75 79 2c 20 63 6f 6d 65 20 62 75 79 3a e buy, come buy:\n"
|
+ "00000064 65 20 62 75 79 2c 20 63 6f 6d 65 20 62 75 79 3a e buy, come buy:\n"
|
||||||
+ "00000080 0a . \n";
|
+ "00000080 0a . \n";
|
||||||
assertThat(input).hasLength(81);
|
assertThat(input).hasLength(81);
|
||||||
assertThat(HexDumper.dumpHex(input.getBytes())).isEqualTo(output);
|
assertThat(HexDumper.dumpHex(input.getBytes(UTF_8))).isEqualTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -73,7 +72,7 @@ public class HexDumperTest {
|
||||||
String output = "[16 bytes total]\n"
|
String output = "[16 bytes total]\n"
|
||||||
+ "00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 64 64 64 64 64 hello worldddddd\n";
|
+ "00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 64 64 64 64 64 hello worldddddd\n";
|
||||||
assertThat(input).hasLength(16);
|
assertThat(input).hasLength(16);
|
||||||
assertThat(HexDumper.dumpHex(input.getBytes())).isEqualTo(output);
|
assertThat(HexDumper.dumpHex(input.getBytes(UTF_8))).isEqualTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -114,7 +113,7 @@ public class HexDumperTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLineBuffering() throws Exception {
|
public void testLineBuffering() throws Exception {
|
||||||
// Assume that we have some data that's N bytes long.
|
// Assume that we have some data that's N bytes long.
|
||||||
byte[] data = "Sweet to tongue and sound to eye; Come buy, come buy.".getBytes();
|
byte[] data = "Sweet to tongue and sound to eye; Come buy, come buy.".getBytes(UTF_8);
|
||||||
// And a streaming HexDumper that displays N+1 characters per row.
|
// And a streaming HexDumper that displays N+1 characters per row.
|
||||||
int perLine = data.length + 1;
|
int perLine = data.length + 1;
|
||||||
try (StringWriter out = new StringWriter();
|
try (StringWriter out = new StringWriter();
|
||||||
|
@ -141,11 +140,11 @@ public class HexDumperTest {
|
||||||
public void testFlush() throws Exception {
|
public void testFlush() throws Exception {
|
||||||
try (StringWriter out = new StringWriter();
|
try (StringWriter out = new StringWriter();
|
||||||
HexDumper dumper = new HexDumper(out)) {
|
HexDumper dumper = new HexDumper(out)) {
|
||||||
dumper.write("hello ".getBytes());
|
dumper.write("hello ".getBytes(UTF_8));
|
||||||
assertThat(out.toString()).isEmpty();
|
assertThat(out.toString()).isEmpty();
|
||||||
dumper.flush();
|
dumper.flush();
|
||||||
assertThat(out.toString()).isEqualTo("00000000 68 65 6c 6c 6f 20 ");
|
assertThat(out.toString()).isEqualTo("00000000 68 65 6c 6c 6f 20 ");
|
||||||
dumper.write("world".getBytes());
|
dumper.write("world".getBytes(UTF_8));
|
||||||
assertThat(out.toString()).isEqualTo("00000000 68 65 6c 6c 6f 20 ");
|
assertThat(out.toString()).isEqualTo("00000000 68 65 6c 6c 6f 20 ");
|
||||||
dumper.flush();
|
dumper.flush();
|
||||||
assertThat(out.toString()).isEqualTo("00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 ");
|
assertThat(out.toString()).isEqualTo("00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 ");
|
||||||
|
@ -164,7 +163,7 @@ public class HexDumperTest {
|
||||||
+ "00000002 6c l\n"
|
+ "00000002 6c l\n"
|
||||||
+ "00000003 6c l\n"
|
+ "00000003 6c l\n"
|
||||||
+ "00000004 6f o\n";
|
+ "00000004 6f o\n";
|
||||||
assertThat(HexDumper.dumpHex(input.getBytes(), 1, 0)).isEqualTo(output);
|
assertThat(HexDumper.dumpHex(input.getBytes(UTF_8), 1, 0)).isEqualTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.util;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static google.registry.testing.SystemInfo.hasCommand;
|
import static google.registry.testing.SystemInfo.hasCommand;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
@ -53,7 +52,7 @@ public class PosixTarHeaderSystemTest {
|
||||||
|
|
||||||
// We have some data (in memory) that we'll call hello.txt.
|
// We have some data (in memory) that we'll call hello.txt.
|
||||||
String fileName = "hello.txt";
|
String fileName = "hello.txt";
|
||||||
byte[] fileData = "hello world\n".getBytes();
|
byte[] fileData = "hello world\n".getBytes(UTF_8);
|
||||||
|
|
||||||
// We're going to put it in a new tar archive (on the filesystem) named hello.tar.
|
// We're going to put it in a new tar archive (on the filesystem) named hello.tar.
|
||||||
String tarName = "hello.tar";
|
String tarName = "hello.tar";
|
||||||
|
@ -152,8 +151,8 @@ public class PosixTarHeaderSystemTest {
|
||||||
String one = "the first line";
|
String one = "the first line";
|
||||||
String two = "the second line";
|
String two = "the second line";
|
||||||
File cwd = folder.getRoot();
|
File cwd = folder.getRoot();
|
||||||
Files.write(one.getBytes(), new File(cwd, "one"));
|
Files.write(one.getBytes(UTF_8), new File(cwd, "one"));
|
||||||
Files.write(two.getBytes(), new File(cwd, "two"));
|
Files.write(two.getBytes(UTF_8), new File(cwd, "two"));
|
||||||
|
|
||||||
String[] cmd = {"tar", "--format=ustar", "-cf", "lines.tar", "one", "two"};
|
String[] cmd = {"tar", "--format=ustar", "-cf", "lines.tar", "one", "two"};
|
||||||
String[] env = {"PATH=" + System.getenv("PATH")};
|
String[] env = {"PATH=" + System.getenv("PATH")};
|
||||||
|
@ -171,7 +170,7 @@ public class PosixTarHeaderSystemTest {
|
||||||
assertThat(header.getName()).isEqualTo("one");
|
assertThat(header.getName()).isEqualTo("one");
|
||||||
assertThat(header.getSize()).isEqualTo(one.length());
|
assertThat(header.getSize()).isEqualTo(one.length());
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(one).isEqualTo(new String(block, 0, one.length()));
|
assertThat(one).isEqualTo(new String(block, 0, one.length(), UTF_8));
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
header = PosixTarHeader.from(block);
|
header = PosixTarHeader.from(block);
|
||||||
|
@ -179,7 +178,7 @@ public class PosixTarHeaderSystemTest {
|
||||||
assertThat(header.getName()).isEqualTo("two");
|
assertThat(header.getName()).isEqualTo("two");
|
||||||
assertThat(header.getSize()).isEqualTo(two.length());
|
assertThat(header.getSize()).isEqualTo(two.length());
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(two).isEqualTo(new String(block, 0, two.length()));
|
assertThat(two).isEqualTo(new String(block, 0, two.length(), UTF_8));
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
||||||
|
@ -194,7 +193,7 @@ public class PosixTarHeaderSystemTest {
|
||||||
assumeTrue(hasCommand("tar"));
|
assumeTrue(hasCommand("tar"));
|
||||||
|
|
||||||
String truth = "No one really knows\n";
|
String truth = "No one really knows\n";
|
||||||
Files.write(truth.getBytes(), folder.newFile("truth.txt"));
|
Files.write(truth.getBytes(UTF_8), folder.newFile("truth.txt"));
|
||||||
|
|
||||||
String[] cmd = {"tar", "-cf", "steam.tar", "truth.txt"};
|
String[] cmd = {"tar", "-cf", "steam.tar", "truth.txt"};
|
||||||
String[] env = {"PATH=" + System.getenv("PATH")};
|
String[] env = {"PATH=" + System.getenv("PATH")};
|
||||||
|
@ -213,7 +212,7 @@ public class PosixTarHeaderSystemTest {
|
||||||
assertThat(header.getName()).isEqualTo("truth.txt");
|
assertThat(header.getName()).isEqualTo("truth.txt");
|
||||||
assertThat(header.getSize()).isEqualTo(truth.length());
|
assertThat(header.getSize()).isEqualTo(truth.length());
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(truth).isEqualTo(new String(block, 0, truth.length()));
|
assertThat(truth).isEqualTo(new String(block, 0, truth.length(), UTF_8));
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
||||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.util;
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.testing.EqualsTester;
|
import com.google.common.testing.EqualsTester;
|
||||||
|
@ -273,7 +272,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, likeTears.length())).isEqualTo(likeTears);
|
assertThat(new String(block, 0, likeTears.length(), UTF_8)).isEqualTo(likeTears);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
header = PosixTarHeader.from(block);
|
header = PosixTarHeader.from(block);
|
||||||
|
@ -287,7 +286,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, inRain.length())).isEqualTo(inRain);
|
assertThat(new String(block, 0, inRain.length(), UTF_8)).isEqualTo(inRain);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
||||||
|
@ -327,7 +326,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, likeTears.length())).isEqualTo(likeTears);
|
assertThat(new String(block, 0, likeTears.length(), UTF_8)).isEqualTo(likeTears);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
header = PosixTarHeader.from(block);
|
header = PosixTarHeader.from(block);
|
||||||
|
@ -341,7 +340,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, inRain.length())).isEqualTo(inRain);
|
assertThat(new String(block, 0, inRain.length(), UTF_8)).isEqualTo(inRain);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
||||||
|
@ -381,7 +380,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, likeTears.length())).isEqualTo(likeTears);
|
assertThat(new String(block, 0, likeTears.length(), UTF_8)).isEqualTo(likeTears);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
header = PosixTarHeader.from(block);
|
header = PosixTarHeader.from(block);
|
||||||
|
@ -395,7 +394,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, inRain.length())).isEqualTo(inRain);
|
assertThat(new String(block, 0, inRain.length(), UTF_8)).isEqualTo(inRain);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
||||||
|
@ -436,7 +435,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, likeTears.length())).isEqualTo(likeTears);
|
assertThat(new String(block, 0, likeTears.length(), UTF_8)).isEqualTo(likeTears);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
header = PosixTarHeader.from(block);
|
header = PosixTarHeader.from(block);
|
||||||
|
@ -451,7 +450,7 @@ public class PosixTarHeaderTest {
|
||||||
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
assertThat(header.getMtime().toString(ISODateTimeFormat.date())).isEqualTo("2013-08-16");
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertThat(new String(block, 0, inRain.length())).isEqualTo(inRain);
|
assertThat(new String(block, 0, inRain.length(), UTF_8)).isEqualTo(inRain);
|
||||||
|
|
||||||
assertThat(input.read(block)).isEqualTo(512);
|
assertThat(input.read(block)).isEqualTo(512);
|
||||||
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
assertWithMessage("End of archive marker corrupt").that(block).isEqualTo(new byte[512]);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.util;
|
package google.registry.util;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -43,14 +43,14 @@ public class TeeOutputStreamTest {
|
||||||
// Write shared data using the tee output stream.
|
// Write shared data using the tee output stream.
|
||||||
try (OutputStream tee =
|
try (OutputStream tee =
|
||||||
new TeeOutputStream(asList(outputA, outputB, outputC))) {
|
new TeeOutputStream(asList(outputA, outputB, outputC))) {
|
||||||
tee.write("hello ".getBytes());
|
tee.write("hello ".getBytes(UTF_8));
|
||||||
tee.write("hello world!".getBytes(), 6, 5);
|
tee.write("hello world!".getBytes(UTF_8), 6, 5);
|
||||||
tee.write('!');
|
tee.write('!');
|
||||||
}
|
}
|
||||||
// Write some more data to the different streams - they should not have been closed.
|
// Write some more data to the different streams - they should not have been closed.
|
||||||
outputA.write("a".getBytes());
|
outputA.write("a".getBytes(UTF_8));
|
||||||
outputB.write("b".getBytes());
|
outputB.write("b".getBytes(UTF_8));
|
||||||
outputC.write("c".getBytes());
|
outputC.write("c".getBytes(UTF_8));
|
||||||
// Check the results.
|
// Check the results.
|
||||||
assertThat(outputA.toString()).isEqualTo("hello world!a");
|
assertThat(outputA.toString()).isEqualTo("hello world!a");
|
||||||
assertThat(outputB.toString()).isEqualTo("hello world!b");
|
assertThat(outputB.toString()).isEqualTo("hello world!b");
|
||||||
|
@ -77,7 +77,7 @@ public class TeeOutputStreamTest {
|
||||||
OutputStream tee = new TeeOutputStream(asList(outputA));
|
OutputStream tee = new TeeOutputStream(asList(outputA));
|
||||||
tee.close();
|
tee.close();
|
||||||
thrown.expect(IllegalStateException.class, "outputstream closed");
|
thrown.expect(IllegalStateException.class, "outputstream closed");
|
||||||
tee.write("hello".getBytes());
|
tee.write("hello".getBytes(UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -85,6 +85,6 @@ public class TeeOutputStreamTest {
|
||||||
OutputStream tee = new TeeOutputStream(asList(outputA));
|
OutputStream tee = new TeeOutputStream(asList(outputA));
|
||||||
tee.close();
|
tee.close();
|
||||||
thrown.expect(IllegalStateException.class, "outputstream closed");
|
thrown.expect(IllegalStateException.class, "outputstream closed");
|
||||||
tee.write("hello".getBytes(), 1, 3);
|
tee.write("hello".getBytes(UTF_8), 1, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
package google.registry.xjc;
|
package google.registry.xjc;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import google.registry.xjc.rdehost.XjcRdeHostElement;
|
import google.registry.xjc.rdehost.XjcRdeHostElement;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -40,7 +40,7 @@ public class JaxbFragmentTest {
|
||||||
public void testJavaSerialization() throws Exception {
|
public void testJavaSerialization() throws Exception {
|
||||||
// Load rdeHost xml fragment into a jaxb object, wrap it, marshal, unmarshal, verify host.
|
// Load rdeHost xml fragment into a jaxb object, wrap it, marshal, unmarshal, verify host.
|
||||||
// The resulting host name should be "ns1.example1.test", from the original xml fragment.
|
// The resulting host name should be "ns1.example1.test", from the original xml fragment.
|
||||||
try (InputStream source = new ByteArrayInputStream(HOST_FRAGMENT.getBytes())) {
|
try (InputStream source = new ByteArrayInputStream(HOST_FRAGMENT.getBytes(UTF_8))) {
|
||||||
// Load xml
|
// Load xml
|
||||||
JaxbFragment<XjcRdeHostElement> hostFragment =
|
JaxbFragment<XjcRdeHostElement> hostFragment =
|
||||||
JaxbFragment.create(XjcXmlTransformer.unmarshal(XjcRdeHostElement.class, source));
|
JaxbFragment.create(XjcXmlTransformer.unmarshal(XjcRdeHostElement.class, source));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue