use of org.junit.Ignore in project webmagic by code4craft.
the class SpiderTest method testSpider.
@Ignore
@Test
public void testSpider() throws InterruptedException {
Spider me = Spider.create(new HuxiuProcessor()).addPipeline(new FilePipeline());
me.run();
}
use of org.junit.Ignore in project webmagic by code4craft.
the class DelayQueueSchedulerTest method test.
@Ignore("infinite")
@Test
public void test() {
DelayQueueScheduler delayQueueScheduler = new DelayQueueScheduler(1, TimeUnit.SECONDS);
delayQueueScheduler.push(new Request("1"), null);
while (true) {
Request poll = delayQueueScheduler.poll(null);
System.out.println(System.currentTimeMillis() + "\t" + poll);
}
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class FlowControlStrategyTest method testServerTwoDataFramesWithStalledStream.
// TODO
// Since we changed the API to disallow consecutive data() calls without waiting
// for the callback, it is now not possible to have DATA1, DATA2 in the queue for
// the same stream. Perhaps this test should just be deleted.
@Ignore
@Test
public void testServerTwoDataFramesWithStalledStream() throws Exception {
// Frames in queue = DATA1, DATA2.
// Server writes part of DATA1, then stalls.
// A window update unstalls the session, verify that the data is correctly sent.
Random random = new Random();
final byte[] chunk1 = new byte[1024];
random.nextBytes(chunk1);
final byte[] chunk2 = new byte[2048];
random.nextBytes(chunk2);
// Two SETTINGS frames: the initial after the preface,
// and the explicit where we set the stream window size to zero.
final AtomicReference<CountDownLatch> settingsLatch = new AtomicReference<>(new CountDownLatch(2));
final CountDownLatch dataLatch = new CountDownLatch(1);
start(new ServerSessionListener.Adapter() {
@Override
public void onSettings(Session session, SettingsFrame frame) {
settingsLatch.get().countDown();
}
@Override
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame) {
stream.data(new DataFrame(stream.getId(), ByteBuffer.wrap(chunk1), false), Callback.NOOP);
stream.data(new DataFrame(stream.getId(), ByteBuffer.wrap(chunk2), true), Callback.NOOP);
dataLatch.countDown();
return null;
}
});
Session session = newClient(new Session.Listener.Adapter());
Map<Integer, Integer> settings = new HashMap<>();
settings.put(SettingsFrame.INITIAL_WINDOW_SIZE, 0);
session.settings(new SettingsFrame(settings, false), Callback.NOOP);
Assert.assertTrue(settingsLatch.get().await(5, TimeUnit.SECONDS));
byte[] content = new byte[chunk1.length + chunk2.length];
final ByteBuffer buffer = ByteBuffer.wrap(content);
MetaData.Request metaData = newRequest("GET", new HttpFields());
HeadersFrame requestFrame = new HeadersFrame(metaData, null, true);
final CountDownLatch responseLatch = new CountDownLatch(1);
session.newStream(requestFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() {
@Override
public void onData(Stream stream, DataFrame frame, Callback callback) {
buffer.put(frame.getData());
callback.succeeded();
if (frame.isEndStream())
responseLatch.countDown();
}
});
Assert.assertTrue(dataLatch.await(5, TimeUnit.SECONDS));
// Now we have the 2 DATA frames queued in the server.
// Unstall the stream window.
settingsLatch.set(new CountDownLatch(1));
settings.clear();
settings.put(SettingsFrame.INITIAL_WINDOW_SIZE, chunk1.length / 2);
session.settings(new SettingsFrame(settings, false), Callback.NOOP);
Assert.assertTrue(settingsLatch.get().await(5, TimeUnit.SECONDS));
Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS));
// Check that the data is sent correctly.
byte[] expected = new byte[content.length];
System.arraycopy(chunk1, 0, expected, 0, chunk1.length);
System.arraycopy(chunk2, 0, expected, chunk1.length, chunk2.length);
Assert.assertArrayEquals(expected, content);
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class ThreadMonitorTest method monitorTest.
@Ignore
@Test
public void monitorTest() throws Exception {
try (StacklessLogging stackless = new StacklessLogging(ThreadMonitor.class)) {
final AtomicInteger countLogs = new AtomicInteger(0);
final AtomicInteger countSpin = new AtomicInteger(0);
ThreadMonitor monitor = new ThreadMonitor(1000, 50, 1, 1) {
@Override
protected void logThreadInfo(boolean logAll) {
if (logAll)
countLogs.incrementAndGet();
else
countSpin.incrementAndGet();
super.logThreadInfo(logAll);
}
};
monitor.setDumpable(new Dumpable() {
public void dump(Appendable out, String indent) throws IOException {
out.append(dump());
}
public String dump() {
return "Dump Spinning";
}
});
monitor.logCpuUsage(2000, 0);
monitor.start();
Random rnd = new Random();
for (long cnt = 0; cnt < 100; cnt++) {
long value = rnd.nextLong() % 50 + 50;
Sleeper sleeper = new Sleeper(value);
Thread runner = new Thread(sleeper);
runner.setDaemon(true);
runner.start();
}
Spinner spinner = new Spinner();
Thread runner = new Thread(spinner);
runner.start();
Thread.sleep(DURATION);
spinner.setDone();
monitor.stop();
assertTrue(countLogs.get() >= 1);
assertTrue(countSpin.get() >= 2);
}
}
use of org.junit.Ignore in project jetty.project by eclipse.
the class ConnectorTimeoutTest method testBlockingTimeoutRead.
@Test(timeout = 60000)
// TODO make more stable
@Ignore
public void testBlockingTimeoutRead() throws Exception {
_httpConfiguration.setBlockingTimeout(750L);
configureServer(new EchoHandler());
Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort());
client.setSoTimeout(10000);
InputStream is = client.getInputStream();
Assert.assertFalse(client.isClosed());
OutputStream os = client.getOutputStream();
os.write(("GET / HTTP/1.1\r\n" + "host: " + _serverURI.getHost() + ":" + _serverURI.getPort() + "\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain\r\n" + "Connection: close\r\n" + "\r\n" + "5\r\n" + "LMNOP\r\n").getBytes("utf-8"));
os.flush();
long start = System.currentTimeMillis();
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class)) {
Thread.sleep(300);
os.write("1".getBytes("utf-8"));
os.flush();
Thread.sleep(300);
os.write("0".getBytes("utf-8"));
os.flush();
Thread.sleep(300);
os.write("\r".getBytes("utf-8"));
os.flush();
Thread.sleep(300);
os.write("\n".getBytes("utf-8"));
os.flush();
Thread.sleep(300);
os.write("0123456789ABCDEF\r\n".getBytes("utf-8"));
os.write("0\r\n".getBytes("utf-8"));
os.write("\r\n".getBytes("utf-8"));
os.flush();
} catch (Exception e) {
}
long duration = System.currentTimeMillis() - start;
Assert.assertThat(duration, Matchers.greaterThan(500L));
try {
// read the response
String response = IO.toString(is);
Assert.assertThat(response, Matchers.startsWith("HTTP/1.1 500 "));
Assert.assertThat(response, Matchers.containsString("InterruptedIOException"));
} catch (SSLException e) {
}
}
Aggregations