From b6bbb6d5e0cd0f69d77c142351e9fb6655b75250 Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Wed, 12 Feb 2020 10:31:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8D=95=E5=9C=BA=E6=99=AF=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=B6=E5=8F=AF=E8=87=AA=E5=AE=9A=E4=B9=89=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8A=A5=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/action/AutoTestAction.java | 32 +++++++++++++------ .../resource/advanced/chooseMessageScene.js | 24 ++++++++++++-- .../webapp/resource/message/messageScene.js | 25 +++++++++++++-- src/main/webapp/resource/message/setScene.js | 25 ++++++++++++++- .../resource/template/messageScene-test.htm | 2 +- update.md | 6 ++++ 6 files changed, 98 insertions(+), 16 deletions(-) diff --git a/src/main/java/yi/master/business/message/action/AutoTestAction.java b/src/main/java/yi/master/business/message/action/AutoTestAction.java index f9d2742..5c3f69f 100644 --- a/src/main/java/yi/master/business/message/action/AutoTestAction.java +++ b/src/main/java/yi/master/business/message/action/AutoTestAction.java @@ -95,6 +95,11 @@ public class AutoTestAction extends ActionSupport implements ModelDriven - 执行测试 + 执行测试 自定义数据 diff --git a/update.md b/update.md index fe0dbf4..b106358 100644 --- a/update.md +++ b/update.md @@ -1,3 +1,9 @@ +### v1.0.3 +#### 2020.2.5 +- 更新:单个场景调试时可自定义报文内容; +- 更新: + + ### v1.0.2 #### 2020.1.2 - 新增:全局变量 -> 数据库取值,可通过SQL语句从数据库获取指定变量; -- Gitee From 3b7a84c5ef697077f99e0669bc3b914f8702b4f3 Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Wed, 12 Feb 2020 11:19:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AHTTP=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=97=B6=E8=BF=94=E5=9B=9E302=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E6=B5=8B=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/protocol/HTTPTestClient.java | 28 +++++++++++++++++-- update.md | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/yi/master/coretest/message/protocol/HTTPTestClient.java b/src/main/java/yi/master/coretest/message/protocol/HTTPTestClient.java index c2ade8c..9a99d6a 100644 --- a/src/main/java/yi/master/coretest/message/protocol/HTTPTestClient.java +++ b/src/main/java/yi/master/coretest/message/protocol/HTTPTestClient.java @@ -262,7 +262,29 @@ public class HTTPTestClient extends TestClient { if (!requestSuccessFlag) { returnMap.addMark("超过最大请求重试次数:" + config.getRetryCount() + ", 测试终止。"); } - + + //处理302状态无返回的问题 + if (returnInfo != null) { + response = (HttpResponse) returnInfo[0]; + if (response != null && 302 == response.getStatusLine().getStatusCode()) { + returnInfo = null; + //302状态的时候重新请求一次新的地址 + Header header = response.getFirstHeader("location"); + + returnMap.addMark("检测到状态码为302,使用重定向地址[" + header.getValue() + "]重新请求一次"); + try { + if (HttpMethod.GET.name().equalsIgnoreCase(method)) { + returnInfo = doGet(header.getValue(), headers, querys, requestMessage, client); + } else { + returnInfo = doPost(method, header.getValue(), headers, querys, requestMessage, encType, client); + } + } catch (Exception e) { + returnMap.addMark("使用重定向地址请求失败:"); + returnMap.addMark(e.getMessage()); + } + } + } + if (returnInfo != null) { response = (HttpResponse) returnInfo[0]; useTime = (long) returnInfo[1]; @@ -272,8 +294,8 @@ public class HTTPTestClient extends TestClient { JSONObject headersObject = new JSONObject(); headersObject.put("RequestHeader", new JSONObject()); headersObject.put("ResponseHeader", new JSONObject()); - - if (response != null) { + + if (response != null) { StringBuilder returnMsg = new StringBuilder(); //获取所有头信息 parseHeaders(headersObject.getJSONObject("ResponseHeader"), response.getAllHeaders()); diff --git a/update.md b/update.md index b106358..380b9a1 100644 --- a/update.md +++ b/update.md @@ -1,7 +1,7 @@ ### v1.0.3 #### 2020.2.5 - 更新:单个场景调试时可自定义报文内容; -- 更新: +- 修复:HTTP请求时返回302状态时报错的问题;(未测试) ### v1.0.2 -- Gitee From f77141cee5cdb45c90f8b62540e135a54806c278 Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Thu, 13 Feb 2020 10:04:58 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=9B=86=E6=88=90swaager4j=EF=BC=88?= =?UTF-8?q?=E7=94=B1=E4=BA=8E=E4=BF=AE=E6=94=B9=E4=BA=86=E9=83=A8=E5=88=86?= =?UTF-8?q?jar=E5=8C=85=E7=89=88=E6=9C=AC=EF=BC=8C=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E5=AF=B9=E5=85=B6=E4=BB=96=E5=8A=9F=E8=83=BD=E9=80=A0?= =?UTF-8?q?=E6=88=90=E5=BD=B1=E5=93=8D=EF=BC=8C=E6=B2=A1=E6=9C=89=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 9 ++++++++- .../yi/master/business/user/action/UserAction.java | 10 ++++++++++ src/main/resources/swagger.properties | 9 +++++++++ src/main/webapp/WEB-INF/web.xml | 9 +++++++++ update.md | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/swagger.properties diff --git a/pom.xml b/pom.xml index fe807ca..0363024 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ org.freemarker freemarker - 2.3.19 + 2.3.23 org.hibernate @@ -458,7 +458,14 @@ 3.6 + + + com.cpjit + swagger4j + 2.2.1 + + org.jsoup jsoup diff --git a/src/main/java/yi/master/business/user/action/UserAction.java b/src/main/java/yi/master/business/user/action/UserAction.java index 81ac651..c1ec51d 100644 --- a/src/main/java/yi/master/business/user/action/UserAction.java +++ b/src/main/java/yi/master/business/user/action/UserAction.java @@ -2,6 +2,9 @@ package yi.master.business.user.action; import cn.hutool.captcha.CaptchaUtil; import cn.hutool.captcha.LineCaptcha; +import com.cpjit.swagger4j.annotation.API; +import com.cpjit.swagger4j.annotation.APIs; +import com.cpjit.swagger4j.annotation.Param; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts2.dispatcher.SessionMap; @@ -34,6 +37,7 @@ import java.util.List; @Controller @Scope("prototype") +@APIs public class UserAction extends BaseAction{ private static final long serialVersionUID = 1L; @@ -73,6 +77,12 @@ public class UserAction extends BaseAction{ * @return * @throws NoSuchAlgorithmException */ + @API(value = "user-toLogin", summary = "用户登录", parameters = { + @Param(name = "username", description = "用户名", required = true, type = "string"), + @Param(name = "password", description = "密码", required = true, type = "string"), + @Param(name = "verifyCode", description = "验证码", required = true,type= "string"), + @Param(name = "loginIdentification", description = "登录标识",type= "string") + }) public String toLogin() throws NoSuchAlgorithmException { boolean passwdLogin = false; if (PracticalUtils.isNormalString(model.getLoginIdentification())) { diff --git a/src/main/resources/swagger.properties b/src/main/resources/swagger.properties new file mode 100644 index 0000000..8e8b9de --- /dev/null +++ b/src/main/resources/swagger.properties @@ -0,0 +1,9 @@ +# see https://github.com/cpjit/swagger + +packageToScan=yi.master.business +apiDescription=Master Yi Api Test +apiTitle=MasterYiApi +apiVersion=1.0.0 +teamOfService=www.xuwangcheng.com/yi +devMode=false +disabled=true \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index ed91172..24992f5 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -38,6 +38,15 @@ + + + swaggerFilter + com.cpjit.swagger4j.SwaggerFilter + + + swaggerFilter + /doc/* + DruidWebStatFilter diff --git a/update.md b/update.md index 380b9a1..5659d08 100644 --- a/update.md +++ b/update.md @@ -2,6 +2,7 @@ #### 2020.2.5 - 更新:单个场景调试时可自定义报文内容; - 修复:HTTP请求时返回302状态时报错的问题;(未测试) +- 新增:继承swagger4j,可查看api文档,使用方法:修改swagger.properties中disabled=false,启动项目打开http://localhost:8080/doc/index.html,api注解使用请参考https://github.com/cpjit/swagger ### v1.0.2 -- Gitee From 10c8abac2785766626a12d538056e4b426fe4048 Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Thu, 20 Feb 2020 13:01:56 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=97=B6=E6=8C=87=E5=AE=9A=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E8=8B=B1=E6=96=87=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E6=9F=90=E4=BA=9BLinux=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=8A=E5=87=BA=E7=8E=B0=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E4=B9=B1=E7=A0=81=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/excel/ExportInterfaceInfo.java | 25 ++++++++----------- update.md | 3 ++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/yi/master/util/excel/ExportInterfaceInfo.java b/src/main/java/yi/master/util/excel/ExportInterfaceInfo.java index b8b6570..5a16b8c 100644 --- a/src/main/java/yi/master/util/excel/ExportInterfaceInfo.java +++ b/src/main/java/yi/master/util/excel/ExportInterfaceInfo.java @@ -1,25 +1,20 @@ package yi.master.util.excel; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; -import java.util.List; - import org.apache.log4j.Logger; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; - +import org.apache.poi.ss.usermodel.*; import yi.master.business.message.bean.InterfaceInfo; import yi.master.business.message.bean.Parameter; import yi.master.constant.MessageKeys; import yi.master.constant.SystemConsts; -import yi.master.util.PracticalUtils; import yi.master.util.FrameworkUtil; +import yi.master.util.PracticalUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Date; +import java.util.List; /** * 从数据库导出接口详细文档 @@ -34,7 +29,7 @@ public class ExportInterfaceInfo { public static String exportDocuments (List infos, int type) throws Exception { String path = null; OutputStream outputStream = null; - String fileName = "接口文档_" + System.currentTimeMillis() + "." + (PoiExcelUtil.XLSX == type ? "xlsx" : "xls"); + String fileName = "document_" + System.currentTimeMillis() + "." + (PoiExcelUtil.XLSX == type ? "xlsx" : "xls"); try { //创建excel Workbook wb = PoiExcelUtil.createWorkBook(type); diff --git a/update.md b/update.md index 5659d08..cda44c7 100644 --- a/update.md +++ b/update.md @@ -2,7 +2,8 @@ #### 2020.2.5 - 更新:单个场景调试时可自定义报文内容; - 修复:HTTP请求时返回302状态时报错的问题;(未测试) -- 新增:继承swagger4j,可查看api文档,使用方法:修改swagger.properties中disabled=false,启动项目打开http://localhost:8080/doc/index.html,api注解使用请参考https://github.com/cpjit/swagger +- 新增:集成swagger4j,可查看api文档,使用方法:修改swagger.properties中disabled=false,启动项目打开http://localhost:8080/doc/index.html,api注解使用请参考https://github.com/cpjit/swagger +- 更新:生成接口文档时指定名称修改为英文,防止某些Linux服务器上出现文件名中文乱码的文件; ### v1.0.2 -- Gitee