forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURLGeneratorTest.java
More file actions
52 lines (39 loc) · 1.42 KB
/
Copy pathURLGeneratorTest.java
File metadata and controls
52 lines (39 loc) · 1.42 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
package com.pubnub.api;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
public class URLGeneratorTest {
Pubnub pubnub;
@Before
public void setUp() {
pubnub = new Pubnub("demo", "demo");
}
@Test
public void testGetURL() {
assertEquals("http://pubsub-1.pubnub.com", pubnub.getPubnubUrl());
}
@Test
public void testGetURLWithCacheBustingDisabled() {
pubnub.setCacheBusting(false);
assertEquals("http://pubsub.pubnub.com", pubnub.getPubnubUrl());
}
@Test
public void testGetUrlWithAndWithoutOriginManager() throws PubnubException, InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
pubnub.setOriginsPool(new String[]{"origin1", "origin2"}, true);
pubnub.subscribe("demo", new Callback() {
@Override
public void connectCallback(String channel, Object message) {
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
assertTrue(pubnub.isOriginManagerRunning());
assertEquals("http://origin1.pubnub.com", pubnub.getPubnubUrl());
pubnub.unsubscribe("demo");
assertFalse(pubnub.isOriginManagerRunning());
assertTrue(pubnub.getPubnubUrl().matches("^http://pubsub-\\d+\\.pubnub\\.com$"));
}
}