diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index 010a60f8b..b948ef656 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -205,7 +205,7 @@ public class ChronicleMapTest { public void testByteArrayPersistenceFileReuse() throws Exception { final File persistenceFile = Builder.getPersistenceFile(); - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { try (ChronicleMap map = ChronicleMapBuilder.of(byte[].class, byte[] .class).createPersistedTo(persistenceFile)) { @@ -213,6 +213,9 @@ public class ChronicleMapTest { System.out.println(o == null ? "null" : new String(o)); map.put("hello".getBytes(), "world".getBytes()); } + } + + persistenceFile.delete(); } @Test @@ -1851,7 +1854,9 @@ public class ChronicleMapTest { assertEquals(2, value1.getValue()); } } + tmpFile.delete(); } + } diff --git a/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java b/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java index 0df11a3cf..6a232599a 100644 --- a/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java @@ -190,24 +190,26 @@ public class EntryCountMapTest { Random random = new Random(seed); int counter = minSize + random.nextInt(9999 + maxSize); final int stride = 1 + random.nextInt(100); - int maxKeySize = "key:".length() + + final int maxKeySize = "key:".length() + (int) round(log10(moreThanMaxSize(maxSize) * stride + counter)) + 1; - File f = null; - try ( final ChronicleMap map = - getSharedMap(minSize, segments, maxKeySize)) { - f = map.file(); - return es.submit(new Callable() { - @Override - public Void call() throws Exception { + + return es.submit(new Callable() { + @Override + public Void call() throws Exception { + File f = null; + try (final ChronicleMap map = + getSharedMap(minSize, segments, maxKeySize)) { + f = map.file(); testEntriesMaxSize0(segments, minSize, maxSize, seed, stride, map); + } finally { + if (f != null && f.exists()) + f.delete(); return null; } - }); - } finally { - if (f != null && f.exists()) - f.delete(); - } + } + }); + } void testEntriesMaxSize(int segments, int minSize, int maxSize, int seed) throws IOException { diff --git a/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java b/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java index 325d89b33..c8050fd36 100755 --- a/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java +++ b/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java @@ -83,6 +83,7 @@ public class LargeEntriesTest { es.awaitTermination(1, TimeUnit.MINUTES); assertTrue(es.isTerminated()); } + file.delete(); } private void warmUpCompression(int entrySize) { diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java index 7587d2105..6aa5d02bf 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java @@ -56,8 +56,9 @@ public class TCPSocketReplicationBootStrapTest { ChronicleMapBuilder map2aBuilder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8092, new InetSocketAddress("localhost", 8091)); + File persistenceFile = getPersistenceFile(); final ChronicleMap map2a = - map2aBuilder.createPersistedTo(getPersistenceFile()); + map2aBuilder.createPersistedTo(persistenceFile); map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2 long lastModificationTime; @@ -86,6 +87,9 @@ public class TCPSocketReplicationBootStrapTest { // add data into it waitTillEqual(5000); assertEquals("ADDED WHEN DISCONNECTED TO MAP1", map1.get(11)); + + map2.file().delete(); + persistenceFile.delete(); } @Test