diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index b05855c53..ac159a539 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -41,6 +41,7 @@ import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.util.Arrays.asList; import static net.openhft.chronicle.map.StatelessClientTest.localClient; import static net.openhft.chronicle.map.fromdocs.OpenJDKAndHashMapExamplesTest.parseYYYYMMDD; @@ -447,12 +448,12 @@ public class CHMUseCasesTest { .of(byte[].class, byte[][].class); try (ChronicleMap map = newInstance(builder)) { - byte[] bytes1 = "value1".getBytes(); - byte[] bytes2 = "value2".getBytes(); + byte[] bytes1 = "value1".getBytes(ISO_8859_1); + byte[] bytes2 = "value2".getBytes(ISO_8859_1); byte[][] value = {bytes1, bytes2}; - map.put("Key".getBytes(), value); + map.put("Key".getBytes(ISO_8859_1), value); - assertEquals(value, map.get("Key".getBytes())); + assertEquals(value, map.get("Key".getBytes(ISO_8859_1))); mapChecks(); } } diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index b510b3684..19bc96150 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -36,6 +36,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import static net.openhft.chronicle.map.Alignment.*; import static net.openhft.chronicle.map.StatelessClientTest.localClient; import static org.junit.Assert.*; @@ -192,9 +193,9 @@ public class ChronicleMapTest { try (ChronicleMap map = ChronicleMapBuilder.of(byte[].class, byte[] .class).createPersistedTo(persistenceFile)) { - byte[] o = map.get("hello".getBytes()); + byte[] o = map.get("hello".getBytes(ISO_8859_1)); System.out.println(o == null ? "null" : new String(o)); - map.put("hello".getBytes(), "world".getBytes()); + map.put("hello".getBytes(ISO_8859_1), "world".getBytes(ISO_8859_1)); } } @@ -1800,10 +1801,10 @@ public class ChronicleMapTest { try (ChronicleMap map2 = localClient(8877)) { byte[] key = new byte[14]; - System.arraycopy("A".getBytes(), 0, key, 0, "A".length()); + System.arraycopy("A".getBytes(ISO_8859_1), 0, key, 0, "A".length()); byte[][] value = {new byte[11], new byte[11]}; - System.arraycopy("A".getBytes(), 0, value[0], 0, "A".length()); - System.arraycopy("A".getBytes(), 0, value[1], 0, "A".length()); + System.arraycopy("A".getBytes(ISO_8859_1), 0, value[0], 0, "A".length()); + System.arraycopy("A".getBytes(ISO_8859_1), 0, value[1], 0, "A".length()); map2.put(key, value); Assert.assertNotNull(map2.get(key)); diff --git a/src/test/java/net/openhft/chronicle/map/HasherTest.java b/src/test/java/net/openhft/chronicle/map/HasherTest.java index 2043d41c0..30e11f407 100644 --- a/src/test/java/net/openhft/chronicle/map/HasherTest.java +++ b/src/test/java/net/openhft/chronicle/map/HasherTest.java @@ -20,6 +20,8 @@ import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; import net.openhft.chronicle.hash.hashing.Hasher; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + public class HasherTest { public static void main(String[] args) { @@ -27,8 +29,8 @@ public class HasherTest { for (int i=0;i<10;i++) { String key = "010758403"+String.format("%06d",i)+"S-INJFIX_SLE"; - long hashCode = Hasher.hash(key.getBytes()); - long guavaHashCode = hashFunction.hashBytes(key.getBytes()).asLong(); + long hashCode = Hasher.hash(key.getBytes(ISO_8859_1)); + long guavaHashCode = hashFunction.hashBytes(key.getBytes(ISO_8859_1)).asLong(); System.out.println("<"+key+"> => "+hashCode+" "+guavaHashCode); } } diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientDuplicateKeyTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientDuplicateKeyTest.java index dd340fe9b..1c558631a 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientDuplicateKeyTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientDuplicateKeyTest.java @@ -27,7 +27,8 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.*; -import static net.openhft.chronicle.map.ChronicleMapStatelessClientBuilder.*; +import static java.nio.charset.StandardCharsets.ISO_8859_1; +import static net.openhft.chronicle.map.ChronicleMapStatelessClientBuilder.createClientOf; public class StatelessClientDuplicateKeyTest { @@ -78,8 +79,8 @@ public class StatelessClientDuplicateKeyTest { byte[] _42 = {42}; map.put(_42, new byte[] {1, 2, 3}); map.put(new byte[]{1, 2, 3}, _42); - byte[] longKey = "fooBarFooBarFooBarFooBar".getBytes(); - map.put(longKey, "bar".getBytes()); + byte[] longKey = "fooBarFooBarFooBarFooBar".getBytes(ISO_8859_1); + map.put(longKey, "bar".getBytes(ISO_8859_1)); final ChronicleMap client = createClientOf(new InetSocketAddress("localhost", 8081)); diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java index dc817ad03..c86e2814d 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java @@ -34,6 +34,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import static net.openhft.chronicle.map.ChronicleMapStatelessClientBuilder.createClientOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -756,7 +757,7 @@ public class StatelessClientTest { try (ChronicleMap map2 = localClient(8875)) { byte[] key = new byte[14]; - System.arraycopy("A".getBytes(), 0, key, 0, "A".length()); + System.arraycopy("A".getBytes(ISO_8859_1), 0, key, 0, "A".length()); map2.put(key, "hello world"); Assert.assertNotNull(map2.get(key));