mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-14 10:26:26 +00:00
test[cow]: CopyOnWriteHashMap test
This commit is contained in:
@@ -17,11 +17,10 @@ import com.zfoo.orm.OrmContext;
|
||||
import com.zfoo.orm.entity.bag.BagItem;
|
||||
import com.zfoo.orm.entity.bag.Item;
|
||||
import com.zfoo.orm.entity.bag.MapEntity;
|
||||
import com.zfoo.protocol.collection.concurrent.CopyOnWriteHashMap;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -32,7 +31,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@Ignore
|
||||
public class MapTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(MapTest.class);
|
||||
|
||||
@Test
|
||||
public void insertTest() {
|
||||
@@ -61,17 +59,19 @@ public class MapTest {
|
||||
copyOnWriteArrayList.add(2);
|
||||
entity.setCopyOnWriteArrayList(copyOnWriteArrayList);
|
||||
|
||||
ConcurrentHashMap<Long,Integer> concurrentHashMap=new ConcurrentHashMap<>();
|
||||
concurrentHashMap.put(1L,1);
|
||||
concurrentHashMap.put(2L,2);
|
||||
ConcurrentHashMap<Long, Integer> concurrentHashMap = new ConcurrentHashMap<>();
|
||||
concurrentHashMap.put(1L, 1);
|
||||
concurrentHashMap.put(2L, 2);
|
||||
entity.setConcurrentHashMap(concurrentHashMap);
|
||||
|
||||
ConcurrentHashMap<Long,ConcurrentHashMap<Integer,Integer>> concurrentHashMapConcurrentHashMap=new ConcurrentHashMap<>();
|
||||
|
||||
ConcurrentHashMap<Integer, Integer> conMap = new ConcurrentHashMap<>();
|
||||
conMap.put(1,1);
|
||||
concurrentHashMapConcurrentHashMap.putIfAbsent(1L,conMap);
|
||||
entity.setConcurrentHashMapAndConcurrentHashMap(concurrentHashMapConcurrentHashMap);
|
||||
CopyOnWriteHashMap<Long, CopyOnWriteHashMap<Integer, Integer>> copyOnWriteHashMap = new CopyOnWriteHashMap<>();
|
||||
CopyOnWriteHashMap<Integer, Integer> copMap = new CopyOnWriteHashMap<>();
|
||||
copMap.put(1, 1);
|
||||
copMap.put(2, 2);
|
||||
copMap.put(3, 3);
|
||||
copyOnWriteHashMap.putIfAbsent(1L, copMap);
|
||||
copyOnWriteHashMap.putIfAbsent(2L, copMap);
|
||||
entity.setCopyOnWriteHashMap(copyOnWriteHashMap);
|
||||
var bagMap = new HashMap<String, BagItem>();
|
||||
entity.setBagMap(bagMap);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ package com.zfoo.orm.entity.bag;
|
||||
|
||||
import com.zfoo.orm.anno.Id;
|
||||
import com.zfoo.orm.model.IEntity;
|
||||
import com.zfoo.protocol.collection.concurrent.CopyOnWriteHashMap;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -30,7 +31,7 @@ public class MapEntity implements IEntity<Long> {
|
||||
|
||||
private ConcurrentHashMap<Long, Integer> concurrentHashMap = new ConcurrentHashMap<>();
|
||||
|
||||
private ConcurrentHashMap<Long, ConcurrentHashMap<Integer,Integer>> concurrentHashMapAndConcurrentHashMap = new ConcurrentHashMap<>();
|
||||
private CopyOnWriteHashMap<Long, CopyOnWriteHashMap<Integer,Integer>> copyOnWriteHashMap = new CopyOnWriteHashMap<>();
|
||||
private Map<String, BagItem> bagMap = new HashMap<>();
|
||||
|
||||
private Map<String, Map<String, String>> baseMap = new HashMap<>();
|
||||
@@ -52,6 +53,14 @@ public class MapEntity implements IEntity<Long> {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<Integer> getList() {
|
||||
return list;
|
||||
}
|
||||
@@ -60,12 +69,28 @@ public class MapEntity implements IEntity<Long> {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
public CopyOnWriteArrayList<Integer> getCopyOnWriteArrayList() {
|
||||
return copyOnWriteArrayList;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
public void setCopyOnWriteArrayList(CopyOnWriteArrayList<Integer> copyOnWriteArrayList) {
|
||||
this.copyOnWriteArrayList = copyOnWriteArrayList;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Long, Integer> getConcurrentHashMap() {
|
||||
return concurrentHashMap;
|
||||
}
|
||||
|
||||
public void setConcurrentHashMap(ConcurrentHashMap<Long, Integer> concurrentHashMap) {
|
||||
this.concurrentHashMap = concurrentHashMap;
|
||||
}
|
||||
|
||||
public CopyOnWriteHashMap<Long, CopyOnWriteHashMap<Integer, Integer>> getCopyOnWriteHashMap() {
|
||||
return copyOnWriteHashMap;
|
||||
}
|
||||
|
||||
public void setCopyOnWriteHashMap(CopyOnWriteHashMap<Long, CopyOnWriteHashMap<Integer, Integer>> copyOnWriteHashMap) {
|
||||
this.copyOnWriteHashMap = copyOnWriteHashMap;
|
||||
}
|
||||
|
||||
public Map<String, BagItem> getBagMap() {
|
||||
@@ -172,31 +197,6 @@ public class MapEntity implements IEntity<Long> {
|
||||
this.doubleBagMap = doubleBagMap;
|
||||
}
|
||||
|
||||
public CopyOnWriteArrayList<Integer> getCopyOnWriteArrayList() {
|
||||
return copyOnWriteArrayList;
|
||||
}
|
||||
|
||||
public void setCopyOnWriteArrayList(CopyOnWriteArrayList<Integer> copyOnWriteArrayList) {
|
||||
this.copyOnWriteArrayList = copyOnWriteArrayList;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Long, Integer> getConcurrentHashMap() {
|
||||
return concurrentHashMap;
|
||||
}
|
||||
|
||||
public void setConcurrentHashMap(ConcurrentHashMap<Long, Integer> concurrentHashMap) {
|
||||
this.concurrentHashMap = concurrentHashMap;
|
||||
}
|
||||
|
||||
|
||||
public ConcurrentHashMap<Long, ConcurrentHashMap<Integer, Integer>> getConcurrentHashMapAndConcurrentHashMap() {
|
||||
return concurrentHashMapAndConcurrentHashMap;
|
||||
}
|
||||
|
||||
public void setConcurrentHashMapAndConcurrentHashMap(ConcurrentHashMap<Long, ConcurrentHashMap<Integer, Integer>> concurrentHashMapAndConcurrentHashMap) {
|
||||
this.concurrentHashMapAndConcurrentHashMap = concurrentHashMapAndConcurrentHashMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
Reference in New Issue
Block a user