Skip to content

Commit

Permalink
Tests #4577 IPAccessHandler target
Browse files Browse the repository at this point in the history
Updates from review.

Signed-off-by: Greg Wilkins <[email protected]>
  • Loading branch information
gregw committed Feb 21, 2020
1 parent 80e481e commit d95f2fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@
* internet address. Both of these features have been deprecated in the current version.
*
* @see InetAccessHandler
* @deprecated
* @deprecated Use @{@link InetAccessHandler}.
*/
@Deprecated
public class IPAccessHandler extends HandlerWrapper
{
private static final Logger LOG = Log.getLogger(IPAccessHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@

public class IPAccessHandlerTest
{
private static Server _server;
private static NetworkConnector _connector;
private static IPAccessHandler _handler;
private Server _server;
private NetworkConnector _connector;
private IPAccessHandler _handler;

@BeforeEach
public void setUp()
Expand Down Expand Up @@ -115,9 +115,8 @@ public void testHandler(String white, String black, String host, String uri, Str
String request = "GET " + uri + " HTTP/1.1\n" + "Host: " + host + "\n\n";
Socket socket = new Socket("127.0.0.1", _connector.getLocalPort());
socket.setSoTimeout(5000);
try
try (OutputStream output = socket.getOutputStream();)
{
OutputStream output = socket.getOutputStream();
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));

output.write(request.getBytes(StandardCharsets.UTF_8));
Expand All @@ -130,10 +129,6 @@ public void testHandler(String white, String black, String host, String uri, Str
};
assertEquals(code, response.getCode(), Arrays.deepToString(params));
}
finally
{
socket.close();
}
}

@ParameterizedTest
Expand All @@ -153,9 +148,8 @@ public void testContext(String white, String black, String host, String uri, Str
String request = "GET /ctx" + uri + " HTTP/1.1\n" + "Host: " + host + "\n\n";
Socket socket = new Socket("127.0.0.1", _connector.getLocalPort());
socket.setSoTimeout(5000);
try
try (OutputStream output = socket.getOutputStream();)
{
OutputStream output = socket.getOutputStream();
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));

output.write(request.getBytes(StandardCharsets.UTF_8));
Expand All @@ -168,10 +162,6 @@ public void testContext(String white, String black, String host, String uri, Str
};
assertEquals(code, response.getCode(), Arrays.deepToString(params));
}
finally
{
socket.close();
}
}

protected Response readResponse(BufferedReader reader)
Expand Down

0 comments on commit d95f2fb

Please sign in to comment.