forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubscribe.java
More file actions
42 lines (29 loc) · 1.01 KB
/
Copy pathSubscribe.java
File metadata and controls
42 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.pubnub.api;
import java.util.concurrent.TimeUnit;
import static com.jayway.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import com.pubnub.api.Callback;
import com.pubnub.api.Pubnub;
import com.pubnub.api.PubnubError;
class PublishResult {
int result = 0;
}
public class Subscribe {
@Test
public void shouldReceiveMessage() throws Exception {
Pubnub pubnub = new Pubnub("demo", "demo");
PublishResult pr = new PublishResult();
pubnub.publish("demo", "demo", new Callback() {
public void successCallback(String channel, Object message) {
System.out.println(message);
// pr.result = 1;
}
public void errorCallback(String channel, PubnubError error) {
}
});
await().pollDelay(1, TimeUnit.MICROSECONDS).until(() -> pr.result == 1);
}
}