Skip to content

Commit 49b03fe

Browse files
author
KenChoi1992
committed
规范写法
1 parent b313f6d commit 49b03fe

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

example/main/java/cn/jsms/api/JSMSExample.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package cn.jsms.api;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
5-
63
import org.slf4j.Logger;
74
import org.slf4j.LoggerFactory;
85

@@ -33,12 +30,10 @@ public static void testSendSMSCode() {
3330
.build();
3431
try {
3532
SendSMSResult res = client.sendSMSCode(payload);
36-
assertTrue(res.isResultOK());
3733
System.out.println(res.toString());
3834
} catch (APIConnectionException e) {
3935
LOG.error("Connection error. Should retry later. ", e);
4036
} catch (APIRequestException e) {
41-
e.printStackTrace();
4237
LOG.error("Error response from JPush server. Should review and fix it. ", e);
4338
LOG.info("HTTP Status: " + e.getStatus());
4439
LOG.info("Error Message: " + e.getMessage());
@@ -49,12 +44,10 @@ public static void testSendValidSMSCode() {
4944
SMSClient client = new SMSClient(masterSecret, appkey, null, JSMSConfig.getInstance());
5045
try {
5146
ValidSMSResult res = client.sendValidSMSCode("23956732-d63f-438b-b940-e1578cc0199f", 225415);
52-
assertEquals(true, res.getIsValid());
5347
System.out.println(res.toString());
5448
} catch (APIConnectionException e) {
5549
LOG.error("Connection error. Should retry later. ", e);
5650
} catch (APIRequestException e) {
57-
e.printStackTrace();
5851
LOG.error("Error response from JPush server. Should review and fix it. ", e);
5952
LOG.info("HTTP Status: " + e.getStatus());
6053
LOG.info("Error Message: " + e.getMessage());

src/main/java/cn/jsms/api/JSMSClient.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package cn.jsms.api;
22

33
import cn.jiguang.common.connection.HttpProxy;
4+
import cn.jiguang.common.resp.APIConnectionException;
5+
import cn.jiguang.common.resp.APIRequestException;
46
import cn.jsms.api.common.JSMSConfig;
57
import cn.jsms.api.common.SMSClient;
8+
import cn.jsms.api.common.model.SMSPayload;
69

710
public class JSMSClient {
811

@@ -11,4 +14,14 @@ public class JSMSClient {
1114
public JSMSClient(String masterSecret, String appkey, HttpProxy proxy, JSMSConfig conf) {
1215
_smsClient = new SMSClient(masterSecret, appkey, proxy, conf);
1316
}
17+
18+
public SendSMSResult sendSMSCode(SMSPayload payload)
19+
throws APIConnectionException, APIRequestException {
20+
return _smsClient.sendSMSCode(payload);
21+
}
22+
23+
public ValidSMSResult sendValidSMSCode(String msgId, int code)
24+
throws APIConnectionException, APIRequestException {
25+
return _smsClient.sendValidSMSCode(msgId, code);
26+
}
1427
}

src/main/java/cn/jsms/api/ValidSMSResult.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.jsms.api;
22

3-
import com.google.gson.JsonObject;
43
import com.google.gson.annotations.Expose;
54

65
import cn.jiguang.common.resp.BaseResult;

src/test/java/cn/jsms/api/sms/SMSClientTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public void testSendSMSCode() {
5353
} catch (APIConnectionException e) {
5454
LOG.error("Connection error. Should retry later. ", e);
5555
} catch (APIRequestException e) {
56-
e.printStackTrace();
5756
LOG.error("Error response from JPush server. Should review and fix it. ", e);
5857
LOG.info("HTTP Status: " + e.getStatus());
5958
LOG.info("Error Message: " + e.getMessage());
@@ -173,7 +172,6 @@ public void testSendValidSMSCode() {
173172
} catch (APIConnectionException e) {
174173
LOG.error("Connection error. Should retry later. ", e);
175174
} catch (APIRequestException e) {
176-
e.printStackTrace();
177175
LOG.error("Error response from JPush server. Should review and fix it. ", e);
178176
LOG.info("HTTP Status: " + e.getStatus());
179177
LOG.info("Error Message: " + e.getMessage());
@@ -187,7 +185,6 @@ public void testSendValidSMSCode_InvalidCode1() {
187185
} catch (APIConnectionException e) {
188186
LOG.error("Connection error. Should retry later. ", e);
189187
} catch (APIRequestException e) {
190-
e.printStackTrace();
191188
LOG.error("Error response from JPush server. Should review and fix it. ", e);
192189
LOG.info("HTTP Status: " + e.getStatus());
193190
LOG.info("Error Message: " + e.getMessage());
@@ -201,7 +198,6 @@ public void testSendValidSMSCode_InvalidCode2() {
201198
} catch (APIConnectionException e) {
202199
LOG.error("Connection error. Should retry later. ", e);
203200
} catch (APIRequestException e) {
204-
e.printStackTrace();
205201
LOG.error("Error response from JPush server. Should review and fix it. ", e);
206202
LOG.info("HTTP Status: " + e.getStatus());
207203
LOG.info("Error Message: " + e.getMessage());
@@ -215,7 +211,6 @@ public void testSendValidSMSCode_InvalidCode3() {
215211
} catch (APIConnectionException e) {
216212
LOG.error("Connection error. Should retry later. ", e);
217213
} catch (APIRequestException e) {
218-
e.printStackTrace();
219214
LOG.error("Error response from JPush server. Should review and fix it. ", e);
220215
LOG.info("HTTP Status: " + e.getStatus());
221216
LOG.info("Error Message: " + e.getMessage());

0 commit comments

Comments
 (0)