66import org .junit .Test ;
77
88import cn .jpush .api .push .PushResult ;
9+ import cn .jpush .api .push .model .Message ;
910import cn .jpush .api .push .model .Platform ;
1011import cn .jpush .api .push .model .PushPayload ;
1112import cn .jpush .api .push .model .audience .Audience ;
1213import cn .jpush .api .push .model .notification .AndroidNotification ;
14+ import cn .jpush .api .push .model .notification .IosNotification ;
1315import cn .jpush .api .push .model .notification .Notification ;
16+ import cn .jpush .api .push .model .notification .WinphoneNotification ;
1417
1518public class PushFunctionTests {
1619 private static final String appKey ="dd1066407b044738b6479275" ;
@@ -31,14 +34,27 @@ public void before() {
3134
3235
3336 @ Test
34- public void sendSimpleNotificationAll () {
37+ public void sendSimpleNotification_Pall_Ndefault () {
3538 PushPayload payload = PushPayload .notificationAlertAll (ALERT );
3639 PushResult result = _client .sendPush (payload );
3740 assertEquals (0 , result .getErrorCode ());
3841 }
3942
4043 @ Test
41- public void sendSimpleNotification_android () {
44+ public void sendSimpleNotification_Pandroid_Nandroid () {
45+ PushPayload payload = PushPayload .newBuilder ()
46+ .setPlatform (Platform .android ())
47+ .setAudience (Audience .all ())
48+ .setNotification (Notification .newBuilder ()
49+ .addPlatformNotification (AndroidNotification .alert ("alert" ))
50+ .build ())
51+ .build ();
52+ PushResult result = _client .sendPush (payload );
53+ assertEquals (0 , result .getErrorCode ());
54+ }
55+
56+ @ Test
57+ public void sendSimpleNotification_Pall_Nandroid () {
4258 PushPayload payload = PushPayload .newBuilder ()
4359 .setPlatform (Platform .all ())
4460 .setAudience (Audience .all ())
@@ -50,7 +66,114 @@ public void sendSimpleNotification_android() {
5066 assertEquals (0 , result .getErrorCode ());
5167 }
5268
53-
69+ @ Test
70+ public void sendSimpleNotification_Pios_Nios () {
71+ PushPayload payload = PushPayload .newBuilder ()
72+ .setPlatform (Platform .ios ())
73+ .setAudience (Audience .all ())
74+ .setNotification (Notification .newBuilder ()
75+ .addPlatformNotification (IosNotification .alert ("alert" ))
76+ .build ())
77+ .build ();
78+ PushResult result = _client .sendPush (payload );
79+ assertEquals (0 , result .getErrorCode ());
80+ }
81+
82+ @ Test
83+ public void sendSimpleNotification_Pall_Nios () {
84+ PushPayload payload = PushPayload .newBuilder ()
85+ .setPlatform (Platform .all ())
86+ .setAudience (Audience .all ())
87+ .setNotification (Notification .newBuilder ()
88+ .addPlatformNotification (IosNotification .alert ("alert" ))
89+ .build ())
90+ .build ();
91+ PushResult result = _client .sendPush (payload );
92+ assertEquals (0 , result .getErrorCode ());
93+ }
94+
95+ @ Test
96+ public void sendSimpleNotification_Pwp_Nwp () {
97+ PushPayload payload = PushPayload .newBuilder ()
98+ .setPlatform (Platform .winphone ())
99+ .setAudience (Audience .all ())
100+ .setNotification (Notification .newBuilder ()
101+ .addPlatformNotification (WinphoneNotification .alert ("alert" ))
102+ .build ())
103+ .build ();
104+ PushResult result = _client .sendPush (payload );
105+ assertEquals (0 , result .getErrorCode ());
106+ }
107+
108+ @ Test
109+ public void sendSimpleNotification_wp () {
110+ PushPayload payload = PushPayload .newBuilder ()
111+ .setPlatform (Platform .all ())
112+ .setAudience (Audience .all ())
113+ .setNotification (Notification .newBuilder ()
114+ .addPlatformNotification (WinphoneNotification .alert ("alert" ))
115+ .build ())
116+ .build ();
117+ PushResult result = _client .sendPush (payload );
118+ assertEquals (0 , result .getErrorCode ());
119+ }
120+
121+
122+ @ Test
123+ public void sendSimpleNotification_Pall_Nall () {
124+ PushPayload payload = PushPayload .newBuilder ()
125+ .setPlatform (Platform .all ())
126+ .setAudience (Audience .all ())
127+ .setNotification (Notification .newBuilder ()
128+ .addPlatformNotification (WinphoneNotification .alert ("alert" ))
129+ .addPlatformNotification (IosNotification .alert ("alert" ))
130+ .addPlatformNotification (AndroidNotification .alert ("alert" ))
131+ .build ())
132+ .build ();
133+ PushResult result = _client .sendPush (payload );
134+ assertEquals (0 , result .getErrorCode ());
135+ }
136+
137+ @ Test
138+ public void sendSimpleMessage_default () {
139+ PushPayload payload = PushPayload .simpleMessageAll (MSG_CONTENT );
140+ PushResult result = _client .sendPush (payload );
141+ assertEquals (0 , result .getErrorCode ());
142+ }
143+
144+ @ Test
145+ public void sendSimpleMessage_Pandroid () {
146+ PushPayload payload = PushPayload .newBuilder ()
147+ .setPlatform (Platform .android ())
148+ .setAudience (Audience .all ())
149+ .setMessage (Message .content (MSG_CONTENT ))
150+ .build ();
151+ PushResult result = _client .sendPush (payload );
152+ assertEquals (0 , result .getErrorCode ());
153+ }
154+
155+ @ Test
156+ public void sendSimpleMessage_Pios () {
157+ PushPayload payload = PushPayload .newBuilder ()
158+ .setPlatform (Platform .ios ())
159+ .setAudience (Audience .all ())
160+ .setMessage (Message .content (MSG_CONTENT ))
161+ .build ();
162+ PushResult result = _client .sendPush (payload );
163+ assertEquals (0 , result .getErrorCode ());
164+ }
165+
166+ @ Test
167+ public void sendSimpleMessage_Pwinphone () {
168+ PushPayload payload = PushPayload .newBuilder ()
169+ .setPlatform (Platform .winphone ())
170+ .setAudience (Audience .all ())
171+ .setMessage (Message .content (MSG_CONTENT ))
172+ .build ();
173+ PushResult result = _client .sendPush (payload );
174+ assertEquals (400 , result .getErrorCode ());
175+ }
176+
54177
55178
56179}
0 commit comments