forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPubNubTest.java
More file actions
59 lines (45 loc) · 1.8 KB
/
Copy pathPubNubTest.java
File metadata and controls
59 lines (45 loc) · 1.8 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
56
57
58
59
package com.pubnub.api;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
public class PubNubTest {
private PubNub pubnub;
private PNConfiguration pnConfiguration;
@Before
public void beforeEach() throws IOException {
pnConfiguration = new PNConfiguration();
pnConfiguration.setSecure(true);
pnConfiguration.setSubscribeKey("demo");
pnConfiguration.setPublishKey("demo");
}
@org.junit.Test
public void testCreateSuccess() throws IOException, PubNubException {
pubnub = new PubNub(pnConfiguration);
Assert.assertNotNull("pubnub object is null", pubnub);
Assert.assertNotNull(pubnub.getConfiguration());
Assert.assertEquals("https://pubsub.pubnub.com", pubnub.getBaseUrl());
}
@Test
public void testEncryptCustomKey() throws PubNubException {
pubnub = new PubNub(pnConfiguration);
Assert.assertEquals("iALQtn3PfIXe74CT/wrS7g==", pubnub.encrypt("test1", "cipherKey").trim());
}
@Test
public void testEncryptConfigurationKey() throws PubNubException {
pnConfiguration.setCipherKey("cipherKey");
pubnub = new PubNub(pnConfiguration);
Assert.assertEquals("iALQtn3PfIXe74CT/wrS7g==", pubnub.encrypt("test1").trim());
}
@Test
public void testDecryptCustomKey() throws PubNubException {
pubnub = new PubNub(pnConfiguration);
Assert.assertEquals("test1", pubnub.decrypt("iALQtn3PfIXe74CT/wrS7g==", "cipherKey").trim());
}
@Test
public void testDecryptConfigurationKey() throws PubNubException {
pnConfiguration.setCipherKey("cipherKey");
pubnub = new PubNub(pnConfiguration);
Assert.assertEquals("test1", pubnub.decrypt("iALQtn3PfIXe74CT/wrS7g==").trim());
}
}