focusing on using autoClose

Conflicts:
	src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java
	src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java
This commit is contained in:
Rob Austin
2015-07-25 16:45:02 +03:00
committed by leventov
parent e1b1ca237f
commit d9be91d106
4 changed files with 27 additions and 15 deletions
@@ -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<byte[], byte[]> 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();
}
}
@@ -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<CharSequence, LongValue> map =
getSharedMap(minSize, segments, maxKeySize)) {
f = map.file();
return es.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
return es.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
File f = null;
try (final ChronicleMap<CharSequence, LongValue> 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 {
@@ -83,6 +83,7 @@ public class LargeEntriesTest {
es.awaitTermination(1, TimeUnit.MINUTES);
assertTrue(es.isTerminated());
}
file.delete();
}
private void warmUpCompression(int entrySize) {
@@ -56,8 +56,9 @@ public class TCPSocketReplicationBootStrapTest {
ChronicleMapBuilder<Integer, CharSequence> map2aBuilder =
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
(byte) 2, 8092, new InetSocketAddress("localhost", 8091));
File persistenceFile = getPersistenceFile();
final ChronicleMap<Integer, CharSequence> 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