use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class TestABCase5 method testCase5_19.
/**
* send text message fragmented in 5 frames, with 2 pings and wait between.
* @throws Exception on test failure
*/
@Test
@Slow
public void testCase5_19() throws Exception {
// phase 1
List<WebSocketFrame> send1 = new ArrayList<>();
send1.add(new TextFrame().setPayload("f1").setFin(false));
send1.add(new ContinuationFrame().setPayload(",f2").setFin(false));
send1.add(new PingFrame().setPayload("pong-1"));
List<WebSocketFrame> expect1 = new ArrayList<>();
expect1.add(new PongFrame().setPayload("pong-1"));
// phase 2
List<WebSocketFrame> send2 = new ArrayList<>();
send2.add(new ContinuationFrame().setPayload(",f3").setFin(false));
send2.add(new ContinuationFrame().setPayload(",f4").setFin(false));
send2.add(new PingFrame().setPayload("pong-2"));
send2.add(new ContinuationFrame().setPayload(",f5").setFin(true));
send2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect2 = new ArrayList<>();
expect2.add(new PongFrame().setPayload("pong-2"));
expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5"));
expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
// phase 1
fuzzer.send(send1);
fuzzer.expect(expect1);
// delay
TimeUnit.SECONDS.sleep(1);
// phase 2
fuzzer.send(send2);
fuzzer.expect(expect2);
}
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpClientTimeoutTest method testTimeoutIsCancelledOnSuccess.
@Slow
@Test
public void testTimeoutIsCancelledOnSuccess() throws Exception {
long timeout = 1000;
start(new TimeoutHandler(timeout));
final CountDownLatch latch = new CountDownLatch(1);
final byte[] content = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Request request = client.newRequest("localhost", connector.getLocalPort()).scheme(scheme).content(new InputStreamContentProvider(new ByteArrayInputStream(content))).timeout(2 * timeout, TimeUnit.MILLISECONDS);
request.send(new BufferingResponseListener() {
@Override
public void onComplete(Result result) {
Assert.assertFalse(result.isFailed());
Assert.assertArrayEquals(content, getContent());
latch.countDown();
}
});
Assert.assertTrue(latch.await(3 * timeout, TimeUnit.MILLISECONDS));
TimeUnit.MILLISECONDS.sleep(2 * timeout);
Assert.assertNull(request.getAbortCause());
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpClientTimeoutTest method testTimeoutOnQueuedRequest.
@Slow
@Test
public void testTimeoutOnQueuedRequest() throws Exception {
long timeout = 1000;
start(new TimeoutHandler(3 * timeout));
// Only one connection so requests get queued
client.setMaxConnectionsPerDestination(1);
// The first request has a long timeout
final CountDownLatch firstLatch = new CountDownLatch(1);
Request request = client.newRequest("localhost", connector.getLocalPort()).scheme(scheme).timeout(4 * timeout, TimeUnit.MILLISECONDS);
request.send(new Response.CompleteListener() {
@Override
public void onComplete(Result result) {
Assert.assertFalse(result.isFailed());
firstLatch.countDown();
}
});
// Second request has a short timeout and should fail in the queue
final CountDownLatch secondLatch = new CountDownLatch(1);
request = client.newRequest("localhost", connector.getLocalPort()).scheme(scheme).timeout(timeout, TimeUnit.MILLISECONDS);
request.send(new Response.CompleteListener() {
@Override
public void onComplete(Result result) {
Assert.assertTrue(result.isFailed());
secondLatch.countDown();
}
});
Assert.assertTrue(secondLatch.await(2 * timeout, TimeUnit.MILLISECONDS));
// The second request must fail before the first request has completed
Assert.assertTrue(firstLatch.getCount() > 0);
Assert.assertTrue(firstLatch.await(5 * timeout, TimeUnit.MILLISECONDS));
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpSenderOverHTTPTest method test_Send_NoRequestContent_IncompleteFlush.
@Slow
@Test
public void test_Send_NoRequestContent_IncompleteFlush() throws Exception {
ByteArrayEndPoint endPoint = new ByteArrayEndPoint("", 16);
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
connection.send(request, null);
// This take will free space in the buffer and allow for the write to complete
StringBuilder builder = new StringBuilder(endPoint.takeOutputString());
// Wait for the write to complete
TimeUnit.SECONDS.sleep(1);
String chunk = endPoint.takeOutputString();
while (chunk.length() > 0) {
builder.append(chunk);
chunk = endPoint.takeOutputString();
}
String requestString = builder.toString();
Assert.assertTrue(requestString.startsWith("GET "));
Assert.assertTrue(requestString.endsWith("\r\n\r\n"));
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpClientTimeoutTest method testTimeoutOnListenerWithExplicitConnection.
@Slow
@Test
public void testTimeoutOnListenerWithExplicitConnection() throws Exception {
long timeout = 1000;
start(new TimeoutHandler(2 * timeout));
final CountDownLatch latch = new CountDownLatch(1);
Destination destination = client.getDestination(scheme, "localhost", connector.getLocalPort());
FuturePromise<Connection> futureConnection = new FuturePromise<>();
destination.newConnection(futureConnection);
try (Connection connection = futureConnection.get(5, TimeUnit.SECONDS)) {
Request request = client.newRequest("localhost", connector.getLocalPort()).scheme(scheme).timeout(timeout, TimeUnit.MILLISECONDS);
connection.send(request, new Response.CompleteListener() {
@Override
public void onComplete(Result result) {
Assert.assertTrue(result.isFailed());
latch.countDown();
}
});
Assert.assertTrue(latch.await(3 * timeout, TimeUnit.MILLISECONDS));
}
}
Aggregations