From 8ed2f2d89d28f4002b990f6bed0d05644291a726 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Mon, 13 Apr 2020 15:31:32 +0100 Subject: [PATCH] https://github.com/OpenHFT/Chronicle-Map/issues/214, added net.openhft.chronicle.map.AutoResizeTest --- .../openhft/chronicle/map/AutoResizeTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/java/net/openhft/chronicle/map/AutoResizeTest.java diff --git a/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java b/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java new file mode 100644 index 000000000..4ca677ffe --- /dev/null +++ b/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java @@ -0,0 +1,65 @@ +package net.openhft.chronicle.map; + +import net.openhft.chronicle.core.Jvm; +import org.junit.Assert; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; + +public class AutoResizeTest { + + static { + Jvm.setExceptionHandlers(null, null, null); + } + + /** + * test that the auto resizes are not zero upon a restart + * + * @throws IOException IOException + */ + @Test + public void testAutoResizeNotZeroUponRestart() throws IOException { + + File cmap = File.createTempFile("chron", "cmap"); + + try (ChronicleMap map = ChronicleMapBuilder + .of(String.class, String.class) + .averageKeySize(10).averageValueSize(10) + .entries(100).actualSegments(10).maxBloatFactor(10).replication((byte) 1) + .createOrRecoverPersistedTo(cmap)) { + + int actual = map.remainingAutoResizes(); + Assert.assertNotEquals(0.0, actual); + System.out.println(actual); + } + + // if the file already exists it will reuse the existing settings, set above + + try (ChronicleMap map = ChronicleMapBuilder + .of(String.class, String.class) + .createOrRecoverPersistedTo(cmap)) { + int actual = map.remainingAutoResizes(); + Assert.assertNotEquals(0.0, map.remainingAutoResizes()); + System.out.println(actual); + } + + } + + @Test + public void testAutoResizeNotZeroUponRestart2() throws IOException { + + try (ChronicleMap map = ChronicleMapBuilder + .of(String.class, String.class) + .averageKeySize(10).averageValueSize(10) + .entries(100).actualSegments(10).maxBloatFactor(10).replication((byte) 1) + .create()) { + + int actual = map.remainingAutoResizes(); + Assert.assertNotEquals(0.0, actual); + System.out.println(actual); + } + + } + +}