8
8
import cn .binarywang .wx .miniapp .constant .WxMaApiUrlConstants ;
9
9
import cn .binarywang .wx .miniapp .test .ApiTestModule ;
10
10
import cn .binarywang .wx .miniapp .test .TestConfig ;
11
+ import com .google .gson .JsonObject ;
11
12
import com .google .inject .Inject ;
12
13
import java .util .ArrayList ;
13
14
import java .util .List ;
15
+ import me .chanjar .weixin .common .bean .ToJson ;
14
16
import me .chanjar .weixin .common .error .WxErrorException ;
15
17
import org .slf4j .Logger ;
16
18
import org .slf4j .LoggerFactory ;
@@ -35,6 +37,85 @@ public void testApiSignature() throws Exception {
35
37
logger .info ("apply 额度剩余 :{}" , result .getQuota ());
36
38
}
37
39
40
+ @ Test
41
+ public void testApiGetPostNullData () throws Exception {
42
+ try {
43
+ wxService .get (WxMaApiUrlConstants .Analysis .GET_USER_PORTRAIT_URL , null );
44
+ } catch (NullPointerException npe ) {
45
+ logger .error ("NullPointerException" , npe );
46
+ fail ("遇到空指针 get(url, null)" );
47
+ } catch (WxErrorException wxErrorException ) {
48
+ // 这个是正常的,因为这里的调用没按照接口规则
49
+ }
50
+ // 走加密路径url
51
+ try {
52
+ wxService .post (WxMaApiUrlConstants .OpenApi .CLEAR_QUOTA , (Object ) null );
53
+ } catch (NullPointerException npe ) {
54
+ logger .error ("NullPointerException" , npe );
55
+ fail ("遇到空指针 post(url, Object null)" );
56
+ } catch (WxErrorException wxErrorException ) {
57
+ // 这个是正常的,因为这里的调用没按照接口规则
58
+ }
59
+ try {
60
+ wxService .post (WxMaApiUrlConstants .OpenApi .CLEAR_QUOTA , (String ) null );
61
+ } catch (NullPointerException npe ) {
62
+ logger .error ("NullPointerException" , npe );
63
+ fail ("遇到空指针 post(url, String null)" );
64
+ } catch (WxErrorException wxErrorException ) {
65
+ // 这个是正常的,因为这里的调用没按照接口规则
66
+ }
67
+ try {
68
+ wxService .post (WxMaApiUrlConstants .OpenApi .CLEAR_QUOTA , (JsonObject ) null );
69
+ } catch (NullPointerException npe ) {
70
+ logger .error ("NullPointerException" , npe );
71
+ fail ("遇到空指针 post(url, JsonObject null)" );
72
+ } catch (WxErrorException wxErrorException ) {
73
+ // 这个是正常的,因为这里的调用没按照接口规则
74
+ }
75
+ try {
76
+ wxService .post (WxMaApiUrlConstants .OpenApi .CLEAR_QUOTA , (ToJson ) null );
77
+ } catch (NullPointerException npe ) {
78
+ logger .error ("NullPointerException" , npe );
79
+ fail ("遇到空指针 post(url, ToJson null)" );
80
+ } catch (WxErrorException wxErrorException ) {
81
+ // 这个是正常的,因为这里的调用没按照接口规则
82
+ }
83
+
84
+ // 不走加密路径URL
85
+ try {
86
+ wxService .post (WxMaApiUrlConstants .Intracity .APPLY_URL , (Object ) null );
87
+ } catch (NullPointerException npe ) {
88
+ logger .error ("NullPointerException" , npe );
89
+ fail ("遇到空指针 post(url, Object null)" );
90
+ } catch (WxErrorException wxErrorException ) {
91
+ // 这个是正常的,因为这里的调用没按照接口规则
92
+ }
93
+ try {
94
+ wxService .post (WxMaApiUrlConstants .Intracity .APPLY_URL , (String ) null );
95
+ } catch (NullPointerException npe ) {
96
+ logger .error ("NullPointerException" , npe );
97
+ fail ("遇到空指针 post(url, String null)" );
98
+ } catch (WxErrorException wxErrorException ) {
99
+ // 这个是正常的,因为这里的调用没按照接口规则
100
+ }
101
+ try {
102
+ wxService .post (WxMaApiUrlConstants .Intracity .APPLY_URL , (JsonObject ) null );
103
+ } catch (NullPointerException npe ) {
104
+ logger .error ("NullPointerException" , npe );
105
+ fail ("遇到空指针 post(url, JsonObject null)" );
106
+ } catch (WxErrorException wxErrorException ) {
107
+ // 这个是正常的,因为这里的调用没按照接口规则
108
+ }
109
+ try {
110
+ wxService .post (WxMaApiUrlConstants .Intracity .APPLY_URL , (ToJson ) null );
111
+ } catch (NullPointerException npe ) {
112
+ logger .error ("NullPointerException" , npe );
113
+ fail ("遇到空指针 post(url, ToJson null)" );
114
+ } catch (WxErrorException wxErrorException ) {
115
+ // 这个是正常的,因为这里的调用没按照接口规则
116
+ }
117
+ }
118
+
38
119
@ Test
39
120
public void testApply () throws Exception {
40
121
logger .debug ("testApply" );
0 commit comments