@@ -45,7 +45,7 @@ public void beforeEach() throws IOException {
4545 @ Test
4646 public void appleSyncTest () throws PubNubException , InterruptedException {
4747
48- stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_apns%22%3A%7B%22a %22%3A%22b %22%2C%22c %22%3A%22d %22%7D%7D" ))
48+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_apns%22%3A%7B%22c %22%3A%22d %22%2C%22a %22%3A%22b %22%7D%7D" ))
4949 .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
5050
5151 instance .channel ("testChannel" )
@@ -57,12 +57,16 @@ public void appleSyncTest() throws PubNubException, InterruptedException {
5757 }
5858
5959 @ Test
60- public void googleSyncTest () throws InterruptedException , PubNubException {
61- stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_gcm%22%3A%7B%22a %22%3A%22b %22%2C%22c %22%3A%22d %22%7D%7D" ))
60+ public void googleSyncTest () throws InterruptedException {
61+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_gcm%22%3A%7B%22c %22%3A%22d %22%2C%22a %22%3A%22b %22%7D%7D" ))
6262 .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
6363
6464
65- instance .channel ("testChannel" ).addGooglePayload (pushPayload ).sync ();
65+ try {
66+ instance .channel ("testChannel" ).addGooglePayload (pushPayload ).sync ();
67+ } catch (PubNubException e ) {
68+ e .printStackTrace ();
69+ }
6670
6771 List <LoggedRequest > requests = findAll (getRequestedFor (urlMatching ("/.*" )));
6872 assertEquals (1 , requests .size ());
@@ -72,7 +76,7 @@ public void googleSyncTest() throws InterruptedException, PubNubException {
7276 @ Test
7377 public void microsoftSyncTest () throws PubNubException , InterruptedException {
7478
75- stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_mpns%22%3A%7B%22a %22%3A%22b %22%2C%22c %22%3A%22d %22%7D%7D" ))
79+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_mpns%22%3A%7B%22c %22%3A%22d %22%2C%22a %22%3A%22b %22%7D%7D" ))
7680 .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
7781
7882 instance .channel ("testChannel" )
@@ -104,18 +108,15 @@ public void allPayloadsSyncTest() throws InterruptedException, PubNubException {
104108 @ Test
105109 public void appleAsyncTest () throws PubNubException , InterruptedException {
106110
107- stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_apns%22%3A%7B%22a %22%3A%22b %22%2C%22c %22%3A%22d %22%7D%7D" ))
111+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_apns%22%3A%7B%22c %22%3A%22d %22%2C%22a %22%3A%22b %22%7D%7D" ))
108112 .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
109113
110114 final AtomicInteger atomic = new AtomicInteger (0 );
111115 instance .channel ("testChannel" )
112116 .addApplePayload (pushPayload ).async (new PNCallback <PNPublishResult >() {
113117 @ Override
114118 public void onResponse (PNPublishResult result , PNStatus status ) {
115- List <LoggedRequest > requests = findAll (getRequestedFor (urlMatching ("/.*" )));
116119 assertFalse (status .isError ());
117- assertEquals (1 , requests .size ());
118- assertEquals ("myUUID" , requests .get (0 ).queryParameter ("uuid" ).firstValue ());
119120 atomic .addAndGet (1 );
120121 }
121122 });
@@ -127,17 +128,14 @@ public void onResponse(PNPublishResult result, PNStatus status) {
127128
128129 @ Test
129130 public void googleAsyncTest () throws PubNubException , InterruptedException {
130- stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_gcm%22%3A%7B%22a %22%3A%22b %22%2C%22c %22%3A%22d %22%7D%7D" ))
131+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_gcm%22%3A%7B%22c %22%3A%22d %22%2C%22a %22%3A%22b %22%7D%7D" ))
131132 .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
132133 final AtomicInteger atomic = new AtomicInteger (0 );
133134 instance .channel ("testChannel" )
134135 .addGooglePayload (pushPayload ).async (new PNCallback <PNPublishResult >() {
135136 @ Override
136137 public void onResponse (PNPublishResult result , PNStatus status ) {
137- List <LoggedRequest > requests = findAll (getRequestedFor (urlMatching ("/.*" )));
138138 assertFalse (status .isError ());
139- assertEquals (1 , requests .size ());
140- assertEquals ("myUUID" , requests .get (0 ).queryParameter ("uuid" ).firstValue ());
141139 atomic .addAndGet (1 );
142140 }
143141 });
@@ -150,18 +148,15 @@ public void onResponse(PNPublishResult result, PNStatus status) {
150148 @ Test
151149 public void microsoftAsyncTest () throws PubNubException , InterruptedException {
152150
153- stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_mpns%22%3A%7B%22a %22%3A%22b %22%2C%22c %22%3A%22d %22%7D%7D" ))
151+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_mpns%22%3A%7B%22c %22%3A%22d %22%2C%22a %22%3A%22b %22%7D%7D" ))
154152 .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
155153
156154 final AtomicInteger atomic = new AtomicInteger (0 );
157155 instance .channel ("testChannel" )
158156 .addMicrosoftPayload (pushPayload ).async (new PNCallback <PNPublishResult >() {
159157 @ Override
160158 public void onResponse (PNPublishResult result , PNStatus status ) {
161- List <LoggedRequest > requests = findAll (getRequestedFor (urlMatching ("/.*" )));
162159 assertFalse (status .isError ());
163- assertEquals (1 , requests .size ());
164- assertEquals ("myUUID" , requests .get (0 ).queryParameter ("uuid" ).firstValue ());
165160 atomic .addAndGet (1 );
166161 }
167162 });
@@ -171,5 +166,25 @@ public void onResponse(PNPublishResult result, PNStatus status) {
171166
172167 }
173168
169+ @ Test
170+ public void allPayloadsASyncTest () throws InterruptedException , PubNubException {
171+
172+ stubFor (get (urlPathEqualTo ("/publish/myPublishKey/mySubscribeKey/0/testChannel/0/%7B%22pn_mpns%22%3A%7B%22c%22%3A%22d%22%2C%22a%22%3A%22b%22%7D%2C%22c%22%3A%22d%22%2C%22a%22%3A%22b%22%2C%22pn_gcm%22%3A%7B%22c%22%3A%22d%22%2C%22a%22%3A%22b%22%7D%2C%22pn_apns%22%3A%7B%22c%22%3A%22d%22%2C%22a%22%3A%22b%22%7D%7D" ))
173+ .willReturn (aResponse ().withBody ("[1,\" Sent\" ,\" 14598111595318003\" ]" )));
174+
175+ final AtomicInteger atomic = new AtomicInteger (0 );
176+ instance .channel ("testChannel" )
177+ .addApplePayload (pushPayload )
178+ .addMicrosoftPayload (pushPayload )
179+ .addGooglePayload (pushPayload )
180+ .addPubNubPayload (pushPayload )
181+ .async (new PNCallback <PNPublishResult >() {
182+ @ Override
183+ public void onResponse (PNPublishResult result , PNStatus status ) {
184+ assertFalse (status .isError ());
185+ atomic .addAndGet (1 );
186+ }
187+ });
188+ }
174189
175190}
0 commit comments