use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class ManyConnectionsCleanupTest method fastFail.
private void fastFail() throws Exception {
try (IBlockheadClient client = new BlockheadClient(server.getServerUri())) {
client.setProtocols("fastfail");
client.setTimeout(1, TimeUnit.SECONDS);
try (StacklessLogging scope = new StacklessLogging(WebSocketSession.class)) {
client.connect();
client.sendStandardRequest();
client.expectUpgradeResponse();
// client.readFrames(1,2,TimeUnit.SECONDS);
CloseInfo close = new CloseInfo(StatusCode.NORMAL, "Normal");
// respond with close
client.write(close.asFrame());
// ensure server socket got close event
assertThat("Fast Fail Latch", closeSocket.closeLatch.await(1, TimeUnit.SECONDS), is(true));
assertThat("Fast Fail.statusCode", closeSocket.closeStatusCode, is(StatusCode.SERVER_ERROR));
assertThat("Fast Fail.errors", closeSocket.errors.size(), is(1));
}
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class TestABCase2 method testCase2_5.
/**
* Ping with 126 byte binary payload
* @throws Exception on test failure
*/
@Test
public void testCase2_5() throws Exception {
try (StacklessLogging scope = new StacklessLogging(Parser.class)) {
// intentionally too big
byte[] payload = new byte[126];
Arrays.fill(payload, (byte) '5');
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
// trick websocket frame into making extra large payload for ping
send.add(new BadFrame(OpCode.PING).setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL, "Test 2.5").asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class HttpClientTest method testEarlyEOF.
@Test
public void testEarlyEOF() throws Exception {
start(new AbstractHandler() {
@Override
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
baseRequest.setHandled(true);
// Promise some content, then flush the headers, then fail to send the content.
response.setContentLength(16);
response.flushBuffer();
throw new NullPointerException("Explicitly thrown by test");
}
});
try (StacklessLogging stackless = new StacklessLogging(org.eclipse.jetty.server.HttpChannel.class)) {
client.newRequest("localhost", connector.getLocalPort()).scheme(scheme).timeout(60, TimeUnit.SECONDS).send();
Assert.fail();
} catch (ExecutionException x) {
// Expected.
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class AsyncServletTest method testAsyncNotSupportedAsync.
@Test
public void testAsyncNotSupportedAsync() throws Exception {
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class)) {
_expectedCode = "500 ";
String response = process("noasync", "start=200", null);
Assert.assertThat(response, Matchers.startsWith("HTTP/1.1 500 "));
assertThat(__history, contains("REQUEST /ctx/noasync/info", "initial", "ERROR /ctx/error/custom", "!initial"));
assertContains("500", response);
assertContains("!asyncSupported", response);
assertContains("AsyncServletTest$AsyncServlet", response);
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class PostServletTest method testBadSplitPost.
@Test
public void testBadSplitPost() throws Exception {
StringBuilder req = new StringBuilder();
req.append("POST /post HTTP/1.1\r\n");
req.append("Host: localhost\r\n");
req.append("Connection: close\r\n");
req.append("Transfer-Encoding: chunked\r\n");
req.append("\r\n");
req.append("6\r\n");
req.append("Hello ");
req.append("\r\n");
try (StacklessLogging scope = new StacklessLogging(ServletHandler.class)) {
LocalConnector.LocalEndPoint endp = connector.executeRequest(req.toString());
req.setLength(0);
while (!posted.get()) Thread.sleep(100);
Thread.sleep(100);
req.append("x\r\n");
req.append("World\n");
req.append("\r\n");
req.append("0\r\n");
req.append("\r\n");
endp.addInput(req.toString());
endp.waitUntilClosedOrIdleFor(1, TimeUnit.SECONDS);
String resp = endp.takeOutputString();
assertThat("resp", resp, containsString("HTTP/1.1 200 "));
// aborted
assertThat("resp", resp, not(containsString("\r\n0\r\n")));
}
assertTrue(complete.await(5, TimeUnit.SECONDS));
assertThat(ex0.get(), not(nullValue()));
assertThat(ex1.get(), not(nullValue()));
}
Aggregations