Skip to content

Commit e528ceb

Browse files
author
Max Presman
committed
bumping dependencies and adding tests
1 parent 795533c commit e528ceb

3 files changed

Lines changed: 110 additions & 25 deletions

File tree

‎pom.xml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<plugin>
4444
<groupId>org.apache.maven.plugins</groupId>
4545
<artifactId>maven-compiler-plugin</artifactId>
46-
<version>3.1</version>
46+
<version>3.5.1</version>
4747
<configuration>
4848
<source>1.7</source>
4949
<target>1.7</target>
@@ -53,7 +53,7 @@
5353
<plugin>
5454
<groupId>org.apache.maven.plugins</groupId>
5555
<artifactId>maven-surefire-plugin</artifactId>
56-
<version>2.7</version>
56+
<version>2.19.1</version>
5757
</plugin>
5858

5959
<plugin>
@@ -120,25 +120,25 @@
120120
<dependency>
121121
<groupId>com.squareup.retrofit2</groupId>
122122
<artifactId>retrofit</artifactId>
123-
<version>2.0.0</version>
123+
<version>2.0.2</version>
124124
</dependency>
125125

126126
<dependency>
127127
<groupId>com.fasterxml.jackson.core</groupId>
128128
<artifactId>jackson-core</artifactId>
129-
<version>2.7.2</version>
129+
<version>2.7.3</version>
130130
</dependency>
131131

132132
<dependency>
133133
<groupId>com.fasterxml.jackson.core</groupId>
134134
<artifactId>jackson-annotations</artifactId>
135-
<version>2.7.2</version>
135+
<version>2.7.3</version>
136136
</dependency>
137137

138138
<dependency>
139139
<groupId>com.squareup.retrofit2</groupId>
140140
<artifactId>converter-jackson</artifactId>
141-
<version>2.0.0</version>
141+
<version>2.0.2</version>
142142
</dependency>
143143

144144

@@ -165,7 +165,7 @@
165165
<dependency>
166166
<groupId>org.slf4j</groupId>
167167
<artifactId>slf4j-nop</artifactId>
168-
<version>1.7.20</version>
168+
<version>1.7.21</version>
169169
</dependency>
170170

171171
<dependency>
@@ -185,7 +185,7 @@
185185
<dependency>
186186
<groupId>junit</groupId>
187187
<artifactId>junit</artifactId>
188-
<version>4.11</version>
188+
<version>4.12</version>
189189
<scope>test</scope>
190190
</dependency>
191191

‎src/test/java/com.pubnub.api/endpoints/push/CreatePushNotificationTest.java‎

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

‎src/test/java/com/pubnub/api/managers/SubscriptionManagerTest.java‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,76 @@ public void presence(PubNub pubnub, PNPresenceEventResult presence) {
7474

7575
}
7676

77+
@Test
78+
public void testSubscribeChannelGroupBuilder() {
79+
final AtomicInteger atomic = new AtomicInteger(0);
80+
stubFor(get(urlPathEqualTo("/v2/subscribe/mySubscribeKey/,/0"))
81+
.willReturn(aResponse().withBody("{\"t\":{\"t\":\"14607577960932487\",\"r\":1},\"m\":[{\"a\":\"4\",\"f\":0,\"i\":\"Client-g5d4g\",\"p\":{\"t\":\"14607577960925503\",\"r\":1},\"k\":\"sub-c-4cec9f8e-01fa-11e6-8180-0619f8945a4f\",\"c\":\"coolChannel\",\"d\":{\"text\":\"Enter Message Here\"},\"b\":\"coolChan-bnel\"}]}")));
82+
83+
pubnub.addListener(new SubscribeCallback() {
84+
@Override
85+
public void status(PubNub pubnub, PNStatus status) {
86+
}
87+
88+
@Override
89+
public void message(PubNub pubnub, PNMessageResult message) {
90+
List<LoggedRequest> requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*")));
91+
92+
if (requests.size() == 1){
93+
assertEquals("cg1,cg2", requests.get(0).queryParameter("channel-group").firstValue());
94+
atomic.addAndGet(1);
95+
}
96+
97+
}
98+
99+
@Override
100+
public void presence(PubNub pubnub, PNPresenceEventResult presence) {
101+
}
102+
});
103+
104+
105+
pubnub.subscribe().channelGroups(Arrays.asList("cg1", "cg2")).execute();
106+
107+
Awaitility.await().atMost(5, TimeUnit.SECONDS)
108+
.untilAtomic(atomic, org.hamcrest.core.IsEqual.equalTo(1));
109+
110+
}
111+
112+
@Test
113+
public void testSubscribeChannelGroupWithPresenceBuilder() {
114+
final AtomicInteger atomic = new AtomicInteger(0);
115+
stubFor(get(urlPathEqualTo("/v2/subscribe/mySubscribeKey/,/0"))
116+
.willReturn(aResponse().withBody("{\"t\":{\"t\":\"14607577960932487\",\"r\":1},\"m\":[{\"a\":\"4\",\"f\":0,\"i\":\"Client-g5d4g\",\"p\":{\"t\":\"14607577960925503\",\"r\":1},\"k\":\"sub-c-4cec9f8e-01fa-11e6-8180-0619f8945a4f\",\"c\":\"coolChannel\",\"d\":{\"text\":\"Enter Message Here\"},\"b\":\"coolChan-bnel\"}]}")));
117+
118+
pubnub.addListener(new SubscribeCallback() {
119+
@Override
120+
public void status(PubNub pubnub, PNStatus status) {
121+
}
122+
123+
@Override
124+
public void message(PubNub pubnub, PNMessageResult message) {
125+
List<LoggedRequest> requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*")));
126+
127+
if (requests.size() == 1){
128+
assertEquals("cg1,cg1-pnpres,cg2,cg2-pnpres", requests.get(0).queryParameter("channel-group").firstValue());
129+
atomic.addAndGet(1);
130+
}
131+
132+
}
133+
134+
@Override
135+
public void presence(PubNub pubnub, PNPresenceEventResult presence) {
136+
}
137+
});
138+
139+
140+
pubnub.subscribe().channelGroups(Arrays.asList("cg1", "cg2")).withPresence().execute();
141+
142+
Awaitility.await().atMost(5, TimeUnit.SECONDS)
143+
.untilAtomic(atomic, org.hamcrest.core.IsEqual.equalTo(1));
144+
145+
}
146+
77147
@Test
78148
public void testSubscribeWithTimeTokenBuilder() {
79149
final AtomicInteger atomic = new AtomicInteger(0);

0 commit comments

Comments
 (0)