删除不用的ConcurrentIdentityHashMap

This commit is contained in:
wenshao
2013-08-08 17:47:17 +08:00
parent 462e208bc9
commit b0f87d132d
4 changed files with 0 additions and 1401 deletions
@@ -1,32 +0,0 @@
package com.alibaba.druid.bvt.utils;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.util.ConcurrentIdentityHashMap;
public class ConcurrentIdentityHashMapTest extends TestCase {
public void test_0() throws Exception {
ConcurrentIdentityHashMap<Integer, String> map = new ConcurrentIdentityHashMap<Integer, String>();
Integer v1 = new Integer(3);
map.put(v1, "3");
Assert.assertTrue(map.contains("3"));
Assert.assertTrue(map.containsKey(v1));
Assert.assertFalse(map.contains("4"));
Assert.assertFalse(map.containsKey(new Integer(3)));
map.put(v1, "33");
Assert.assertFalse(map.contains("3"));
Assert.assertTrue(map.contains("33"));
Assert.assertEquals(1, map.size());
map.clear();
Assert.assertEquals(0, map.size());
}
}
@@ -1,63 +0,0 @@
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());
}
}
@@ -1,78 +0,0 @@
package com.alibaba.druid.bvt.utils;
import java.util.Map;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.util.ConcurrentIdentityHashMap;
public class ConcurrentIdentityHashMapTest3 extends TestCase {
public void test_0() throws Exception {
ConcurrentIdentityHashMap<Integer, Object> map = new ConcurrentIdentityHashMap<Integer, Object>(16, 0.75f, 2);
Integer[] keys = new Integer[10000];
for (int i = 0; i < keys.length; ++i) {
keys[i] = i;
}
for (int i = 0; i < keys.length; ++i) {
map.put(keys[i], "");
}
Assert.assertEquals(keys.length, map.size());
for (int i = 0; i < keys.length; ++i) {
map.put(keys[i], "");
}
for (Map.Entry<Integer, Object> entry : map.entrySet()) {
entry.getKey();
entry.getValue();
}
Assert.assertEquals(keys.length, map.size());
for (int i = 0; i < keys.length; ++i) {
map.replace(keys[i], "", "a");
}
for (int i = 0; i < keys.length; ++i) {
map.replace(keys[i], "", "b");
}
for (int i = 0; i < keys.length; ++i) {
map.replace(keys[i], "");
}
Assert.assertEquals(keys.length, map.size());
map.keys();
map.keys().hasMoreElements();
map.keys().nextElement();
for (int i = 0; i < keys.length; ++i) {
map.remove(keys[i]);
}
Assert.assertEquals(0, map.size());
map.keys();
map.entrySet();
map.size();
map.clear();
map.isEmpty();
map.entrySet().size();
map.entrySet().isEmpty();
map.entrySet().remove(null);
map.entrySet().clear();
map.entrySet().contains("");
map.values().size();
map.values().isEmpty();
map.values().remove(null);
map.values().clear();
map.values().contains("");
map.keySet().size();
map.keySet().isEmpty();
map.keySet().remove(null);
map.keySet().clear();
map.keySet().contains("");
}
}