use of org.apache.hyracks.http.servlet.SlowServlet in project asterixdb by apache.
the class HttpServerTest method testOverloadingServer.
@Test
public void testOverloadingServer() throws Exception {
WebManager webMgr = new WebManager();
HttpServer server = new HttpServer(webMgr.getBosses(), webMgr.getWorkers(), PORT, NUM_EXECUTOR_THREADS, SERVER_QUEUE_SIZE);
SlowServlet servlet = new SlowServlet(server.ctx(), new String[] { PATH });
server.addServlet(servlet);
webMgr.add(server);
webMgr.start();
try {
request(NUM_OF_REQUESTS);
for (Thread thread : THREADS) {
thread.join();
}
Assert.assertEquals(32, SUCCESS_COUNT.get());
Assert.assertEquals(16, UNAVAILABLE_COUNT.get());
Assert.assertEquals(0, OTHER_COUNT.get());
} finally {
webMgr.stop();
}
}
use of org.apache.hyracks.http.servlet.SlowServlet in project asterixdb by apache.
the class HttpServerTest method testMalformedString.
@Test
public void testMalformedString() throws Exception {
WebManager webMgr = new WebManager();
HttpServer server = new HttpServer(webMgr.getBosses(), webMgr.getWorkers(), PORT, NUM_EXECUTOR_THREADS, SERVER_QUEUE_SIZE);
SlowServlet servlet = new SlowServlet(server.ctx(), new String[] { PATH });
server.addServlet(servlet);
webMgr.add(server);
webMgr.start();
try {
StringBuilder response = new StringBuilder();
try (Socket s = new Socket(InetAddress.getLocalHost(), PORT)) {
PrintWriter pw = new PrintWriter(s.getOutputStream());
pw.println("GET /?handle=%7B%22handle%22%3A%5B0%2C%200%5D%7 HTTP/1.1");
pw.println("Host: 127.0.0.1");
pw.println();
pw.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
response.append(line).append('\n');
}
br.close();
}
String output = response.toString();
Assert.assertTrue(output.contains(HttpResponseStatus.BAD_REQUEST.toString()));
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
webMgr.stop();
}
}
Aggregations