Skip to content

Commit f80ec46

Browse files
committed
非 DEBUG 模式下不允许使用 UnitAuto 单元测试
1 parent 102e2e3 commit f80ec46

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

pom.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>apijson.framework</groupId>
77
<artifactId>apijson-framework</artifactId>
8-
<version>4.2.3</version>
8+
<version>4.3.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONFramework</name>
@@ -28,6 +28,16 @@
2828
<artifactId>apijson-orm</artifactId>
2929
<version>4.2.3</version>
3030
</dependency>
31+
<!-- <dependency>
32+
<groupId>com.github.TommyLemon</groupId>
33+
<artifactId>unitauto-java</artifactId>
34+
<version>2.5.0</version>
35+
</dependency> -->
36+
<!-- <dependency>
37+
<groupId>com.github.TommyLemon</groupId>
38+
<artifactId>unitauto-jar</artifactId>
39+
<version>2.5.2</version>
40+
</dependency> -->
3141
<dependency>
3242
<groupId>javax.servlet</groupId>
3343
<artifactId>javax.servlet-api</artifactId>
@@ -70,8 +80,8 @@
7080

7181
<repositories>
7282
<repository>
73-
<id>jitpack.io</id>
74-
<url>https://jitpack.io</url>
83+
<id>jitpack.io</id>
84+
<url>https://jitpack.io</url>
7585
</repository>
7686
</repositories>
7787

src/main/java/apijson/framework/APIJSONController.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Parser<Long> newParser(HttpSession session, RequestMethod method) {
7272
public String parse(String request, HttpSession session, RequestMethod method) {
7373
return newParser(session, method).parse(request);
7474
}
75-
75+
7676
//通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
7777

7878
/**获取
@@ -231,9 +231,12 @@ public Object logout(@NotNull HttpSession session) {
231231

232232

233233
public JSONObject listMethod(String request) {
234+
if (Log.DEBUG == false) {
235+
return APIJSONParser.newErrorResult(new IllegalAccessException("非 DEBUG 模式下不允许使用 UnitAuto 单元测试!"));
236+
}
234237
return MethodUtil.listMethod(request);
235238
}
236-
239+
237240
public void invokeMethod(String request, HttpServletRequest servletRequest) {
238241
AsyncContext asyncContext = servletRequest.startAsync();
239242

@@ -243,8 +246,8 @@ public void invokeMethod(String request, HttpServletRequest servletRequest) {
243246
public void complete(JSONObject data, Method method, InterfaceProxy proxy, Object... extras) throws Exception {
244247
ServletResponse servletResponse = asyncContext.getResponse();
245248
if (servletResponse.isCommitted()) {
246-
Log.w(TAG, "invokeMethod listener.complete servletResponse.isCommitted() >> return;");
247-
return;
249+
Log.w(TAG, "invokeMethod listener.complete servletResponse.isCommitted() >> return;");
250+
return;
248251
}
249252

250253
servletResponse.setCharacterEncoding(servletRequest.getCharacterEncoding());
@@ -253,6 +256,19 @@ public void complete(JSONObject data, Method method, InterfaceProxy proxy, Objec
253256
asyncContext.complete();
254257
}
255258
};
259+
260+
if (Log.DEBUG == false) {
261+
try {
262+
listener.complete(MethodUtil.JSON_CALLBACK.newErrorResult(new IllegalAccessException("非 DEBUG 模式下不允许使用 UnitAuto 单元测试!")));
263+
}
264+
catch (Exception e1) {
265+
e1.printStackTrace();
266+
asyncContext.complete();
267+
}
268+
269+
return;
270+
}
271+
256272

257273
try {
258274
MethodUtil.invokeMethod(request, null, listener);

0 commit comments

Comments
 (0)