{
+
+ 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
new file mode 100644
index 000000000..645e39dc2
--- /dev/null
+++ b/test/com/wentch/redkale/test/net/UploadTestServlet.java
@@ -0,0 +1,48 @@
+/*
+ * 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(
+ ""
+ + ""
+ + "");
+ }
+
+ 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/IMService.java b/test/com/wentch/redkale/test/service/IMService.java
new file mode 100644
index 000000000..92a04e289
--- /dev/null
+++ b/test/com/wentch/redkale/test/service/IMService.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+import com.wentch.redkale.service.Service;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class IMService implements Service {
+
+ @Override
+ public String toString() {
+ return "[" + this.getClass().getSimpleName() + "]";
+ }
+
+ public void send(String text) {
+ onSend(text);
+ }
+
+ public void onSend(String text) {
+ System.out.println("接收到消息: " + text);
+ }
+}
diff --git a/test/com/wentch/redkale/test/service/IMServlet.java b/test/com/wentch/redkale/test/service/IMServlet.java
new file mode 100644
index 000000000..b4a05bf58
--- /dev/null
+++ b/test/com/wentch/redkale/test/service/IMServlet.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+import com.wentch.redkale.net.http.WebSocketServlet;
+import com.wentch.redkale.net.http.WebSocket;
+import java.util.Map;
+import javax.annotation.Resource;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class IMServlet extends WebSocketServlet {
+
+ @Resource(name = "^IMNODE.+$")
+ private Map nodemaps;
+
+ @Override
+ protected WebSocket createWebSocket() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+}
diff --git a/test/com/wentch/redkale/test/service/Person.java b/test/com/wentch/redkale/test/service/Person.java
new file mode 100644
index 000000000..c8791de9a
--- /dev/null
+++ b/test/com/wentch/redkale/test/service/Person.java
@@ -0,0 +1,32 @@
+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
new file mode 100644
index 000000000..86eb03140
--- /dev/null
+++ b/test/com/wentch/redkale/test/service/TestBean.java
@@ -0,0 +1,14 @@
+/*
+ * 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
new file mode 100644
index 000000000..a6c244d65
--- /dev/null
+++ b/test/com/wentch/redkale/test/sncp/SncpTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.net.*;
+import com.wentch.redkale.net.sncp.*;
+import com.wentch.redkale.util.*;
+import com.wentch.redkale.watch.*;
+import java.net.*;
+import java.util.concurrent.*;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class SncpTest {
+
+ private static final String serviceName = "";
+
+ private static final int port = 7070;
+
+ public static void main(String[] args) throws Exception {
+
+ runServer();
+ runClient();
+ }
+
+ private static void runClient() throws Exception {
+ ResourceFactory.root().register("", BsonConvert.class, BsonFactory.root().getConvert());
+ Transport transport = new Transport("testsncp", "UDP", WatchFactory.root(), 100, new InetSocketAddress("127.0.0.1", port));
+ ResourceFactory.root().register("testsncp", Transport.class, transport);
+ SncpTestService service = Sncp.createRemoteService(serviceName, SncpTestService.class, "testsncp");
+ 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());
+ System.out.println(service.queryResult(bean));
+ }
+
+ private static void runServer() throws Exception {
+ final CountDownLatch cdl = new CountDownLatch(1);
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ SncpServer server = new SncpServer();
+ server.addService(new ServiceEntry(SncpTestService.class, new SncpTestService(), null, serviceName));
+ 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();
+ }
+}
diff --git a/test/com/wentch/redkale/test/sncp/SncpTestBean.java b/test/com/wentch/redkale/test/sncp/SncpTestBean.java
new file mode 100644
index 000000000..d8348dbc7
--- /dev/null
+++ b/test/com/wentch/redkale/test/sncp/SncpTestBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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.json.*;
+import com.wentch.redkale.source.*;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class SncpTestBean implements FilterBean {
+
+ private long id;
+
+ private String content;
+
+ @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
new file mode 100644
index 000000000..ba1d591b4
--- /dev/null
+++ b/test/com/wentch/redkale/test/sncp/SncpTestService.java
@@ -0,0 +1,20 @@
+/*
+ * 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.service.*;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class SncpTestService implements Service {
+
+ public String queryResult(SncpTestBean bean) {
+ System.out.println("运行了方法");
+ return "result: " + bean;
+ }
+}
diff --git a/test/com/wentch/redkale/test/source/CacheTestBean.java b/test/com/wentch/redkale/test/source/CacheTestBean.java
new file mode 100644
index 000000000..6ba131166
--- /dev/null
+++ b/test/com/wentch/redkale/test/source/CacheTestBean.java
@@ -0,0 +1,78 @@
+/*
+ * 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.*;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class CacheTestBean {
+
+ 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(CacheTestBean.class, Creator.create(CacheTestBean.class), idattr, null);
+ cache.fullLoad(list);
+
+ System.out.println(cache.getMapResult(idattr, Reckon.COUNT, nameattr, null));
+ System.out.println(cache.getMapResult(idattr, Reckon.DISTINCTCOUNT, nameattr, null));
+ System.out.println(cache.getMapResult(idattr, Reckon.AVG, priceattr, null));
+ System.out.println(cache.getMapResult(idattr, Reckon.SUM, priceattr, null));
+ System.out.println(cache.getMapResult(idattr, Reckon.MAX, priceattr, null));
+ System.out.println(cache.getMapResult(idattr, Reckon.MIN, priceattr, 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
new file mode 100644
index 000000000..b843faa7b
--- /dev/null
+++ b/test/com/wentch/redkale/test/source/JDBCTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.DataSource;
+import com.wentch.redkale.source.DataSourceFactory;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class JDBCTest {
+
+ public static void main(String[] args) throws Exception {
+ System.setProperty("persist.type", "jdbc");
+ DataSource source = DataSourceFactory.create(); //耗时: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
new file mode 100644
index 000000000..4e6be6650
--- /dev/null
+++ b/test/com/wentch/redkale/test/source/LoginTestBean.java
@@ -0,0 +1,26 @@
+/*
+ * 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
new file mode 100644
index 000000000..8f73d0a92
--- /dev/null
+++ b/test/com/wentch/redkale/test/source/LoginTestRecord.java
@@ -0,0 +1,96 @@
+/*
+ * 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/util/Test.java b/test/com/wentch/redkale/test/util/Test.java
new file mode 100644
index 000000000..22430bcf2
--- /dev/null
+++ b/test/com/wentch/redkale/test/util/Test.java
@@ -0,0 +1,38 @@
+/*
+ * 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.*;
+
+/**
+ *
+ * @author zhangjx
+ */
+public class Test {
+
+ public static void main(String args[]) {
+ List list = new ArrayList();
+ test1(list);
+ System.out.println(list.size()); // 1处
+ test2(list);
+ System.out.println(list.size()); // 2处
+ test3(list);
+ System.out.println(list.size()); // 3处
+ }
+
+ public static void test1(List list) {
+ list = null;
+ }
+
+ public static void test2(List list) {
+ list.add("3wyc");
+ }
+
+ public static void test3(List list) {
+ list.add(new StringBuilder("3wyc"));
+ }
+
+}
diff --git a/test/com/wentch/redkale/test/util/TestBean.java b/test/com/wentch/redkale/test/util/TestBean.java
new file mode 100644
index 000000000..0965718fc
--- /dev/null
+++ b/test/com/wentch/redkale/test/util/TestBean.java
@@ -0,0 +1,46 @@
+/*
+ * 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 {
+
+ 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
new file mode 100644
index 000000000..87dcd87c2
--- /dev/null
+++ b/test/com/wentch/redkale/test/util/TestXBean.java
@@ -0,0 +1,15 @@
+/*
+ * 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
new file mode 100644
index 000000000..82045ee04
--- /dev/null
+++ b/test/com/wentch/redkale/test/util/UntilTestMain.java
@@ -0,0 +1,101 @@
+/*
+ * 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");
+ 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.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
new file mode 100644
index 000000000..735bfabd9
--- /dev/null
+++ b/test/com/wentch/redkale/test/websocket/ChatWebSocketServlet.java
@@ -0,0 +1,68 @@
+/*
+ * 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 static java.lang.Thread.sleep;
+import java.text.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ *
+ * @author zhangjx
+ */
+@WebServlet("/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));
+ }
+ };
+ }
+
+}
diff --git a/test/com/wentch/redkale/test/websocket/Flash843.java b/test/com/wentch/redkale/test/websocket/Flash843.java
new file mode 100644
index 000000000..77ea2c40e
--- /dev/null
+++ b/test/com/wentch/redkale/test/websocket/Flash843.java
@@ -0,0 +1,29 @@
+/*
+ * 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
new file mode 100644
index 000000000..7e54a0de6
--- /dev/null
+++ b/test/com/wentch/redkale/test/websocket/VideoWebSocketServlet.java
@@ -0,0 +1,128 @@
+/*
+ * 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.util.*;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ *
+ * @author zhangjx
+ */
+@WebServlet({"/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 String userid;
+
+ }
+
+ public VideoWebSocketServlet() {
+ super();
+ users.put("zhangjx", "xxxx");
+ }
+
+ @Override
+ protected WebSocket createWebSocket() {
+ WebSocket socket = new WebSocket() {
+
+ private final TypeToken