diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 4304bca3a..5e5e7db3e 100644 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -22,14 +22,12 @@ import net.openhft.chronicle.common.ChronicleHashErrorListener; import net.openhft.chronicle.common.serialization.*; import net.openhft.chronicle.common.threadlocal.Provider; import net.openhft.chronicle.common.threadlocal.ThreadLocalCopies; -import net.openhft.lang.MemoryUnit; import net.openhft.lang.collection.DirectBitSet; import net.openhft.lang.collection.SingleThreadedDirectBitSet; import net.openhft.lang.io.*; import net.openhft.lang.io.serialization.JDKObjectSerializer; import net.openhft.lang.io.serialization.ObjectFactory; import net.openhft.lang.io.serialization.impl.VanillaBytesMarshallerFactory; -import net.openhft.lang.model.Byteable; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -483,7 +481,8 @@ class VanillaChronicleMap, * @param newValue the new value you wish to store in the map * @return the value that was replaced */ - V replaceIfValueIs(@NotNull final K key, final V existingValue, final V newValue) { + V replaceIfValueIs(@net.openhft.lang.model.constraints.NotNull final K key, + final V existingValue, final V newValue) { checkKey(key); checkValue(newValue); ThreadLocalCopies copies = keyInteropProvider.getCopies(null); diff --git a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java index f67549868..382c299cc 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java @@ -21,7 +21,6 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.map.jrs166.JSR166TestCase; import org.junit.Test; -import java.io.File; import java.io.IOException; import java.util.*; @@ -36,67 +35,27 @@ import static org.junit.Assert.*; */ public class ReplicatedChronicleMapTest extends JSR166TestCase { - private static File getPersistenceFile() { - String TMP = System.getProperty("java.io.tmpdir"); - File file = new File(TMP + "/chm-test" + System.nanoTime()); - file.deleteOnExit(); - return file; - } - - ChronicleMap newShmIntString(int size) throws IOException { - ChronicleMapBuilder.of(Integer.class, CharSequence.class) - .entries(size).replicators((byte) 1); - return ChronicleMapBuilder.of(Integer.class, CharSequence.class) - .entries(size) - .create(); - - } - - ChronicleMap newShmListBoolean(int size) throws IOException { - ChronicleMapBuilder.of(ArrayList.class, CharSequence.class) - .entries(size).replicators((byte) 1); - return ChronicleMapBuilder.of(ArrayList.class, CharSequence.class) - .entries(size) - .create(); - - } - - - ChronicleMap newShmListBoolean() throws IOException { - ChronicleMapBuilder.of(ArrayList.class, CharSequence.class).replicators((byte) 1); - return ChronicleMapBuilder.of(ArrayList.class, CharSequence.class) - .create(); - - } - - ChronicleMap newShmStringString(int size) throws IOException { - ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) - .entries(size).replicators((byte) 1); - return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) - .entries(size) - .create(); - - } ChronicleMap newShmIntString() throws IOException { - ChronicleMapBuilder.of(Integer.class, CharSequence.class).replicators((byte) 1); return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .create(); } - ChronicleMap newShmBiBoolean() throws IOException { - ChronicleMapBuilder.of(BI.class, Boolean.class).replicators((byte) 1); - return ChronicleMapBuilder.of(BI.class, Boolean.class).create(); + + ChronicleMap newShmStringString() throws IOException { + return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) + .create(); } + /** * Returns a new map from Integers 1-5 to Strings "A"-"E". */ private ChronicleMap map5() throws IOException { - ChronicleMap map = newShmIntString(10); + ChronicleMap map = newShmIntString(); assertTrue(map.isEmpty()); map.put(JSR166TestCase.one, "A"); map.put(JSR166TestCase.two, "B"); @@ -503,7 +462,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testGet_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.get(null); shouldThrow(); } catch (NullPointerException success) { @@ -516,7 +475,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testContainsKey_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.containsKey(null); shouldThrow(); } catch (NullPointerException success) { @@ -529,7 +488,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testPut1_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.put(null, "whatever"); shouldThrow(); } catch (NullPointerException success) { @@ -542,7 +501,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testPut2_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.put(JSR166TestCase.notPresent, null); shouldThrow(); } catch (NullPointerException success) { @@ -555,7 +514,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testPutIfAbsent1_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.putIfAbsent(null, "whatever"); shouldThrow(); } catch (NullPointerException success) { @@ -603,7 +562,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testReplace_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.replace(null, "whatever"); shouldThrow(); } catch (NullPointerException success) { @@ -616,7 +575,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testReplaceValue_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.replace(null, "A", "whatever"); shouldThrow(); } catch (NullPointerException success) { @@ -655,7 +614,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testPutIfAbsent2_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.putIfAbsent(JSR166TestCase.notPresent, null); shouldThrow(); } catch (NullPointerException success) { @@ -668,7 +627,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testReplace2_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.replace(JSR166TestCase.notPresent, null); shouldThrow(); } catch (NullPointerException success) { @@ -681,7 +640,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testReplaceValue2_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.replace(JSR166TestCase.notPresent, null, "A"); shouldThrow(); } catch (NullPointerException success) { @@ -694,7 +653,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testReplaceValue3_NullPointerException() throws IOException { try { - ChronicleMap c = newShmIntString(5); + ChronicleMap c = newShmIntString(); c.replace(JSR166TestCase.notPresent, "A", null); shouldThrow(); } catch (NullPointerException success) { @@ -707,7 +666,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testRemove1_NullPointerException() throws IOException { try { - ChronicleMap c = newShmStringString(5); + ChronicleMap c = newShmStringString(); c.put("sadsdf", "asdads"); c.remove(null); shouldThrow(); @@ -721,7 +680,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { @Test public void testRemove2_NullPointerException() throws IOException { try { - ChronicleMap c = newShmStringString(5); + ChronicleMap c = newShmStringString(); c.put("sadsdf", "asdads"); c.remove(null, "whatever"); shouldThrow(); @@ -734,7 +693,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { */ @Test public void testRemove3() throws IOException { - ChronicleMap c = newShmStringString(5); + ChronicleMap c = newShmStringString(); c.put("sadsdf", "asdads"); assertFalse(c.remove("sadsdf", null)); } diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTests.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTests.java index 115eb6718..7eb7f7d7c 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTests.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTests.java @@ -93,6 +93,7 @@ public class TCPSocketReplicationBootStrapTests { ChronicleMapBuilder map2aBuilder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8076); + final ReplicatedChronicleMap map2a = (ReplicatedChronicleMap) map2aBuilder.file(getPersistenceFile()).create();