33import static com .google .common .base .Optional .of ;
44import static org .assertj .core .api .Assertions .assertThat ;
55import static org .mockito .Mockito .mock ;
6+ import static org .mockito .Mockito .when ;
67import static se .bjurr .prnfb .http .UrlInvoker .HTTP_METHOD .DELETE ;
78import static se .bjurr .prnfb .http .UrlInvoker .HTTP_METHOD .GET ;
89import static se .bjurr .prnfb .http .UrlInvoker .HTTP_METHOD .POST ;
@@ -31,11 +32,12 @@ public void before() {
3132 this .urlInvoker =
3233 new UrlInvoker () {
3334 @ Override
34- HttpResponse doInvoke (HttpRequestBase httpRequest , HttpClientBuilder builder ) {
35+ HttpResponse doInvoke (
36+ final HttpRequestBase httpRequest , final HttpClientBuilder builder ) {
3537 UrlInvokerTest .this .httpRequestBase = httpRequest ;
3638 try {
3739 return new HttpResponse (new URI ("http://fake.com" ), 200 , "" );
38- } catch (URISyntaxException e ) {
40+ } catch (final URISyntaxException e ) {
3941 e .printStackTrace ();
4042 return null ;
4143 }
@@ -60,7 +62,7 @@ public void testThatHeadersAreAdded() {
6062
6163 @ Test
6264 public void testThatHeadersAreAddedForBasicAuth () throws Exception {
63- PrnfbNotification notification =
65+ final PrnfbNotification notification =
6466 prnfbNotificationBuilder () //
6567 .withUrl ("http://url.com/" ) //
6668 .withUser ("user" ) //
@@ -82,7 +84,7 @@ public void testThatHeadersAreAddedForBasicAuth() throws Exception {
8284
8385 @ Test
8486 public void testThatHttpEntityEnclosingRequestBaseCanBeCreatedAsPOSTWithoutContent () {
85- HttpRequestBase response =
87+ final HttpRequestBase response =
8688 this .urlInvoker //
8789 .withMethod (POST ) //
8890 .newHttpRequestBase ();
@@ -95,22 +97,22 @@ public void testThatHttpEntityEnclosingRequestBaseCanBeCreatedAsPOSTWithoutConte
9597
9698 @ Test
9799 public void testThatHttpEntityEnclosingRequestBaseCanBeCreatedAsPUTWithContent () {
98- HttpRequestBase response =
100+ final HttpRequestBase response =
99101 this .urlInvoker //
100102 .withMethod (PUT ) //
101103 .withPostContent (Optional .of ("some content" )) //
102104 .newHttpRequestBase ();
103105
104106 assertThat (response .getMethod ()) //
105107 .isEqualTo (PUT .name ());
106- HttpEntityEnclosingRequestBase c = (HttpEntityEnclosingRequestBase ) response ;
108+ final HttpEntityEnclosingRequestBase c = (HttpEntityEnclosingRequestBase ) response ;
107109 assertThat (c .getEntity ().getContentLength ()) //
108110 .isGreaterThan (0 );
109111 }
110112
111113 @ Test
112114 public void testThatHttpRequestBaseCanBeCreatedWithDelete () {
113- HttpRequestBase response =
115+ final HttpRequestBase response =
114116 this .urlInvoker //
115117 .withMethod (DELETE ) //
116118 .newHttpRequestBase ();
@@ -123,43 +125,37 @@ public void testThatHttpRequestBaseCanBeCreatedWithDelete() {
123125
124126 @ Test
125127 public void testThatNoneSslCanBeConfigured () throws Exception {
126- HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
128+ final HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
127129
128130 this .urlInvoker //
129131 .withUrlParam ("http://url.com/" ) //
130132 .configureSsl (mockedBuilder );
131-
132- // verify(mockedBuilder, times(0)).setSSLSocketFactory(Matchers.any());
133133 }
134134
135135 @ Test
136136 public void testThatProxyIsConfiguredIfThereIsAHostAndPort () throws Exception {
137- HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
137+ final HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
138138
139139 this .urlInvoker //
140140 .withUrlParam ("http://url.com/" ) //
141141 .withProxyServer (of ("http://proxy.com/" )) //
142142 .withProxyPort (123 ) //
143143 .configureProxy (mockedBuilder );
144-
145- // verify(mockedBuilder, times(1)).setProxy(Matchers.any());
146144 }
147145
148146 @ Test
149147 public void testThatProxyIsNotConfiguredIfThereIsNoHost () throws Exception {
150- HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
148+ final HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
151149
152150 this .urlInvoker //
153151 .withUrlParam ("http://url.com/" ) //
154152 .withProxyPort (123 ) //
155153 .configureProxy (mockedBuilder );
156-
157- // verify(mockedBuilder, times(0)).setProxy(Matchers.any());
158154 }
159155
160156 @ Test
161157 public void testThatProxyUserIsConfiguredIfItIsSet () throws Exception {
162- HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
158+ final HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
163159
164160 this .urlInvoker //
165161 .withUrlParam ("http://url.com/" ) //
@@ -168,37 +164,31 @@ public void testThatProxyUserIsConfiguredIfItIsSet() throws Exception {
168164 .withProxyUser (of ("u" )) //
169165 .withProxyPassword (of ("p" )) //
170166 .configureProxy (mockedBuilder );
171-
172- // verify(mockedBuilder,
173- // times(1)).setDefaultCredentialsProvider(Matchers.any());
174- // verify(mockedBuilder, times(1)).setProxy(Matchers.any());
175167 }
176168
177169 @ Test
178170 public void testThatProxyUserIsNotConfiguredIfNoPasswordSet () throws Exception {
179- HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
171+ final HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
180172
181173 this .urlInvoker //
182174 .withUrlParam ("http://url.com/" ) //
183175 .withProxyServer (of ("http://proxy.com/" )) //
184176 .withProxyPort (123 ) //
185177 .withProxyUser (of ("u" )) //
186178 .configureProxy (mockedBuilder );
187-
188- // verify(mockedBuilder,
189- // times(0)).setDefaultCredentialsProvider(Matchers.any());
190- // verify(mockedBuilder, times(1)).setProxy(Matchers.any());
191179 }
192180
193181 @ Test
194182 public void testThatSslCanBeConfigured () throws Exception {
195- HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
183+ final HttpClientBuilder mockedBuilder = mock (HttpClientBuilder .class );
184+ final ClientKeyStore clientKeyStore = mock (ClientKeyStore .class );
185+
186+ when (clientKeyStore .getKeyStore ()).thenReturn (Optional .absent ());
196187
197188 this .urlInvoker //
198189 .withUrlParam ("https://url.com/" ) //
190+ .withClientKeyStore (clientKeyStore ) //
199191 .configureSsl (mockedBuilder );
200-
201- // verify(mockedBuilder).setSSLSocketFactory(Matchers.any());
202192 }
203193
204194 @ Test
0 commit comments