Repository navigation
Expand file tree
/
Copy pathPubnubTest.java
More file actions
62 lines (48 loc) · 1.92 KB
/
Copy pathPubnubTest.java
File metadata and controls
62 lines (48 loc) · 1.92 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
60
61
62
package com.pubnub.api;
import com.pubnub.api.core.PnConfiguration;
import com.pubnub.api.core.Pubnub;
import com.pubnub.api.core.PubnubException;
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());
}
}