add testcase & remove unused code

This commit is contained in:
wenshao
2013-06-16 08:51:51 +08:00
parent 2aabdaea4b
commit da433839ee
98 changed files with 1424 additions and 1459 deletions
@@ -0,0 +1,63 @@
package com.alibaba.druid.bvt.utils;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.util.ConcurrentIdentityHashMap;
public class ConcurrentIdentityHashMapTest2 extends TestCase {
public void test_0() throws Exception {
ConcurrentIdentityHashMap<Integer, Object> map = new ConcurrentIdentityHashMap<Integer, Object>();
map.put(Integer.valueOf(1), "");
Assert.assertEquals(map.get(Integer.valueOf(1)), "");
Assert.assertEquals(map.get(new Integer(1)), null);
Assert.assertTrue(map.containsValue(""));
{
Exception error = null;
try {
map.containsValue(null);
} catch (NullPointerException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
Exception error = null;
try {
map.put(Integer.valueOf(1), null);
} catch (NullPointerException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
Exception error = null;
try {
map.putIfAbsent(Integer.valueOf(1), null);
} catch (NullPointerException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
map.put(Integer.valueOf(1), "123");
Assert.assertEquals(map.get(Integer.valueOf(1)), "123");
Assert.assertEquals(map.get(new Integer(1)), null);
map.putIfAbsent(Integer.valueOf(1), "234");
Assert.assertEquals(map.get(Integer.valueOf(1)), "123");
Assert.assertEquals(map.get(new Integer(1)), null);
map.remove(new Integer(1));
Assert.assertEquals(map.get(Integer.valueOf(1)), "123");
Assert.assertFalse(map.isEmpty());
map.remove(Integer.valueOf(1));
Assert.assertEquals(map.get(Integer.valueOf(1)), null);
Assert.assertTrue(map.isEmpty());
}
}