From b6d6f9d8534470188661e79a5e102f435a2f9998 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sat, 23 Jan 2021 20:52:54 +0800 Subject: [PATCH] delete unused code in sample-bootstrap, simplify the demo --- sample-bootstrap/README.md | 1 - sample-bootstrap/README_CN.md | 1 - sample-bootstrap/pom.xml | 64 ------------------- .../bootstrap/config/WebSocketConfig.java | 20 ------ .../controller/WebSocketEndpoint.java | 46 ------------- .../src/main/resources/sureness.yml | 2 +- .../controller/WebSocketEndpointTest.java | 28 -------- 7 files changed, 1 insertion(+), 161 deletions(-) delete mode 100644 sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/config/WebSocketConfig.java delete mode 100644 sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpoint.java delete mode 100644 sample-bootstrap/src/test/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpointTest.java diff --git a/sample-bootstrap/README.md b/sample-bootstrap/README.md index 265ef87..f94da0e 100644 --- a/sample-bootstrap/README.md +++ b/sample-bootstrap/README.md @@ -8,6 +8,5 @@ - load data from default dataSource - `sureness.yml` - use default sureness config - use default `jwt auth, basic auth, digest auth` to authenticate and authorize -- contain `restful api,websocket` - project's protected entrance is `SurenessFilterExample` - suggest use postman to test, test case is in `sample-bootstrap-postman.json`, user can load it in postman diff --git a/sample-bootstrap/README_CN.md b/sample-bootstrap/README_CN.md index adb8633..64c4a2c 100644 --- a/sample-bootstrap/README_CN.md +++ b/sample-bootstrap/README_CN.md @@ -8,6 +8,5 @@ sureness 10分钟例子项目 - 从默认的配置文件`sureness.yml`加载账户信息,资源角色,过滤资源等信息 - 使用默认的`sureness-config` - 使用默认的`jwt auth,basic auth,digest auth`方式认证鉴权 -- 例子中包含`restful api,websocket` - 保护入口: `SurenessFilterExample` - 推荐使用`postman`测试,测试样例为`sample-bootstrap-postman.json`,导入`postman`即可 diff --git a/sample-bootstrap/pom.xml b/sample-bootstrap/pom.xml index 6510b06..12d285d 100644 --- a/sample-bootstrap/pom.xml +++ b/sample-bootstrap/pom.xml @@ -23,36 +23,16 @@ org.springframework.boot spring-boot-starter-web - - org.springframework.boot - spring-boot-starter-websocket - org.springframework.boot spring-boot-configuration-processor true - com.usthe.sureness sureness-core - - - org.projectlombok - lombok - 1.18.6 - provided - - - - - javax.xml.bind - jaxb-api - 2.3.0 - - org.springframework.boot @@ -76,50 +56,6 @@ - - - org.apache.maven.plugins - maven-pmd-plugin - 3.8 - - - rulesets/java/ali-comment.xml - rulesets/java/ali-concurrent.xml - rulesets/java/ali-constant.xml - rulesets/java/ali-exception.xml - rulesets/java/ali-flowcontrol.xml - rulesets/java/ali-naming.xml - rulesets/java/ali-oop.xml - rulesets/java/ali-orm.xml - rulesets/java/ali-other.xml - rulesets/java/ali-set.xml - - true - false - - - - validate - validate - - check - - - - - - com.alibaba.p3c - p3c-pmd - 1.3.0 - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.0 - diff --git a/sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/config/WebSocketConfig.java b/sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/config/WebSocketConfig.java deleted file mode 100644 index 80fdfd6..0000000 --- a/sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/config/WebSocketConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.usthe.sureness.sample.bootstrap.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.server.standard.ServerEndpointExporter; - -/** - * webSocket endpoint config - * @author tomsun28 - * @date 22:52 2019-05-26 - */ -@Configuration -public class WebSocketConfig { - - @Bean - public ServerEndpointExporter serverEndpointExporter() { - return new ServerEndpointExporter(); - } - -} diff --git a/sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpoint.java b/sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpoint.java deleted file mode 100644 index 61a40c1..0000000 --- a/sample-bootstrap/src/main/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpoint.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.usthe.sureness.sample.bootstrap.controller; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.server.ServerEndpoint; - -/** - * websocket simulate api, for testing websocket - * @author tomsun28 - * @date 22:21 2019-05-26 - */ -@Component -@ServerEndpoint(value = "/webSocket/demo") -public class WebSocketEndpoint { - - private static final Logger logger = LoggerFactory.getLogger(WebSocketEndpoint.class); - - @OnOpen - public void onOpen(Session session) { - logger.info("webSocket: /webSocket/demo onOpen, session is : {} ", session); - } - - @OnMessage - public void onMessage(String message, Session session) { - logger.info("webSocket: /webSocket/demo receive message: {}, the session is : {} ", - message, session); - } - - @OnClose - public void onClose() { - logger.info("webSocket: /webSocket/demo on Close"); - } - - @OnError - public void onError(Session session, Throwable error) { - logger.error("webSocket: /webSocket/demo on Error, the session is {} ", - session, error); - } -} diff --git a/sample-bootstrap/src/main/resources/sureness.yml b/sample-bootstrap/src/main/resources/sureness.yml index bb3909d..1a29c18 100644 --- a/sample-bootstrap/src/main/resources/sureness.yml +++ b/sample-bootstrap/src/main/resources/sureness.yml @@ -1,4 +1,4 @@ -## -- sureness.yml txt dataSource-- ## +## -- sureness.yml document dataSource-- ## # load api resource which need be protected, config role who can access these resource. # resources that are not configured are also authenticated and protected by default, but not authorized diff --git a/sample-bootstrap/src/test/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpointTest.java b/sample-bootstrap/src/test/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpointTest.java deleted file mode 100644 index 446d436..0000000 --- a/sample-bootstrap/src/test/java/com/usthe/sureness/sample/bootstrap/controller/WebSocketEndpointTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.usthe.sureness.sample.bootstrap.controller; - -import org.junit.Test; - - -/** - * @author tomsun28 - * @date 23:01 2019-05-26 - */ -public class WebSocketEndpointTest { - - @Test - public void onOpen() { - } - - @Test - public void onMessage() { - } - - @Test - public void onClose() { - } - - @Test - public void onError() { - } - -} \ No newline at end of file -- GitLab