@@ -81,8 +81,6 @@ void crossHostRedirectStripsAuthHeaders() throws Exception {
8181 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
8282 .build ();
8383
84- // Mock chain to get client without proxy
85- Interceptor .Chain chain = mock (Interceptor .Chain .class );
8684
8785 RedirectHandlerOption option = new RedirectHandlerOption ();
8886 Request result = new RedirectHandler ().getRedirect (original , redirect , option );
@@ -136,16 +134,14 @@ void sameHostRedirectKeepsAllHeaders() throws Exception {
136134 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
137135 .build ();
138136
139- // Mock chain with proxy
140- Interceptor .Chain chain = mock (Interceptor .Chain .class );
137+ // Setup proxy selector
141138 ProxySelector proxySelector = mock (ProxySelector .class );
142139 Proxy proxy = new Proxy (Proxy .Type .HTTP , new InetSocketAddress ("proxy.example.com" , 8080 ));
143140 when (proxySelector .select (any (URI .class ))).thenReturn (Collections .singletonList (proxy ));
144141
145142 RedirectHandlerOption option = new RedirectHandlerOption ();
146143 Request result =
147- new RedirectHandler (option , proxySelector )
148- .getRedirect (original , redirect , option );
144+ new RedirectHandler (option , proxySelector ).getRedirect (original , redirect , option );
149145
150146 assertNotNull (result );
151147 assertEquals ("trusted.example.com" , result .url ().host ());
@@ -173,16 +169,14 @@ void crossHostRedirectWithProxyKeepsProxyAuth() throws Exception {
173169 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
174170 .build ();
175171
176- // Mock chain with active proxy
177- Interceptor .Chain chain = mock (Interceptor .Chain .class );
172+ // Setup proxy selector with active proxy
178173 ProxySelector proxySelector = mock (ProxySelector .class );
179174 Proxy proxy = new Proxy (Proxy .Type .HTTP , new InetSocketAddress ("proxy.example.com" , 8080 ));
180175 when (proxySelector .select (any (URI .class ))).thenReturn (Collections .singletonList (proxy ));
181176
182177 RedirectHandlerOption option = new RedirectHandlerOption ();
183178 Request result =
184- new RedirectHandler (option , proxySelector )
185- .getRedirect (original , redirect , option );
179+ new RedirectHandler (option , proxySelector ).getRedirect (original , redirect , option );
186180
187181 assertNotNull (result );
188182 assertEquals ("other.example.com" , result .url ().host ());
@@ -211,16 +205,14 @@ void crossHostRedirectWithDirectProxyStripsProxyAuth() throws Exception {
211205 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
212206 .build ();
213207
214- // Mock chain with DIRECT proxy (no proxy)
215- Interceptor .Chain chain = mock (Interceptor .Chain .class );
208+ // Setup proxy selector with DIRECT proxy (no proxy)
216209 ProxySelector proxySelector = mock (ProxySelector .class );
217210 when (proxySelector .select (any (URI .class )))
218211 .thenReturn (Collections .singletonList (Proxy .NO_PROXY ));
219212
220213 RedirectHandlerOption option = new RedirectHandlerOption ();
221214 Request result =
222- new RedirectHandler (option , proxySelector )
223- .getRedirect (original , redirect , option );
215+ new RedirectHandler (option , proxySelector ).getRedirect (original , redirect , option );
224216
225217 assertNotNull (result );
226218 assertEquals ("other.example.com" , result .url ().host ());
@@ -252,8 +244,6 @@ void schemeChangeStripsAuthHeaders() throws Exception {
252244 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
253245 .build ();
254246
255- // Mock chain without proxy
256- Interceptor .Chain chain = mock (Interceptor .Chain .class );
257247
258248 RedirectHandlerOption option = new RedirectHandlerOption ();
259249 Request result = new RedirectHandler ().getRedirect (original , redirect , option );
@@ -284,8 +274,6 @@ void redirectWithDifferentPortRemovesAuthAndCookie() throws Exception {
284274 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
285275 .build ();
286276
287- // Mock chain without proxy
288- Interceptor .Chain chain = mock (Interceptor .Chain .class );
289277
290278 RedirectHandlerOption option = new RedirectHandlerOption ();
291279 Request result = new RedirectHandler ().getRedirect (original , redirect , option );
@@ -315,8 +303,6 @@ void redirectWithSamePortKeepsAuthAndCookie() throws Exception {
315303 .body (ResponseBody .create ("" , MediaType .parse ("text/plain" )))
316304 .build ();
317305
318- // Mock chain without proxy
319- Interceptor .Chain chain = mock (Interceptor .Chain .class );
320306
321307 RedirectHandlerOption option = new RedirectHandlerOption ();
322308 Request result = new RedirectHandler ().getRedirect (original , redirect , option );
@@ -352,9 +338,6 @@ void customScrubberIsUsed() throws Exception {
352338 // Don't remove any headers
353339 };
354340
355- // Mock chain
356- Interceptor .Chain chain = mock (Interceptor .Chain .class );
357-
358341 RedirectHandlerOption option = new RedirectHandlerOption (5 , null , customScrubber );
359342 Request result = new RedirectHandler ().getRedirect (original , redirect , option );
360343
@@ -395,7 +378,6 @@ void customScrubberRemovesCustomHeaders() throws Exception {
395378 requestBuilder .removeHeader ("X-Api-Key" );
396379 };
397380
398- Interceptor .Chain chain = mock (Interceptor .Chain .class );
399381
400382 RedirectHandlerOption option = new RedirectHandlerOption (5 , null , customScrubber );
401383 Request result = new RedirectHandler ().getRedirect (original , redirect , option );
0 commit comments