Repository navigation
Expand file tree
/
Copy pathNextPageTest.java
More file actions
55 lines (40 loc) · 1.6 KB
/
Copy pathNextPageTest.java
File metadata and controls
55 lines (40 loc) · 1.6 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
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.pubnub.api.datasync;
import com.pubnub.api.*;
import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
import java.lang.reflect.Field;
import java.util.Hashtable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
public class NextPageTest {
Pubnub pubnub;
String playerString;
@Before
public void setUp() throws InterruptedException {
pubnub = new Pubnub("demo-36", "demo-36");
pubnub.setCacheBusting(false);
playerString = "player-" + TestHelper.random();
}
@Test
public void testNextPage() throws InterruptedException, JSONException, IllegalAccessException, NoSuchFieldException {
DataSyncTestHelper.setupSettingsOn(playerString, pubnub, true);
Field f = pubnub.getClass().getSuperclass().getSuperclass().getDeclaredField("params");
f.setAccessible(true);
Hashtable<String, String> params = (Hashtable<String, String>) f.get(pubnub);
params.put("page_max_bytes", "10");
final CountDownLatch latch = new CountDownLatch(1);
DataSyncCallback settingsCallback = new DataSyncCallback() {
@Override
public void readyCallback() {
latch.countDown();
}
};
SyncedObject player = pubnub.sync(playerString, settingsCallback);
latch.await(5, TimeUnit.SECONDS);
assertEquals(0, latch.getCount());
assertEquals(new Integer(3), player.size("settings"));
assertEquals(new Integer(3), player.size("tracks"));
}
}