From 646eb5318413176bc3bc0d2dd7e19c101de0b3d3 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 30 Dec 2014 10:07:50 +0000 Subject: [PATCH] HCOLL-283 updated test. --- .../chronicle/map/ChronicleMapTest.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index 1ed9ecb15..f4591ad3f 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -1701,28 +1701,35 @@ public class ChronicleMapTest { TcpTransportAndNetworkConfig serverConfig = TcpTransportAndNetworkConfig.of(8877) .name("serverMap"); - File mapFile = new File("map201.dat"); - try (ChronicleMap server = ChronicleMapBuilder.of(byte[].class, byte[][].class) - .replication((byte) 1, serverConfig) - .constantKeySizeBySample(new byte[14]) - .createPersistedTo(mapFile)) { + File mapFile = getPersistenceFile(); - try (ChronicleMap map2 = ChronicleMapBuilder.of(byte[].class, byte[][].class) + + // this test only appear to fail when we reuse the mapFile + for (int i = 0; i < 2; i++) { + + try (ChronicleMap server = ChronicleMapBuilder.of(byte[].class, byte[][].class) + .replication((byte) 1, serverConfig) .constantKeySizeBySample(new byte[14]) - .statelessClient(new InetSocketAddress("localhost", 8877)) - .create()) { + .createPersistedTo(mapFile)) { + + try (ChronicleMap map2 = ChronicleMapBuilder.of(byte[].class, byte[][].class) + .constantKeySizeBySample(new byte[14]) + .statelessClient(new InetSocketAddress("localhost", 8877)) + .create()) { - byte[] key = new byte[14]; - System.arraycopy("A".getBytes(), 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()); + byte[] key = new byte[14]; + System.arraycopy("A".getBytes(), 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()); - map2.put(key, value); - Assert.assertNotNull(map2.get(key)); + map2.put(key, value); + Assert.assertNotNull(map2.get(key)); + } } + } }