diff --git a/orm/src/test/java/com/zfoo/orm/cache/EntityCachesTest.java b/orm/src/test/java/com/zfoo/orm/cache/EntityCachesTest.java index 81d989f9..f1f3b8f9 100644 --- a/orm/src/test/java/com/zfoo/orm/cache/EntityCachesTest.java +++ b/orm/src/test/java/com/zfoo/orm/cache/EntityCachesTest.java @@ -24,6 +24,8 @@ import org.junit.Ignore; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; +import java.util.ArrayList; + /** * @author godotg @@ -36,6 +38,13 @@ public class EntityCachesTest { public void test() { var context = new ClassPathXmlApplicationContext("application.xml"); + // 每次运行前先删除数据库 + var collection = OrmContext.getOrmManager().getCollection(UserEntity.class); + collection.drop(); + + // 再插入 + batchInsert(); + // 动态去拿到UserEntity的EntityCaches @SuppressWarnings("unchecked") var userEntityCaches = (IEntityCache) OrmContext.getOrmManager().getEntityCaches(UserEntity.class); @@ -81,4 +90,13 @@ public class EntityCachesTest { ThreadUtils.sleep(Long.MAX_VALUE); } + public void batchInsert() { + var listUser = new ArrayList(); + for (var i = 1; i <= 10; i++) { + var userEntity = new UserEntity(i, (byte) 1, (short) i, i, true, "helloOrm" + i, "helloOrm" + i); + listUser.add(userEntity); + } + OrmContext.getAccessor().batchInsert(listUser); + } + }