From 48c588c4aa02abf9201b3c6ea12d63b768c5d3e4 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Fri, 14 Nov 2014 15:11:53 +0000 Subject: [PATCH] HCOLL-81 added test for when there is no entry --- .../chronicle/map/StatelessClientTest.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java index dc747b148..21a3d3ba2 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java @@ -71,11 +71,12 @@ public class StatelessClientTest { @Test - public void testMapForKey() throws IOException, InterruptedException { + public void testMapForKeyWithEntry() throws IOException, InterruptedException { try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, StringBuilder.class) + .defaultValue(new StringBuilder()) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { serverMap.put(10, new StringBuilder("Hello World")); @@ -84,7 +85,8 @@ public class StatelessClientTest { .class, StringBuilder.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - String actual = (String) ((StatelessChronicleMap) statelessMap).mapForKey(10, new StringBuilderToStringFunction()); + String actual = (String) ((StatelessChronicleMap) statelessMap).mapForKey(10, new + StringBuilderToStringFunction()); Assert.assertEquals("Hello World", actual); } @@ -92,6 +94,30 @@ public class StatelessClientTest { } + + @Test + public void testMapForKeyWhenNoEntry() throws IOException, InterruptedException { + + + try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, + StringBuilder.class) + .defaultValue(new StringBuilder()) + .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { + + serverMap.put(10, new StringBuilder("Hello World")); + + try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + .class, StringBuilder.class) + .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { + + String actual = (String) ((StatelessChronicleMap) statelessMap).mapForKey(11, new + StringBuilderToStringFunction()); + + Assert.assertEquals("", actual); + } + } + } + @Test(timeout = 5000) public void testBufferOverFlowPutAllAndEntrySet() throws IOException, InterruptedException {