connection.disconnect();
}
//Authenticate
connection = (HttpURLConnection) new URL("http://localhost:8080" + contextPath).openConnection();
String authentication = (new BASE64Encoder()).encode(("alan:starcraft").getBytes());
connection.setRequestProperty("Authorization", "Basic " + authentication);
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
assertEquals("Hello World", reader.readLine());