[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-lib/release] Use StandardCharsets.US_ASCII instead of "US-ASCII".
commit 75e1d31465aceb31c81f86575dc71abdab77095a
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed Nov 20 12:04:29 2019 +0100
Use StandardCharsets.US_ASCII instead of "US-ASCII".
---
.../java/org/torproject/descriptor/impl/ExitListImplTest.java | 9 +++++----
.../org/torproject/descriptor/impl/TorperfResultImplTest.java | 8 ++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
index 0b53250..44a868b 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
@@ -12,6 +12,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
public class ExitListImplTest {
@@ -22,7 +23,7 @@ public class ExitListImplTest {
@Test
public void testAnnotatedInput() throws Exception {
ExitListImpl result = new ExitListImpl((tordnselAnnotation + input)
- .getBytes("US-ASCII"), null, fileName);
+ .getBytes(StandardCharsets.US_ASCII), null, fileName);
assertEquals("Expected one annotation.", 1,
result.getAnnotations().size());
assertEquals(tordnselAnnotation.substring(0, 18),
@@ -38,7 +39,7 @@ public class ExitListImplTest {
public void testMultipleExitAddresses() throws Exception {
ExitListImpl result = new ExitListImpl(
(tordnselAnnotation + multiExitAddressInput)
- .getBytes("US-ASCII"), null, fileName);
+ .getBytes(StandardCharsets.US_ASCII), null, fileName);
assertTrue("Unrecognized lines: " + result.getUnrecognizedLines(),
result.getUnrecognizedLines().isEmpty());
Map<String, Long> map = result.getEntries()
@@ -54,7 +55,7 @@ public class ExitListImplTest {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage("Missing 'ExitAddress' line in exit list entry.");
new ExitListImpl((tordnselAnnotation + insufficientInput[0])
- .getBytes("US-ASCII"), null, fileName);
+ .getBytes(StandardCharsets.US_ASCII), null, fileName);
}
@Test
@@ -62,7 +63,7 @@ public class ExitListImplTest {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage("Missing 'Published' line in exit list entry.");
new ExitListImpl((tordnselAnnotation + insufficientInput[1])
- .getBytes("US-ASCII"), null, fileName);
+ .getBytes(StandardCharsets.US_ASCII), null, fileName);
}
private static final String tordnselAnnotation = "@type tordnsel 1.0\n";
diff --git a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
index 2af458f..b56490a 100644
--- a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
@@ -22,7 +22,7 @@ public class TorperfResultImplTest {
public void testAnnotatedInput() throws Exception {
TorperfResultImpl result = (TorperfResultImpl)
(TorperfResultImpl.parseTorperfResults((torperfAnnotation + input)
- .getBytes("US-ASCII"), null).get(0));
+ .getBytes(StandardCharsets.US_ASCII), null).get(0));
assertEquals("Expected one annotation.", 1,
result.getAnnotations().size());
assertEquals(torperfAnnotation.substring(0, 17),
@@ -37,7 +37,7 @@ public class TorperfResultImplTest {
@Test
public void testPartiallyAnnotatedInput() throws Exception {
byte[] asciiBytes = (torperfAnnotation
- + input + input + input).getBytes("US-ASCII");
+ + input + input + input).getBytes(StandardCharsets.US_ASCII);
List<Descriptor> result = TorperfResultImpl.parseTorperfResults(
asciiBytes, null);
assertEquals("Expected one annotation.", 1,
@@ -53,7 +53,7 @@ public class TorperfResultImplTest {
public void testAllAnnotatedInput() throws Exception {
byte[] asciiBytes = (torperfAnnotation + input
+ torperfAnnotation + input
- + torperfAnnotation + input).getBytes("US-ASCII");
+ + torperfAnnotation + input).getBytes(StandardCharsets.US_ASCII);
List<Descriptor> result = TorperfResultImpl.parseTorperfResults(
asciiBytes, null);
assertEquals("Expected one annotation.", 1,
@@ -68,7 +68,7 @@ public class TorperfResultImplTest {
@Test
public void testTrailingNewlinesRetained() throws Exception {
byte[] asciiBytes = (torperfAnnotation + input
- + torperfAnnotation + input).getBytes("US-ASCII");
+ + torperfAnnotation + input).getBytes(StandardCharsets.US_ASCII);
List<Descriptor> result = TorperfResultImpl.parseTorperfResults(
asciiBytes, null);
for (Descriptor descriptor : result) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits