diff --git a/test/com/wentch/redkale/source/FilterNodeTest.java b/test/com/wentch/redkale/source/FilterNodeTest.java deleted file mode 100644 index 3d83cf6fc..000000000 --- a/test/com/wentch/redkale/source/FilterNodeTest.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.source; - -import com.wentch.redkale.convert.json.*; -import static com.wentch.redkale.source.FilterExpress.*; -import com.wentch.redkale.util.*; -import java.util.*; -import java.util.function.*; -import javax.persistence.*; - -/** - * - * @author zhangjx - */ -public class FilterNodeTest { - - public static void main(String[] args) throws Exception { - final Function fullloader = (Class t) -> new ArrayList(); - final Function func = (Class t) -> EntityInfo.load(t, 0, false, fullloader); - final EntityInfo carEntity = EntityInfo.load(CarTestTable.class, 0, false, (t) -> CarTestTable.createList()); - final EntityInfo userEntity = EntityInfo.load(UserTestTable.class, 0, false, (t) -> UserTestTable.createList()); - final EntityInfo typeEntity = EntityInfo.load(CarTypeTestTable.class, 0, false, (t) -> CarTypeTestTable.createList()); - - final CarTestBean bean = new CarTestBean(); - bean.carid = 70002; - bean.username = "用户1"; - bean.createtime = 500; - bean.typename = "法拉利"; - FilterNode joinNode1 = FilterJoinNode.create(UserTestTable.class, new String[]{"userid", "username"}, "username", LIKE, bean.username) - .or(FilterJoinNode.create(UserTestTable.class, new String[]{"userid", "username"}, "createtime", GREATERTHAN, bean.createtime)); - FilterNode joinNode2 = FilterJoinNode.create(CarTypeTestTable.class, "cartype", "typename", LIKE, bean.typename); - FilterNode node = CarTestBean.caridTransient() ? (joinNode2.or(joinNode1)) : FilterNode.create("carid", GREATERTHAN, bean.carid).and(joinNode1).or(joinNode2); - FilterNode beanNode = FilterNodeBean.createFilterNode(bean); - System.out.println("node.string = " + node); - System.out.println("bean.string = " + beanNode); - Map nodeJoinTabalis = node.getJoinTabalis(); - Map beanJoinTabalis = beanNode.getJoinTabalis(); - CharSequence nodeJoinsql = node.createSQLJoin(func, nodeJoinTabalis, carEntity); - CharSequence beanJoinsql = beanNode.createSQLJoin(func, beanJoinTabalis, carEntity); - CharSequence nodeWhere = node.createSQLExpress(carEntity, nodeJoinTabalis); - CharSequence beanWhere = beanNode.createSQLExpress(carEntity, beanJoinTabalis); - System.out.println("node.sql = SELECT a.* FROM " + CarTestTable.class.getSimpleName().toLowerCase() + " a" + (nodeJoinsql == null ? "" : nodeJoinsql) + " WHERE " + nodeWhere); - System.out.println("bean.sql = SELECT a.* FROM " + CarTestTable.class.getSimpleName().toLowerCase() + " a" + (beanJoinsql == null ? "" : beanJoinsql) + " WHERE " + beanWhere); - assert node.isCacheUseable(func) : "isCacheUseable 应该是true"; - assert beanNode.isCacheUseable(func) : "isCacheUseable 应该是true"; - System.out.println("node.Predicate = " + node.createPredicate(carEntity.getCache())); - System.out.println("bean.Predicate = " + beanNode.createPredicate(carEntity.getCache())); - System.out.println("node.sheet = " +carEntity.getCache().querySheet(null, new Flipper(), node)); - System.out.println("bean.sheet = " +carEntity.getCache().querySheet(null, new Flipper(), beanNode)); - } - - public static class CarTestBean implements FilterBean { - - @FilterGroup("[OR].[AND]a") - @FilterColumn(express = GREATERTHAN) - @Transient - public long carid; - - @FilterGroup("[OR].[AND]a.[OR]c") - @FilterColumn(express = LIKE) - @FilterJoinColumn(table = UserTestTable.class, columns = {"userid", "username"}) - public String username; - - @FilterGroup("[OR].[AND]a.[OR]c") - @FilterColumn(express = GREATERTHAN) - @FilterJoinColumn(table = UserTestTable.class, columns = {"userid", "username"}) - public long createtime; - - @FilterGroup("[OR]") - @FilterColumn(express = LIKE) - @FilterJoinColumn(table = CarTypeTestTable.class, columns = {"cartype"}) - public String typename; - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - public static boolean caridTransient() { - try { - return CarTestBean.class.getDeclaredField("carid").getAnnotation(Transient.class) != null; - } catch (Exception e) { - e.printStackTrace(); - return true; - } - } - } - - @AutoLoad - @Cacheable - public static class CarTestTable { - - public static List createList() { - List list = new ArrayList<>(); - - list.add(new CarTestTable(70001, 101, 1000011, "我的车")); - list.add(new CarTestTable(70002, 102, 1000012, "我的车")); - list.add(new CarTestTable(70003, 103, 1000013, "我的车")); - list.add(new CarTestTable(70004, 104, 1000014, "我的车")); - list.add(new CarTestTable(70005, 105, 1000015, "我的车")); - - list.add(new CarTestTable(70201, 201, 1000031, "我的车")); - list.add(new CarTestTable(70202, 202, 1000032, "我的车")); - list.add(new CarTestTable(70203, 203, 1000033, "我的车")); - list.add(new CarTestTable(70204, 204, 1000034, "我的车")); - list.add(new CarTestTable(70205, 205, 1000035, "我的车")); - list.add(new CarTestTable(70505, 301, 1008000, "我的车")); - - return list; - } - - @Id - private long carid; - - private int cartype; - - private int userid; - - private String username; - - private String cartitle; - - public CarTestTable() { - - } - - public CarTestTable(long carid, int cartype, int userid, String cartitle) { - this.carid = carid; - this.cartype = cartype; - this.userid = userid; - this.username = "用户" + userid % 1000; - this.cartitle = cartitle; - } - - public long getCarid() { - return carid; - } - - public void setCarid(long carid) { - this.carid = carid; - } - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getCartitle() { - return cartitle; - } - - public void setCartitle(String cartitle) { - this.cartitle = cartitle; - } - - public int getCartype() { - return cartype; - } - - public void setCartype(int cartype) { - this.cartype = cartype; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - } - - @AutoLoad - @Cacheable - public static class CarTypeTestTable { - - public static List createList() { - List list = new ArrayList<>(); - list.add(new CarTypeTestTable(101, "奥迪A1")); - list.add(new CarTypeTestTable(102, "奥迪A2")); - list.add(new CarTypeTestTable(103, "奥迪A3")); - list.add(new CarTypeTestTable(104, "奥迪A4")); - list.add(new CarTypeTestTable(105, "奥迪A5")); - list.add(new CarTypeTestTable(201, "奔驰S1")); - list.add(new CarTypeTestTable(202, "奔驰S2")); - list.add(new CarTypeTestTable(203, "奔驰S3")); - list.add(new CarTypeTestTable(204, "奔驰S4")); - list.add(new CarTypeTestTable(205, "奔驰S5")); - list.add(new CarTypeTestTable(301, "法拉利")); - return list; - } - - @Id - private int cartype; - - private String typename; - - public CarTypeTestTable() { - - } - - public CarTypeTestTable(int cartype, String typename) { - this.cartype = cartype; - this.typename = typename; - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - public int getCartype() { - return cartype; - } - - public void setCartype(int cartype) { - this.cartype = cartype; - } - - public String getTypename() { - return typename; - } - - public void setTypename(String typename) { - this.typename = typename; - } - - } - - @AutoLoad - @Cacheable - public static class UserTestTable { - - public static List createList() { - List list = new ArrayList<>(); - for (int i = 11; i <= 50; i++) { - list.add(new UserTestTable(1000000 + i, "用户" + i, i * 20)); - } - list.add(new UserTestTable(1008000, "车主A", 20)); - return list; - } - - @Id - private int userid; - - private String username; - - private long createtime; - - public UserTestTable() { - } - - public UserTestTable(int userid, String username, long createtime) { - this.userid = userid; - this.username = username; - this.createtime = createtime; - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public long getCreatetime() { - return createtime; - } - - public void setCreatetime(long createtime) { - this.createtime = createtime; - } - - } -} diff --git a/test/com/wentch/redkale/test/convert/BasedEntity.java b/test/com/wentch/redkale/test/convert/BasedEntity.java deleted file mode 100644 index 5cc9642bd..000000000 --- a/test/com/wentch/redkale/test/convert/BasedEntity.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.convert.json.JsonFactory; -import java.io.Serializable; - -/** - * - * @author zhangjx - */ -public abstract class BasedEntity implements Serializable { - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } -} diff --git a/test/com/wentch/redkale/test/convert/BsonTestMain.java b/test/com/wentch/redkale/test/convert/BsonTestMain.java deleted file mode 100644 index 5504608fb..000000000 --- a/test/com/wentch/redkale/test/convert/BsonTestMain.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.convert.bson.*; -import com.wentch.redkale.convert.json.*; -import com.wentch.redkale.util.*; -import java.io.Serializable; -import java.nio.*; -import java.util.Arrays; - -/** - * - * @author zhangjx - */ -public class BsonTestMain { - - public static void main(String[] args) throws Exception { - Serializable[] sers = new Serializable[]{"aaa",4}; - final BsonConvert convert = BsonFactory.root().getConvert(); - byte[] bytes = convert.convertTo(sers); - Serializable[] a = convert.convertFrom(Serializable[].class, bytes); - System.out.println(Arrays.toString(a)); - main2(args); - } - public static void main2(String[] args) throws Exception { - final BsonConvert convert = BsonFactory.root().getConvert(); - TestEntry2 entry = TestEntry2.create(); - byte[] bytes = convert.convertTo(TestEntry.class, entry); - Utility.println(null,bytes); - System.out.println(JsonFactory.root().getConvert().convertTo(entry)); - TestEntry rs = convert.convertFrom(TestEntry.class, bytes); - System.out.println(rs.toString()); - System.out.println(JsonFactory.root().getConvert().convertTo(rs)); - - TestComplextBean bean = new TestComplextBean(); - byte[] bytes2 = convert.convertTo(Object.class, bean); - final int len = bytes2.length; - BsonByteBufferWriter writer = convert.pollBsonWriter(()-> ByteBuffer.allocate(len/2)); - convert.convertTo(writer, bean); - bytes2 = writer.toArray(); - System.out.println(convert.convertFrom(TestComplextBean.class, bytes2).toString()); - } -} diff --git a/test/com/wentch/redkale/test/convert/JsonTestMain.java b/test/com/wentch/redkale/test/convert/JsonTestMain.java deleted file mode 100644 index edc965bf5..000000000 --- a/test/com/wentch/redkale/test/convert/JsonTestMain.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.convert.json.*; -import com.wentch.redkale.util.*; -import java.lang.reflect.*; -import java.nio.*; -import java.util.*; - -/** - * - * @author zhangjx - */ -public class JsonTestMain { - - private static final Type MAPTYPE = new TypeToken>() { - }.getType(); - - public static void main(String[] args) throws Exception { - JsonFactory factory = JsonFactory.root(); - factory.setTiny(true); - final JsonConvert convert = JsonFactory.root().getConvert(); - String json = "{\"access_token\":\"vVX2bIjN5P9TMOphDkStM96eNWapAehTuWAlVDO74aFaYxLwj2b-9-T9p_W2mfr9\",\"expires_in\":7200, \"aa\":\"\"}"; - Map map = convert.convertFrom(MAPTYPE, json); - System.out.println(map); - System.out.println(convert.convertTo(map)); - ByteBuffer[] buffers = convert.convertTo(() -> ByteBuffer.allocate(1024), map); - byte[] bs = new byte[buffers[0].remaining()]; - buffers[0].get(bs); - System.out.println(new String(bs)); - } -} diff --git a/test/com/wentch/redkale/test/convert/TestComplextBean.java b/test/com/wentch/redkale/test/convert/TestComplextBean.java deleted file mode 100644 index 212957dae..000000000 --- a/test/com/wentch/redkale/test/convert/TestComplextBean.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import java.util.List; -import javax.persistence.*; - -/** - * - * @author zhangjx - */ -public class TestComplextBean extends BasedEntity{ - - @Id - private int userid; - - private String chname = ""; - - private int organid; - - private String photos = ""; - - private String introvideourl = ""; - - private String introduction = ""; - - private String linkemail = ""; - - private String telephone = ""; - - private String skype = ""; - - private String weixin = ""; - - private String jego = ""; - - private String city = ""; //'导师所在城市', - - private String states = ""; //导师所在洲名 - - private String country = ""; //导师所在国家 - - private int zones;// 导师所在时区 - - private int lac;// 1东北部,2西部,4中西部,8南部 - - private short hyproficient; - - private long createtime; - - private long updatetime; - - private int edutype; - - private int major; - - private short iecalevel; //IECA会员或者认证:1、IECA会员一级 ;2、IECA会员二级 ;3、IECA会员三级 ;4、IECA认证一级;5、IECA认证二级;6、IECA认证三级;7、非会员非认证导师' - - private int workyear; - - private int rateservice;//'服务态度评分(总分)', - - private int ratemajor;//'咨询专业评分(总分)', - - private int ratenum;//'导师评分人次数(总评价人次)', - - private int successnum;//'服务过多少名申请学生', - - private int successrate; //'申请的成功率: 9500,表示成功率为95%', - - private int successhotrate; //'常青藤学校比例: 6000,表示比例为60%', - - private long hots; - - private int starlevel; - - private String degreestr = ""; - - private String searchflag=""; - - private String searchkey = ""; - - @Transient - private boolean baseinfoAll = true;//基本信息是否完整 - - @Transient - private List prizes; - - @Transient - private UserInfo user; - - public List getPrizes() { - return prizes; - } - - public void setPrizes(List prizes) { - this.prizes = prizes; - } - - public boolean isBaseinfoAll() { - return baseinfoAll; - } - - public void setBaseinfoAll(boolean baseinfoAll) { - this.baseinfoAll = baseinfoAll; - } - - public UserInfo getUser() { - return user; - } - - public void setUser(UserInfo user) { - this.user = user; - } - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getChname() { - return chname; - } - - public void setChname(String chname) { - this.chname = chname; - } - - public int getOrganid() { - return organid; - } - - public void setOrganid(int organid) { - this.organid = organid; - } - - public String getPhotos() { - return photos; - } - - public void setPhotos(String photos) { - this.photos = photos; - } - - public String getIntrovideourl() { - return introvideourl; - } - - public void setIntrovideourl(String introvideourl) { - this.introvideourl = introvideourl; - } - - public String getIntroduction() { - return introduction; - } - - public void setIntroduction(String introduction) { - this.introduction = introduction; - } - - public String getLinkemail() { - return linkemail; - } - - public void setLinkemail(String linkemail) { - this.linkemail = linkemail; - } - - public String getTelephone() { - return telephone; - } - - public void setTelephone(String telephone) { - this.telephone = telephone; - } - - public String getSkype() { - return skype; - } - - public void setSkype(String skype) { - this.skype = skype; - } - - public String getWeixin() { - return weixin; - } - - public void setWeixin(String weixin) { - this.weixin = weixin; - } - - public String getJego() { - return jego; - } - - public void setJego(String jego) { - this.jego = jego; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getStates() { - return states; - } - - public void setStates(String states) { - this.states = states; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public int getZones() { - return zones; - } - - public void setZones(int zones) { - this.zones = zones; - } - - public int getLac() { - return lac; - } - - public void setLac(int lac) { - this.lac = lac; - } - - public short getHyproficient() { - return hyproficient; - } - - public void setHyproficient(short hyproficient) { - this.hyproficient = hyproficient; - } - - public long getCreatetime() { - return createtime; - } - - public void setCreatetime(long createtime) { - this.createtime = createtime; - } - - public long getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(long updatetime) { - this.updatetime = updatetime; - } - - public int getEdutype() { - return edutype; - } - - public void setEdutype(int edutype) { - this.edutype = edutype; - } - - public int getMajor() { - return major; - } - - public void setMajor(int major) { - this.major = major; - } - - public short getIecalevel() { - return iecalevel; - } - - public void setIecalevel(short iecalevel) { - this.iecalevel = iecalevel; - } - - public int getWorkyear() { - return workyear; - } - - public void setWorkyear(int workyear) { - this.workyear = workyear; - } - - public int getRateservice() { - return rateservice; - } - - public void setRateservice(int rateservice) { - this.rateservice = rateservice; - } - - public int getRatemajor() { - return ratemajor; - } - - public void setRatemajor(int ratemajor) { - this.ratemajor = ratemajor; - } - - public int getRatenum() { - return ratenum; - } - - public void setRatenum(int ratenum) { - this.ratenum = ratenum; - } - - public int getSuccessnum() { - return successnum; - } - - public void setSuccessnum(int successnum) { - this.successnum = successnum; - } - - public int getSuccessrate() { - return successrate; - } - - public void setSuccessrate(int successrate) { - this.successrate = successrate; - } - - public int getSuccesshotrate() { - return successhotrate; - } - - public void setSuccesshotrate(int successhotrate) { - this.successhotrate = successhotrate; - } - - public long getHots() { - return hots; - } - - public void setHots(long hots) { - this.hots = hots; - } - - public int getStarlevel() { - return starlevel; - } - - public void setStarlevel(int starlevel) { - this.starlevel = starlevel; - } - - public String getDegreestr() { - return degreestr; - } - - public void setDegreestr(String degreestr) { - this.degreestr = degreestr; - } - - public String getSearchflag() { - return searchflag; - } - - public void setSearchflag(String searchflag) { - this.searchflag = searchflag; - } - - public String getSearchkey() { - return searchkey; - } - - public void setSearchkey(String searchkey) { - this.searchkey = searchkey; - } - -} diff --git a/test/com/wentch/redkale/test/convert/TestConvertBean.java b/test/com/wentch/redkale/test/convert/TestConvertBean.java deleted file mode 100644 index f35904702..000000000 --- a/test/com/wentch/redkale/test/convert/TestConvertBean.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.util.Sheet; -import com.wentch.redkale.util.TypeToken; -import com.wentch.redkale.convert.bson.BsonFactory; -import com.wentch.redkale.convert.json.JsonFactory; -import java.lang.reflect.*; -import java.util.*; - -/** - * - * @author zhangjx - * @param - * @param - * @param - */ -public class TestConvertBean { - - public static class Entry { - - private String id; - - private String remark; - - public Entry(){ - - } - public Entry(String id, String remark) { - this.id = id; - this.remark = remark; - } - - @Override - public String toString() { - return "Entry{" + "id=" + id + ", remark=" + remark + '}'; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - } - - private T name; - - private List list; - - private Map map; - - public static void main(String[] args) throws Throwable { - TestConvertBean bean = new TestConvertBean<>(); - bean.setName(1234567890L); - List list = new ArrayList<>(); - list.add("你好"); - bean.setList(list); - Map map = new HashMap<>(); - map.put("myvalue", new Entry("myid", "")); - bean.setMap(map); - final Type type = new TypeToken>() { - }.getType(); - JsonFactory.root().setTiny(true); - String json = JsonFactory.root().getConvert().convertTo(type, bean); - System.out.println(json); - System.out.println( JsonFactory.root().getConvert().convertFrom(type, json).toString()); -// JsonFactory child = JsonFactory.root().createChild(); -// System.out.println(child.register(TestConvertBean.class, "name", new ConvertColumnEntry("name", true))); -// child.register(TestConvertBean.class, child.createEncoder(type)); -// System.out.println(child.getConvert().convertTo(type, bean)); - if(true) return; - - Sheet sheet = new Sheet<>(); - sheet.setTotal(20); - List list2 = new ArrayList<>(); - list2.add(new Entry("myid", "描述")); - sheet.setRows(list2); - final Type type2 = new TypeToken>() { - }.getType(); - System.out.println(JsonFactory.root().getConvert().convertTo(type2, sheet)); - sheet = BsonFactory.root().getConvert().convertFrom(type2, BsonFactory.root().getConvert().convertTo(type2, sheet)); - System.out.println(JsonFactory.root().getConvert().convertTo(type2, sheet)); - } - - @Override - public String toString() { - return "TestConvertBean{" + "name=" + name + ", list=" + list + ", map=" + map + '}'; - } - - public T getName() { - return name; - } - - public void setName(T name) { - this.name = name; - } - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } - -} diff --git a/test/com/wentch/redkale/test/convert/TestEntry.java b/test/com/wentch/redkale/test/convert/TestEntry.java deleted file mode 100644 index a8a960d8b..000000000 --- a/test/com/wentch/redkale/test/convert/TestEntry.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.convert.json.JsonFactory; -import com.wentch.redkale.util.Creator; -import java.util.*; - -/** - * - * @author zhangjx - */ -public class TestEntry { - - private String name; - - private String desc=""; - - private int id = (int) System.currentTimeMillis(); - - private int[] addrs; - - private List lists; - - private String[] strings; - - private Map map; - - public static TestEntry create() { - TestEntry v = new TestEntry(); - v.setName("this is name\n \"test"); - v.setId(1000000001); - v.setAddrs(new int[]{22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999}); - v.setStrings(new String[]{"zzz","yyy","xxx"}); - List list = new ArrayList<>(); - list.add("aaaa"); - list.add("bbbb"); - list.add("cccc"); - v.setLists(list); - Map map = new HashMap<>(); - map.put("AAA", 111); - map.put("BBB", 222); - map.put("CCC", 333); - v.setMap(map); - return v; - } - - public static void main(String[] args) throws Exception { - System.out.println(JsonFactory.root().getConvert().convertTo(create())); - Creator creator = Creator.create(TestEntry.class); //Creator.create(10, TestEntry.class); - TestEntry entry = creator.create(); - System.out.println(entry); - for(int i =0; i < 10000000; i++){ - creator.create(); - } - System.gc(); - Thread.sleep(2000) ; - System.out.println(creator.create()); - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - public int[] getAddrs() { - return addrs; - } - - public void setAddrs(int[] addrs) { - this.addrs = addrs; - } - - public List getLists() { - return lists; - } - - public void setLists(List lists) { - this.lists = lists; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public String[] getStrings() { - return strings; - } - - public void setStrings(String[] strings) { - this.strings = strings; - } - -} diff --git a/test/com/wentch/redkale/test/convert/TestEntry2.java b/test/com/wentch/redkale/test/convert/TestEntry2.java deleted file mode 100644 index a37090bdc..000000000 --- a/test/com/wentch/redkale/test/convert/TestEntry2.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.convert.*; -import java.util.*; - -/** - * - * @author zhangjx - */ -@ConvertEntity("myname") -public class TestEntry2 extends TestEntry { - - private String extend; - - public static TestEntry2 create() { - TestEntry2 v = new TestEntry2(); - v.setName("this is name\n \"test"); - v.setId(1000000001); - v.setAddrs(new int[]{22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999}); - v.setStrings(new String[]{"zzz","yyy","xxx"}); - List list = new ArrayList<>(); - list.add("aaaa"); - list.add("bbbb"); - list.add("cccc"); - v.setLists(list); - Map map = new HashMap<>(); - map.put("AAA", 111); - map.put("BBB", 222); - map.put("CCC", 333); - v.setMap(map); - v.setExtend("hahaha"); - return v; - } - - public String getExtend() { - return extend; - } - - public void setExtend(String extend) { - this.extend = extend; - } - -} diff --git a/test/com/wentch/redkale/test/convert/UserInfo.java b/test/com/wentch/redkale/test/convert/UserInfo.java deleted file mode 100644 index 6ffc3391a..000000000 --- a/test/com/wentch/redkale/test/convert/UserInfo.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -/** - * - * @author zhangjx - */ -public class UserInfo extends BasedEntity { - - private int userid; - - private String namekey; - - private String nickname; - - private String chname; - - private String password; - - private String mobile; - - private String email; - - private short type; - - private short status; - - private int gmt = 8; - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getNamekey() { - return namekey; - } - - public void setNamekey(String namekey) { - this.namekey = namekey; - } - - public String getNickname() { - return nickname; - } - - public void setNickname(String nickname) { - this.nickname = nickname; - } - - public String getChname() { - return chname; - } - - public void setChname(String chname) { - this.chname = chname; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public short getType() { - return type; - } - - public void setType(short type) { - this.type = type; - } - - public short getStatus() { - return status; - } - - public void setStatus(short status) { - this.status = status; - } - - public int getGmt() { - return gmt; - } - - public void setGmt(int gmt) { - this.gmt = gmt; - } - -} diff --git a/test/com/wentch/redkale/test/convert/UserMentorPrize.java b/test/com/wentch/redkale/test/convert/UserMentorPrize.java deleted file mode 100644 index 2e9a962fe..000000000 --- a/test/com/wentch/redkale/test/convert/UserMentorPrize.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.convert; - -import com.wentch.redkale.source.DistributeGenerator; -import javax.persistence.*; - -/** - * - * @author zhangjx - */ -public class UserMentorPrize extends BasedEntity implements Comparable { - - private static final long serialVersionUID = 1L; - - @Id - @DistributeGenerator(initialValue = 10001) - private long mentorprizeid; - - private int userid; - - private String prizename; - - private int happenday; - - @Column(updatable = false) - private long createtime = System.currentTimeMillis(); - - private long updatetime; - - public UserMentorPrize() { - } - - public long getMentorprizeid() { - return mentorprizeid; - } - - public void setMentorprizeid(long mentorprizeid) { - this.mentorprizeid = mentorprizeid; - } - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getPrizename() { - return prizename; - } - - public void setPrizename(String prizename) { - this.prizename = prizename; - } - - public int getHappenday() { - return happenday; - } - - public void setHappenday(int happenday) { - this.happenday = happenday; - } - - public long getCreatetime() { - return createtime; - } - - public void setCreatetime(long createtime) { - this.createtime = createtime; - } - - public long getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(long updatetime) { - this.updatetime = updatetime; - } - - @Override - public int compareTo(UserMentorPrize o) { - return this.happenday - o.happenday; - } -} diff --git a/test/com/wentch/redkale/test/net/UploadTestServlet.java b/test/com/wentch/redkale/test/net/UploadTestServlet.java deleted file mode 100644 index 645e39dc2..000000000 --- a/test/com/wentch/redkale/test/net/UploadTestServlet.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.net; - -import com.wentch.redkale.net.http.*; -import java.io.*; - -/** - * - * @author zhangjx - */ -//@WebServlet({"/uploadtest/form", "/uploadtest/send"}) -public class UploadTestServlet extends HttpServlet { - - @Override - public void execute(HttpRequest request, HttpResponse response) throws IOException { - if (request.getRequestURI().contains("/uploadtest/send")) { - send(request, response); - } else { - form(request, response); - } - } - - public void form(HttpRequest req, HttpResponse resp) throws IOException { - resp.setContentType("text/html"); - resp.finish( - "" - + "
" - + "描述:         文件1:

" - + "描述:         文件2:

" - + "描述:         文件3:

" - + "描述:         

" - + "              
" - + ""); - } - - public void send(HttpRequest req, HttpResponse resp) throws IOException { - MultiContext context = req.getMultiContext(); - for (MultiPart entry : context.listMultiPart()) { - entry.skip(); - System.out.println(entry); - } - System.exit(0); - } -} diff --git a/test/com/wentch/redkale/test/service/Person.java b/test/com/wentch/redkale/test/service/Person.java deleted file mode 100644 index c8791de9a..000000000 --- a/test/com/wentch/redkale/test/service/Person.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.wentch.redkale.test.service; - -import java.io.Serializable; - -public class Person implements Serializable { - - private byte[] b = new byte[1024 * 2]; - - private String name; - - @Override - public String toString() { - return "{name=" + name + ", b =" + (b == null ? "null" : "[length=" + b.length + "]") + "}"; - } - - public byte[] getB() { - return b; - } - - public void setB(byte[] b) { - this.b = b; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/test/com/wentch/redkale/test/service/TestBean.java b/test/com/wentch/redkale/test/service/TestBean.java deleted file mode 100644 index 86eb03140..000000000 --- a/test/com/wentch/redkale/test/service/TestBean.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.service; - -/** - * - * @author zhangjx - */ -public class TestBean { - -} diff --git a/test/com/wentch/redkale/test/sncp/SncpTest.java b/test/com/wentch/redkale/test/sncp/SncpTest.java deleted file mode 100644 index d6d692416..000000000 --- a/test/com/wentch/redkale/test/sncp/SncpTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.sncp; - -import com.wentch.redkale.boot.*; -import com.wentch.redkale.convert.bson.*; -import com.wentch.redkale.net.*; -import com.wentch.redkale.net.sncp.*; -import com.wentch.redkale.service.*; -import com.wentch.redkale.util.*; -import com.wentch.redkale.watch.*; -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import java.util.logging.*; - -/** - * - * @author zhangjx - */ -public class SncpTest { - - private static final String serviceName = ""; - - private static final String myhost = Utility.localInetAddress().getHostAddress(); - - private static final int port = 4040; - - private static final int port2 = 0; // 4240; - - public static void main(String[] args) throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - final PrintStream ps = new PrintStream(out); - ps.println("handlers = java.util.logging.ConsoleHandler"); - ps.println(".handlers = java.util.logging.ConsoleHandler"); - ps.println(".level = FINEST"); - ps.println("java.util.logging.ConsoleHandler.level = FINEST"); - LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(out.toByteArray())); - ResourceFactory.root().register("", BsonConvert.class, BsonFactory.root().getConvert()); - if (System.getProperty("client") == null) { - runServer(); - if (port2 > 0) runServer2(); - } - if (System.getProperty("server") == null) { - runClient(); - } - if (System.getProperty("server") != null) { - System.in.read(); - } - } - - private static void runClient() throws Exception { - InetSocketAddress addr = new InetSocketAddress(myhost, port); - Set set = new LinkedHashSet<>(); - set.add(addr); - if (port2 > 0) set.add(new InetSocketAddress(myhost, port2)); - final Transport transport = new Transport("", WatchFactory.root(), 50, set); - final SncpTestService service = Sncp.createRemoteService(serviceName, null, SncpTestService.class, null, new LinkedHashSet<>(), transport); - ResourceFactory.root().inject(service); - -// SncpTestBean bean = new SncpTestBean(); -// StringBuilder sb = new StringBuilder(); -// for (int i = 0; i < 2000; i++) { -// sb.append("_").append(i).append("_0123456789"); -// } -// bean.setContent(sb.toString()); -// bean.setContent("hello sncp"); - SncpTestBean callbean = new SncpTestBean(); - callbean.setId(1); - callbean.setContent("数据X"); - - service.insert(callbean); - System.out.println("bean.id应该会被修改: " + callbean); - System.out.println("---------------------------------------------------"); - final int count = 10; - final CountDownLatch cld = new CountDownLatch(count); - final AtomicInteger ai = new AtomicInteger(); - for (int i = 0; i < count; i++) { - final int k = i + 1; - new Thread() { - @Override - public void run() { - try { - Thread.sleep(k); - SncpTestBean bean = new SncpTestBean(); - bean.setId(k); - bean.setContent("数据: " + (k < 10 ? "0" : "") + k); - StringBuilder sb = new StringBuilder(); - sb.append(k).append("------"); - for (int i = 0; i < 1200; i++) { - sb.append("_").append(i).append("_").append(k).append("_0123456789"); - } - bean.setContent(sb.toString()); - - service.queryResult(bean); - //service.updateBean(bean); - } catch (Exception e) { - e.printStackTrace(); - } finally { - long a = ai.incrementAndGet(); - System.out.println("运行了 " + (a == 100 ? "--------------------------------------------------" : "") + a); - cld.countDown(); - } - } - }.start(); - } - cld.await(); - System.out.println("---全部运行完毕---"); - System.exit(0); - } - - private static void runServer() throws Exception { - InetSocketAddress addr = new InetSocketAddress(myhost, port); - final CountDownLatch cdl = new CountDownLatch(1); - new Thread() { - @Override - public void run() { - try { - SncpServer server = new SncpServer(); - Set set = new LinkedHashSet<>(); - if (port2 > 0) set.add(new InetSocketAddress(myhost, port2)); - Transport transport = new Transport("", WatchFactory.root(), 50, set); - List sameTransports = new ArrayList<>(); - if (port2 > 0) sameTransports.add(transport); - SncpTestService service = Sncp.createLocalService("", null, SncpTestService.class, addr, new LinkedHashSet<>(), sameTransports, null); - ResourceFactory.root().inject(service); - server.addService(new ServiceWrapper(SncpTestService.class, service, "", new ClassFilter.FilterEntry(SncpTestService.class, null))); - System.out.println(service); - AnyValue.DefaultAnyValue conf = new AnyValue.DefaultAnyValue(); - conf.addValue("host", "0.0.0.0"); - conf.addValue("port", "" + port); - server.init(conf); - server.start(); - cdl.countDown(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }.start(); - cdl.await(); - } - - private static void runServer2() throws Exception { - InetSocketAddress addr = new InetSocketAddress(myhost, port2); - final CountDownLatch cdl = new CountDownLatch(1); - new Thread() { - @Override - public void run() { - try { - SncpServer server = new SncpServer(); - Set set = new LinkedHashSet<>(); - set.add(new InetSocketAddress(myhost, port)); - Transport transport = new Transport("", WatchFactory.root(), 50, set); - List sameTransports = new ArrayList<>(); - sameTransports.add(transport); - Service service = Sncp.createLocalService("", null, SncpTestService.class, addr, new LinkedHashSet<>(), sameTransports, null); - server.addService(new ServiceWrapper(SncpTestService.class, service, "", new ClassFilter.FilterEntry(SncpTestService.class, null))); - AnyValue.DefaultAnyValue conf = new AnyValue.DefaultAnyValue(); - conf.addValue("host", "0.0.0.0"); - conf.addValue("port", "" + port2); - server.init(conf); - server.start(); - cdl.countDown(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }.start(); - cdl.await(); - } -} diff --git a/test/com/wentch/redkale/test/sncp/SncpTestBean.java b/test/com/wentch/redkale/test/sncp/SncpTestBean.java deleted file mode 100644 index 202fa9cca..000000000 --- a/test/com/wentch/redkale/test/sncp/SncpTestBean.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.sncp; - -import com.wentch.redkale.convert.bson.*; -import com.wentch.redkale.convert.json.*; -import com.wentch.redkale.source.*; -import com.wentch.redkale.util.*; -import javax.persistence.*; - -/** - * - * @author zhangjx - */ -public class SncpTestBean implements FilterBean { - - @Id - private long id; - - private String content; - - public static void main(String[] args) throws Exception { - SncpTestBean bean = JsonFactory.root().getConvert().convertFrom(SncpTestBean.class, "{\"content\":\"数据: 01\",\"id\":1}"); - System.out.println(bean); - byte[] bs = BsonFactory.root().getConvert().convertTo(bean); - Utility.println("---------", bs); - System.out.println(BsonFactory.root().getConvert().convertFrom(SncpTestBean.class, bs).toString()); - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - -} diff --git a/test/com/wentch/redkale/test/sncp/SncpTestService.java b/test/com/wentch/redkale/test/sncp/SncpTestService.java deleted file mode 100644 index 07c1dca5f..000000000 --- a/test/com/wentch/redkale/test/sncp/SncpTestService.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.sncp; - -import com.wentch.redkale.net.sncp.*; -import com.wentch.redkale.service.*; -import com.wentch.redkale.source.*; -import com.wentch.redkale.util.*; - -/** - * - * @author zhangjx - */ -public class SncpTestService implements Service { - - public static class CallAttribute implements Attribute { - - @Override - public Class type() { - return long.class; - } - - @Override - public Class declaringClass() { - return SncpTestBean.class; - } - - @Override - public String field() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Long get(SncpTestBean obj) { - System.out.println("返回ID: " + obj.getId()); - return obj.getId(); - } - - @Override - public void set(SncpTestBean obj, Long value) { - System.out.println("设置ID: " + value); - obj.setId(value); - } - - } - - public void insert(@SncpCall(DataCallArrayAttribute.class) SncpTestBean... beans) { - for (SncpTestBean bean : beans) { - bean.setId(System.currentTimeMillis()); - } - } - - public String queryResult(SncpTestBean bean) { - System.out.println(Thread.currentThread().getName() + " 运行了queryResult方法"); - return "result: " + bean; - } - - @MultiRun - public String updateBean(@SncpCall(CallAttribute.class) SncpTestBean bean) { - bean.setId(System.currentTimeMillis()); - System.out.println(Thread.currentThread().getName() + " 运行了updateBean方法"); - return "result: " + bean; - } - -} diff --git a/test/com/wentch/redkale/test/source/CacheTestBean.java b/test/com/wentch/redkale/test/source/CacheTestBean.java deleted file mode 100644 index 5ab4d7779..000000000 --- a/test/com/wentch/redkale/test/source/CacheTestBean.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.source; - -import com.wentch.redkale.source.*; -import com.wentch.redkale.source.DataSource.Reckon; -import com.wentch.redkale.util.*; -import java.util.*; -import javax.persistence.*; - -/** - * - * @author zhangjx - */ -public class CacheTestBean { - - @Id - private long pkgid; - - private String name; - - private long price; - - public static void main(String[] args) throws Exception { - final List list = new ArrayList<>(); - list.add(new CacheTestBean(1, "a", 12)); - list.add(new CacheTestBean(1, "a", 18)); - list.add(new CacheTestBean(2, "b", 20)); - list.add(new CacheTestBean(2, "bb", 60)); - Attribute idattr = Attribute.create(CacheTestBean.class, "pkgid"); - Attribute nameattr = Attribute.create(CacheTestBean.class, "name"); - Attribute priceattr = Attribute.create(CacheTestBean.class, "price"); - EntityCache cache = new EntityCache(EntityInfo.load(CacheTestBean.class, 0, true, null)); - cache.fullLoad(list); - - System.out.println(cache.getMapResult("pkgid", Reckon.COUNT, "name", null)); - System.out.println(cache.getMapResult("pkgid", Reckon.DISTINCTCOUNT, "name", null)); - System.out.println(cache.getMapResult("pkgid", Reckon.AVG, "price", null)); - System.out.println(cache.getMapResult("pkgid", Reckon.SUM, "price", null)); - System.out.println(cache.getMapResult("pkgid", Reckon.MAX, "price", null)); - System.out.println(cache.getMapResult("pkgid", Reckon.MIN, "price", null)); - } - - public CacheTestBean() { - } - - public CacheTestBean(long pkgid, String name, long price) { - this.pkgid = pkgid; - this.name = name; - this.price = price; - } - - public long getPkgid() { - return pkgid; - } - - public void setPkgid(long pkgid) { - this.pkgid = pkgid; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public long getPrice() { - return price; - } - - public void setPrice(long price) { - this.price = price; - } - -} diff --git a/test/com/wentch/redkale/test/source/JDBCTest.java b/test/com/wentch/redkale/test/source/JDBCTest.java deleted file mode 100644 index 4792fb17c..000000000 --- a/test/com/wentch/redkale/test/source/JDBCTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.source; - -import com.wentch.redkale.source.*; - -/** - * - * @author zhangjx - */ -public class JDBCTest { - - public static void main(String[] args) throws Exception { - System.setProperty("persist.type", "jdbc"); - DataSource source = new DataDefaultSource(); //耗时:37415 - int count = 1000; - LoginTestRecord last = null; - long s = System.currentTimeMillis(); - int c = 0; - try { - for (int i = 0; i < count; i++) { - LoginTestRecord record = new LoginTestRecord(); - record.setSessionid(Long.toHexString(System.nanoTime())); - record.setLoginagent("win7"); - record.setLogintime(System.currentTimeMillis()); - record.setLoginip("127.0.0.1"); - record.setUserid(i); - source.insert(record); - last = record; - c = i; - } - } catch (Exception e) { - System.out.println("异常了: " + c); - e.printStackTrace(); - } - long e = System.currentTimeMillis() - s; - System.out.println("耗时:" + e); - } -} diff --git a/test/com/wentch/redkale/test/source/LoginTestBean.java b/test/com/wentch/redkale/test/source/LoginTestBean.java deleted file mode 100644 index 4e6be6650..000000000 --- a/test/com/wentch/redkale/test/source/LoginTestBean.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.source; - -import com.wentch.redkale.source.FilterBean; - -/** - * - * @author zhangjx - */ -public class LoginTestBean implements FilterBean { - - private String sessionid; - - public String getSessionid() { - return sessionid; - } - - public void setSessionid(String sessionid) { - this.sessionid = sessionid; - } - -} diff --git a/test/com/wentch/redkale/test/source/LoginTestRecord.java b/test/com/wentch/redkale/test/source/LoginTestRecord.java deleted file mode 100644 index 8f73d0a92..000000000 --- a/test/com/wentch/redkale/test/source/LoginTestRecord.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.source; - -import com.wentch.redkale.convert.json.JsonFactory; -import javax.persistence.*; -import static javax.persistence.GenerationType.SEQUENCE; - -/** - * CREATE TABLE `LoginTestRecord` ( - * `sessionid` VARCHAR(64) NOT NULL COMMENT '登陆会话ID', - * `userid` INT(11) NOT NULL COMMENT '登陆用户ID', - * `loginagent` VARCHAR(128) NOT NULL COMMENT '登陆端信息', - * `loginip` VARCHAR(255) NOT NULL COMMENT '登陆IP', - * `logintime` BIGINT(20) NOT NULL COMMENT '登陆时间', - * `logouttime` BIGINT(20) NOT NULL COMMENT '注销时间', - * PRIMARY KEY (`sessionid`) - * ) ENGINE=INNODB DEFAULT CHARSET=utf8; - * - * @author zhangjx - */ -@Entity -public class LoginTestRecord { - - @Id - @GeneratedValue(strategy = SEQUENCE, generator = "SEQ") - //@SequenceGenerator(name = "SEQ", initialValue = 100001, allocationSize = 1000) - private String sessionid; - - private int userid; - - private String loginagent; - - private String loginip; - - private long logintime; - - private long logouttime; - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - - public String getSessionid() { - return sessionid; - } - - public void setSessionid(String sessionid) { - this.sessionid = sessionid; - } - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getLoginagent() { - return loginagent; - } - - public void setLoginagent(String loginagent) { - this.loginagent = loginagent; - } - - public String getLoginip() { - return loginip; - } - - public void setLoginip(String loginip) { - this.loginip = loginip; - } - - public long getLogintime() { - return logintime; - } - - public void setLogintime(long logintime) { - this.logintime = logintime; - } - - public long getLogouttime() { - return logouttime; - } - - public void setLogouttime(long logouttime) { - this.logouttime = logouttime; - } - -} diff --git a/test/com/wentch/redkale/test/source/TestSourceCache.java b/test/com/wentch/redkale/test/source/TestSourceCache.java deleted file mode 100644 index 967bb3f07..000000000 --- a/test/com/wentch/redkale/test/source/TestSourceCache.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.source; - -import com.wentch.redkale.convert.json.*; -import com.wentch.redkale.source.*; -import com.wentch.redkale.util.*; -import java.util.concurrent.*; -import javax.persistence.*; - -/** - * - * @author zhangjx - */ -public class TestSourceCache { - - public static class TestEntityBean implements FilterBean { - - @FilterColumn(express = FilterExpress.GREATERTHAN) - public int userid; - - @FilterColumn(express = FilterExpress.LIKE) - public String username; - - public TestEntityBean(int userid, String username) { - this.userid = userid; - this.username = username; - } - } - - public static void main(String[] args) throws Exception { - final EntityInfo info = EntityInfo.load(TestEntity.class, 0, false, null); - TestEntity[] entitys = new TestEntity[10_0000]; - for (int i = 0; i < entitys.length; i++) { - entitys[i] = new TestEntity(i + 1, "用户_" + (i + 1)); - } - long s = System.currentTimeMillis(); - for (TestEntity en : entitys) { - info.getCache().insert(en); - } - long e = System.currentTimeMillis() - s; - System.out.println("插入十万条记录耗时: " + e / 1000.0 + " 秒"); - - s = System.currentTimeMillis(); - TestEntity one = info.getCache().find(9999); - e = System.currentTimeMillis() - s; - System.out.println("十万条数据中查询一条记录耗时: " + e / 1000.0 + " 秒 " + one); - - final Flipper flipper = new Flipper(2); - flipper.setSort("userid DESC, createtime DESC"); - final FilterNode node = FilterNode.create("userid", FilterExpress.GREATERTHAN, 1000).and("username", FilterExpress.LIKE, "用户"); - System.out.println("node = " + node); - Sheet sheet = info.getCache().querySheet(null, flipper, node); - System.out.println(sheet); - System.out.println(info.getCache().querySheet(null, flipper, FilterNodeBean.createFilterNode(new TestEntityBean(1000, "用户")))); - final CountDownLatch cdl = new CountDownLatch(100); - s = System.currentTimeMillis(); - for (int i = 0; i < 100; i++) { - new Thread() { - @Override - public void run() { - for (int k = 0; k < 10; k++) { - info.getCache().querySheet(true, null, flipper, node); - } - cdl.countDown(); - } - }.start(); - } - cdl.await(); - e = System.currentTimeMillis() - s; - System.out.println("十万条数据中查询一页记录耗时: " + e / 1000.0 + " 秒 " + sheet); // CopyOnWriteArrayList 0.798 ConcurrentLinkedQueue 1.063 - } - - @VirtualEntity - @Cacheable - public static class TestEntity { - - @Id - private int userid; - - private String username; - - private long createtime = System.currentTimeMillis(); - - public TestEntity() { - - } - - public TestEntity(int userid, String username) { - this.userid = userid; - this.username = username; - } - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public long getCreatetime() { - return createtime; - } - - public void setCreatetime(long createtime) { - this.createtime = createtime; - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - } -} diff --git a/test/com/wentch/redkale/test/util/TestABean.java b/test/com/wentch/redkale/test/util/TestABean.java deleted file mode 100644 index bef27cb75..000000000 --- a/test/com/wentch/redkale/test/util/TestABean.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.util; - -/** - * - * @author zhangjx - */ -public class TestABean { - public long time; -} diff --git a/test/com/wentch/redkale/test/util/TestBean.java b/test/com/wentch/redkale/test/util/TestBean.java deleted file mode 100644 index 7467bb1c0..000000000 --- a/test/com/wentch/redkale/test/util/TestBean.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.util; - -import java.util.Map; - -/** - * - * @author zhangjx - */ -public class TestBean extends TestABean { - - private String name; - - private int id; - - private Map map; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } - -} diff --git a/test/com/wentch/redkale/test/util/TestXBean.java b/test/com/wentch/redkale/test/util/TestXBean.java deleted file mode 100644 index 87dcd87c2..000000000 --- a/test/com/wentch/redkale/test/util/TestXBean.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package com.wentch.redkale.test.util; - -/** - * - * @author zhangjx - */ -public class TestXBean extends TestBean{ - -} diff --git a/test/com/wentch/redkale/test/util/UntilTestMain.java b/test/com/wentch/redkale/test/util/UntilTestMain.java deleted file mode 100644 index 690e689c1..000000000 --- a/test/com/wentch/redkale/test/util/UntilTestMain.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.util; - -import com.wentch.redkale.util.Reproduce; -import com.wentch.redkale.util.Attribute; - -/** - * - * @author zhangjx - */ -public class UntilTestMain { - - public static void main(String[] args) throws Throwable { - reproduce(args); - attribute(args); - } - - public static void reproduce(String[] args) throws Throwable { - final TestBean bean = new TestBean(); - bean.setId(123456); - bean.setName("zhangjx"); - bean.time = 2000; - final TestXBean beanx = new TestXBean(); - Reproduce action1 = Reproduce.create(TestXBean.class, TestBean.class); - Reproduce action2 = new Reproduce() { - - @Override - public TestXBean copy(TestXBean dest, TestBean src) { - dest.time = src.time; - dest.setId(src.getId()); - dest.setName(src.getName()); - dest.setMap(src.getMap()); - return dest; - } - }; - final int count = 1_000_000; - long s = System.nanoTime(); - for (int i = 0; i < count; i++) { - action2.copy(beanx, bean); - } - long e = System.nanoTime() - s; - System.out.println("静态Reproduce耗时: " + e); - s = System.nanoTime(); - for (int i = 0; i < count; i++) { - action1.copy(beanx, bean); - } - e = System.nanoTime() - s; - System.out.println("动态Reproduce耗时: " + e); - System.out.println(); - } - - public static void attribute(String[] args) throws Throwable { - final TestBean bean = new TestBean(); - bean.setId(123456); - bean.setName("zhangjx"); - Attribute action1 = Attribute.create(TestBean.class.getDeclaredField("name")); - Attribute action2 = new Attribute() { - - @Override - public String field() { - return "name"; - } - - @Override - public String get(TestBean obj) { - return obj.getName(); - } - - @Override - public void set(TestBean obj, String value) { - obj.setName(value); - } - - @Override - public Class type() { - return String.class; - } - - @Override - public Class declaringClass() { - return TestBean.class; - } - }; - final int count = 1_000_000; - long s = System.nanoTime(); - for (int i = 0; i < count; i++) { - action2.set(bean, "zhangjx2"); - } - long e = System.nanoTime() - s; - System.out.println("静态Attribute耗时: " + e); - s = System.nanoTime(); - for (int i = 0; i < count; i++) { - action1.set(bean, "zhangjx2"); - } - e = System.nanoTime() - s; - System.out.println("动态Attribute耗时: " + e); - System.out.println(); - } -} diff --git a/test/com/wentch/redkale/test/websocket/ChatWebSocketServlet.java b/test/com/wentch/redkale/test/websocket/ChatWebSocketServlet.java deleted file mode 100644 index ca5905b92..000000000 --- a/test/com/wentch/redkale/test/websocket/ChatWebSocketServlet.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.websocket; - -import com.wentch.redkale.net.http.WebServlet; -import com.wentch.redkale.net.http.WebSocketServlet; -import com.wentch.redkale.net.http.WebSocket; -import java.io.*; -import static java.lang.Thread.sleep; -import java.text.*; -import java.util.concurrent.atomic.*; - -/** - * - * @author zhangjx - */ -@WebServlet("/ws/chat") -public class ChatWebSocketServlet extends WebSocketServlet { - - private final AtomicLong counter = new AtomicLong(); - - private final AtomicLong icounter = new AtomicLong(); - - private final boolean debug; - - public ChatWebSocketServlet() { - debug = "true".equalsIgnoreCase(System.getProperty("debug", "false")); - Thread t = new Thread() { - - private final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - { - setName("Debug-ChatWebSocket-ShowCount-Thread"); - } - - @Override - public void run() { - while (true) { - try { - sleep(60 * 1000); - } catch (Exception e) { - return; - } - System.out.println(format.format(new java.util.Date()) + ": 消息总数: " + counter.get() + ",间隔消息数: " + icounter.getAndSet(0)); - } - } - }; - t.start(); - } - - @Override - protected WebSocket createWebSocket() { - - return new WebSocket() { - - @Override - public void onMessage(String text) { - icounter.incrementAndGet(); - counter.incrementAndGet(); - if (debug) System.out.println("收到消息: " + text); - super.getWebSocketGroup().getWebSockets().forEach(x -> x.send(text)); - } - - @Override - protected Serializable createGroupid() { - return ""; - } - }; - } - -} diff --git a/test/com/wentch/redkale/test/websocket/Flash843.java b/test/com/wentch/redkale/test/websocket/Flash843.java deleted file mode 100644 index 77ea2c40e..000000000 --- a/test/com/wentch/redkale/test/websocket/Flash843.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.websocket; - -import java.io.ByteArrayOutputStream; -import java.net.Socket; - -/** - * - * @author zhangjx - */ -public class Flash843 { - - public static void main(String[] args) throws Exception { - Socket socket = new Socket("113.105.88.229", 843); - socket.getOutputStream().write("".getBytes()); - socket.getOutputStream().flush(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] bytes = new byte[1024]; - int pos; - while ((pos = socket.getInputStream().read(bytes)) != -1) { - out.write(bytes, 0, pos); - } - System.out.println(out.toString()); - } -} diff --git a/test/com/wentch/redkale/test/websocket/VideoWebSocketServlet.java b/test/com/wentch/redkale/test/websocket/VideoWebSocketServlet.java deleted file mode 100644 index 3fdf506cd..000000000 --- a/test/com/wentch/redkale/test/websocket/VideoWebSocketServlet.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.test.websocket; - -import com.wentch.redkale.net.http.WebServlet; -import com.wentch.redkale.net.http.WebSocketServlet; -import com.wentch.redkale.net.http.HttpRequest; -import com.wentch.redkale.net.http.WebSocket; -import com.wentch.redkale.net.http.HttpServer; -import com.wentch.redkale.util.TypeToken; -import com.wentch.redkale.util.AnyValue; -import java.io.*; -import java.util.*; -import java.util.concurrent.CountDownLatch; - -/** - * - * @author zhangjx - */ -@WebServlet({"/ws/listen"}) -public class VideoWebSocketServlet extends WebSocketServlet { - - private final Map sessions = new java.util.concurrent.ConcurrentHashMap<>(); - - private final Map users = new HashMap<>(); - - private static final class Entry { - - public WebSocket socket; - - public String username; - - public Serializable userid; - - } - - public VideoWebSocketServlet() { - super(); - users.put("zhangjx", "xxxx"); - } - - @Override - protected WebSocket createWebSocket() { - WebSocket socket = new WebSocket() { - - private final TypeToken> mapToken = new TypeToken>() { - }; - - private boolean repeat = false; - - @Override - public String onOpen(final HttpRequest request) { - String uri = request.getRequestURI(); - int pos = uri.indexOf("/listen/"); - uri = uri.substring(pos + "/listen/".length()); - this.repeat = sessions.get(uri) != null; - if (!this.repeat) this.repeat = users.get(uri) == null; - String sessionid = Long.toString(System.nanoTime()); - if (uri.indexOf('\'') >= 0 || uri.indexOf('"') >= 0) return null; - if (!repeat) sessionid = uri; - return sessionid; - } - - @Override - public void onConnected() { - if (repeat) { - super.close(); - } else { - Entry entry = new Entry(); - entry.userid = this.getSessionid(); - entry.username = users.get(entry.userid); - sessions.put(this.getSessionid(), entry); - StringBuilder sb = new StringBuilder(); - for (Map.Entry en : sessions.entrySet()) { - if (sb.length() > 0) sb.append(','); - sb.append("{'userid':'").append(en.getKey()).append("','username':'").append(en.getValue().username).append("'}"); - } - super.send(("{'type':'user_list','users':[" + sb + "]}").replace('\'', '"')); - String msg = ("{'type':'discover_user','user':{'userid':'" + this.getSessionid() + "','username':'" + users.get(this.getSessionid()) + "'}}").replace('\'', '"'); - super.getWebSocketGroup().getWebSockets().filter(x -> x != this).forEach(x -> { - x.send(msg); - }); - } - } - - @Override - public void onMessage(String text) { - //System.out.println("接收到消息: " + text); - super.getWebSocketGroup().getWebSockets().filter(x -> x != this).forEach(x -> { - x.send(text); - }); - } - - @Override - public void onClose(int code, String reason) { - sessions.remove(this.getSessionid()); - String msg = ("{'type':'remove_user','user':{'userid':'" + this.getSessionid() + "','username':'" + users.get(this.getSessionid()) + "'}}").replace('\'', '"'); - super.getWebSocketGroup().getWebSockets().filter(x -> x != this).forEach(x -> { - x.send(msg); - }); - } - - @Override - protected Serializable createGroupid() { - return ""; - } - }; - return socket; - } - - public static void main(String[] args) throws Throwable { - CountDownLatch cdl = new CountDownLatch(1); - AnyValue.DefaultAnyValue config = new AnyValue.DefaultAnyValue(); - config.addValue("threads", System.getProperty("threads")); - config.addValue("bufferPoolSize", System.getProperty("bufferPoolSize")); - config.addValue("responsePoolSize", System.getProperty("responsePoolSize")); - config.addValue("host", System.getProperty("host", "0.0.0.0")); - config.addValue("port", System.getProperty("port", "8070")); - config.addValue("root", System.getProperty("root", "./root3/")); - AnyValue.DefaultAnyValue resConf = new AnyValue.DefaultAnyValue(); - resConf.setValue("cacheMaxLength", "200M"); - resConf.setValue("cacheMaxItemLength", "10M"); - config.setValue("ResourceServlet", resConf); - HttpServer server = new HttpServer(); - server.addHttpServlet(new VideoWebSocketServlet(), null, "/pipes/listen/*"); - server.init(config); - server.start(); - cdl.await(); - } - -}