BAEL-4686:Allow Null test
This commit is contained in:
parent
bd6bc03c93
commit
2a1baae599
|
@ -0,0 +1,27 @@
|
|||
package com.baeldung.map.concurrenthashmap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NullAllowInMapTest {
|
||||
|
||||
@Test
|
||||
public void allowOnlyNull_In_SynchronizedMap() {
|
||||
Map<String, Integer> map = Collections
|
||||
.synchronizedMap(new HashMap<String, Integer>());
|
||||
map.put(null, 1);
|
||||
Assert.assertTrue(map.get(null).equals(1));
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void allowOnlyNull_In_ConcurrentHasMap() {
|
||||
Map<String, Integer> map = new ConcurrentHashMap<>();
|
||||
map.put(null, 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConcurrentHashMapVsSynchronizedMapPerformanceTest {
|
||||
public class PerformanceTest {
|
||||
|
||||
public final static int THREAD_POOL_SIZE = 5;
|
||||
public final static int TEST_ITERATIONS = 5;
|
Loading…
Reference in New Issue