11package com .pubnub .api ;
22
3+ import com .pubnub .api .callbacks .SubscribeCallback ;
4+ import com .pubnub .api .enums .PNReconnectionPolicy ;
5+ import com .pubnub .api .models .consumer .PNStatus ;
6+ import com .pubnub .api .models .consumer .pubsub .PNMessageResult ;
7+ import com .pubnub .api .models .consumer .pubsub .PNPresenceEventResult ;
38import org .junit .Assert ;
49import org .junit .Before ;
510import org .junit .Test ;
611
712import java .io .IOException ;
13+ import java .util .Arrays ;
814
915public class PubNubTest {
1016 private PubNub pubnub ;
@@ -56,4 +62,53 @@ public void testDecryptConfigurationKey() throws PubNubException {
5662
5763 }
5864
65+ @ org .junit .Test
66+ public void testPNConfiguration () throws IOException , PubNubException {
67+ pnConfiguration .setSubscribeTimeout (3000 );
68+ pnConfiguration .setConnectTimeout (4000 );
69+ pnConfiguration .setNonSubscribeRequestTimeout (5000 );
70+ pnConfiguration .setReconnectionPolicy (PNReconnectionPolicy .NONE );
71+ pubnub = new PubNub (pnConfiguration );
72+
73+ Assert .assertNotNull ("pubnub object is null" , pubnub );
74+ Assert .assertNotNull (pubnub .getConfiguration ());
75+ Assert .assertEquals ("https://pubsub.pubnub.com" , pubnub .getBaseUrl ());
76+ Assert .assertEquals (3000 , pnConfiguration .getSubscribeTimeout ());
77+ Assert .assertEquals (4000 , pnConfiguration .getConnectTimeout ());
78+ Assert .assertEquals (5000 , pnConfiguration .getNonSubscribeRequestTimeout ());
79+ }
80+
81+ @ org .junit .Test (expected = PubNubException .class )
82+ public void testDecryptNull () throws PubNubException {
83+ pnConfiguration .setCipherKey ("cipherKey" );
84+ pubnub = new PubNub (pnConfiguration );
85+ Assert .assertEquals ("test1" , pubnub .decrypt (null ).trim ());
86+ }
87+
88+ @ org .junit .Test (expected = PubNubException .class )
89+ public void testDecryptNull_B () throws PubNubException {
90+ pubnub = new PubNub (pnConfiguration );
91+ Assert .assertEquals ("test1" , pubnub .decrypt (null , "cipherKey" ).trim ());
92+ }
93+
94+ @ org .junit .Test
95+ public void GetVersionAndTimeStamp () throws PubNubException {
96+ pubnub = new PubNub (pnConfiguration );
97+ String version = pubnub .getVersion ();
98+ int timeStamp = pubnub .getTimestamp ();
99+ Assert .assertEquals ("4.0.4" , version );
100+ Assert .assertTrue (timeStamp > 0 );
101+ }
102+
103+ @ org .junit .Test (expected = PubNubException .class )
104+ public void testEcryptNull () throws PubNubException {
105+ pubnub = new PubNub (pnConfiguration );
106+ Assert .assertEquals ("test1" , pubnub .encrypt (null ));
107+ }
108+
109+ @ org .junit .Test (expected = PubNubException .class )
110+ public void testEcryptNull_B () throws PubNubException {
111+ pubnub = new PubNub (pnConfiguration );
112+ Assert .assertEquals ("test1" , pubnub .encrypt (null , "chiperKey" ));
113+ }
59114}
0 commit comments