11package com .pusher .client ;
22
3- import static org .junit .Assert .*;
4-
53import org .junit .Before ;
64import org .junit .Test ;
75import org .junit .runner .RunWith ;
86import org .mockito .Mock ;
97import org .mockito .runners .MockitoJUnitRunner ;
108
11- import java .net .InetAddress ;
129import java .net .InetSocketAddress ;
1310import java .net .Proxy ;
1411
12+ import static org .junit .Assert .assertEquals ;
13+ import static org .junit .Assert .assertNull ;
14+ import static org .junit .Assert .assertSame ;
15+
1516@ RunWith (MockitoJUnitRunner .class )
1617public class PusherOptionsTest {
1718
@@ -30,6 +31,11 @@ public void testEncryptedInitializedAsTrue() {
3031 assert pusherOptions .isEncrypted ();
3132 }
3233
34+ @ Test
35+ public void testForceTLSInitializedAsTrue () {
36+ assert pusherOptions .isForceTLS ();
37+ }
38+
3339 @ Test
3440 public void testAuthorizerIsInitiallyNull () {
3541 assertNull (pusherOptions .getAuthorizer ());
@@ -47,6 +53,12 @@ public void testEncryptedCanBeSetToTrue() {
4753 assertSame (true , pusherOptions .isEncrypted ());
4854 }
4955
56+ @ Test
57+ public void testForceTLSCanBeSetToTrue () {
58+ pusherOptions .setForceTLS (true );
59+ assertSame (true , pusherOptions .isForceTLS ());
60+ }
61+
5062 @ Test
5163 public void testSetAuthorizerReturnsSelf () {
5264 assertSame (pusherOptions , pusherOptions .setAuthorizer (mockAuthorizer ));
@@ -57,6 +69,11 @@ public void testSetEncryptedReturnsSelf() {
5769 assertSame (pusherOptions , pusherOptions .setEncrypted (true ));
5870 }
5971
72+ @ Test
73+ public void testSetForceTLSReturnsSelf () {
74+ assertSame (pusherOptions , pusherOptions .setForceTLS (true ));
75+ }
76+
6077 @ Test
6178 public void testDefaultURL () {
6279 assertEquals (pusherOptions .buildUrl (API_KEY ), "wss://ws.pusherapp.com:443/app/" + API_KEY
@@ -65,7 +82,7 @@ public void testDefaultURL() {
6582
6683 @ Test
6784 public void testNonSSLURLIsCorrect () {
68- pusherOptions .setEncrypted (false );
85+ pusherOptions .setForceTLS (false );
6986 assertEquals (pusherOptions .buildUrl (API_KEY ), "ws://ws.pusherapp.com:80/app/" + API_KEY
7087 + "?client=java-client&protocol=5&version=" + PusherOptions .LIB_VERSION );
7188 }
@@ -79,7 +96,7 @@ public void testClusterSetURLIsCorrect() {
7996
8097 @ Test
8198 public void testClusterSetNonSSLURLIsCorrect () {
82- pusherOptions .setCluster ("eu" ).setEncrypted (false );
99+ pusherOptions .setCluster ("eu" ).setForceTLS (false );
83100 assertEquals (pusherOptions .buildUrl (API_KEY ), "ws://ws-eu.pusher.com:80/app/" + API_KEY
84101 + "?client=java-client&protocol=5&version=" + PusherOptions .LIB_VERSION );
85102 }
@@ -93,7 +110,7 @@ public void testCustomHostAndPortURLIsCorrect() {
93110
94111 @ Test
95112 public void testCustomHostAndPortNonSSLURLIsCorrect () {
96- pusherOptions .setHost ("subdomain.example.com" ).setWsPort (8080 ).setWssPort (8181 ).setEncrypted (false );
113+ pusherOptions .setHost ("subdomain.example.com" ).setWsPort (8080 ).setWssPort (8181 ).setForceTLS (false );
97114 assertEquals (pusherOptions .buildUrl (API_KEY ), "ws://subdomain.example.com:8080/app/" + API_KEY
98115 + "?client=java-client&protocol=5&version=" + PusherOptions .LIB_VERSION );
99116 }
0 commit comments