use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpClientStreamTest method testUploadWithDeferredContentProviderFromInputStream.
@Slow
@Test
public void testUploadWithDeferredContentProviderFromInputStream() 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);
IO.copy(request.getInputStream(), new ByteArrayOutputStream());
}
});
final CountDownLatch latch = new CountDownLatch(1);
try (DeferredContentProvider content = new DeferredContentProvider()) {
client.newRequest("localhost", connector.getLocalPort()).scheme(getScheme()).content(content).send(result -> {
if (result.isSucceeded() && result.getResponse().getStatus() == 200)
latch.countDown();
});
// Make sure we provide the content *after* the request has been "sent".
Thread.sleep(1000);
try (ByteArrayInputStream input = new ByteArrayInputStream(new byte[1024])) {
byte[] buffer = new byte[200];
int read;
while ((read = input.read(buffer)) >= 0) content.offer(ByteBuffer.wrap(buffer, 0, read));
}
}
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpClientContinueTest method test_Expect100Continue_WithDeferredContent_Respond100Continue.
@Slow
@Test
public void test_Expect100Continue_WithDeferredContent_Respond100Continue() throws Exception {
start(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
baseRequest.setHandled(true);
// Send 100-Continue and echo the content
IO.copy(request.getInputStream(), response.getOutputStream());
}
});
final byte[] chunk1 = new byte[] { 0, 1, 2, 3 };
final byte[] chunk2 = new byte[] { 4, 5, 6, 7 };
final byte[] data = new byte[chunk1.length + chunk2.length];
System.arraycopy(chunk1, 0, data, 0, chunk1.length);
System.arraycopy(chunk2, 0, data, chunk1.length, chunk2.length);
final CountDownLatch latch = new CountDownLatch(1);
DeferredContentProvider content = new DeferredContentProvider();
client.newRequest(newURI()).header(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE.asString()).content(content).send(new BufferingResponseListener() {
@Override
public void onComplete(Result result) {
Assert.assertArrayEquals(data, getContent());
latch.countDown();
}
});
Thread.sleep(1000);
content.offer(ByteBuffer.wrap(chunk1));
Thread.sleep(1000);
content.offer(ByteBuffer.wrap(chunk2));
content.close();
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class HttpClientTest method testRequestIdleTimeout.
@Slow
@Test
public void testRequestIdleTimeout() throws Exception {
final long idleTimeout = 1000;
start(new AbstractHandler() {
@Override
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
try {
baseRequest.setHandled(true);
TimeUnit.MILLISECONDS.sleep(2 * idleTimeout);
} catch (InterruptedException x) {
throw new ServletException(x);
}
}
});
final String host = "localhost";
final int port = connector.getLocalPort();
try {
client.newRequest(host, port).scheme(scheme).idleTimeout(idleTimeout, TimeUnit.MILLISECONDS).timeout(3 * idleTimeout, TimeUnit.MILLISECONDS).send();
Assert.fail();
} catch (ExecutionException expected) {
Assert.assertTrue(expected.getCause() instanceof TimeoutException);
}
// Make another request without specifying the idle timeout, should not fail
ContentResponse response = client.newRequest(host, port).scheme(scheme).timeout(3 * idleTimeout, TimeUnit.MILLISECONDS).send();
Assert.assertNotNull(response);
Assert.assertEquals(200, response.getStatus());
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class QueuedThreadPoolTest method testShrink.
@Test
@Slow
public void testShrink() throws Exception {
final AtomicInteger sleep = new AtomicInteger(100);
Runnable job = new Runnable() {
public void run() {
try {
Thread.sleep(sleep.get());
} catch (Exception e) {
e.printStackTrace();
}
}
};
QueuedThreadPool tp = new QueuedThreadPool();
tp.setMinThreads(2);
tp.setMaxThreads(10);
tp.setIdleTimeout(400);
tp.setThreadsPriority(Thread.NORM_PRIORITY - 1);
tp.start();
waitForIdle(tp, 2);
waitForThreads(tp, 2);
sleep.set(200);
tp.execute(job);
tp.execute(job);
for (int i = 0; i < 20; i++) tp.execute(job);
waitForThreads(tp, 10);
waitForIdle(tp, 0);
sleep.set(5);
for (int i = 0; i < 500; i++) {
tp.execute(job);
Thread.sleep(10);
}
waitForThreads(tp, 2);
waitForIdle(tp, 2);
}
use of org.eclipse.jetty.toolchain.test.annotation.Slow in project jetty.project by eclipse.
the class SchedulerTest method testBenchmark.
@Test
@Slow
@Ignore
public void testBenchmark() throws Exception {
schedule(2000, 10000, 2000, 50);
PlatformMonitor benchmark = new PlatformMonitor();
PlatformMonitor.Start start = benchmark.start();
System.err.println(start);
System.err.println(_scheduler);
schedule(2000, 30000, 2000, 50);
PlatformMonitor.Stop stop = benchmark.stop();
System.err.println(stop);
}
Aggregations