Search in sources :

Example 21 with Ignore

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();
}
Also used : FilePipeline(us.codecraft.webmagic.pipeline.FilePipeline) HuxiuProcessor(us.codecraft.webmagic.samples.HuxiuProcessor) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 22 with Ignore

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);
    }
}
Also used : Request(us.codecraft.webmagic.Request) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with Ignore

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);
}
Also used : ServerSessionListener(org.eclipse.jetty.http2.api.server.ServerSessionListener) HashMap(java.util.HashMap) HeadersFrame(org.eclipse.jetty.http2.frames.HeadersFrame) SettingsFrame(org.eclipse.jetty.http2.frames.SettingsFrame) Random(java.util.Random) MetaData(org.eclipse.jetty.http.MetaData) HttpFields(org.eclipse.jetty.http.HttpFields) HTTP2Stream(org.eclipse.jetty.http2.HTTP2Stream) Stream(org.eclipse.jetty.http2.api.Stream) AtomicReference(java.util.concurrent.atomic.AtomicReference) DataFrame(org.eclipse.jetty.http2.frames.DataFrame) CountDownLatch(java.util.concurrent.CountDownLatch) ByteBuffer(java.nio.ByteBuffer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FuturePromise(org.eclipse.jetty.util.FuturePromise) Promise(org.eclipse.jetty.util.Promise) Callback(org.eclipse.jetty.util.Callback) FutureCallback(org.eclipse.jetty.util.FutureCallback) ServerSessionListener(org.eclipse.jetty.http2.api.server.ServerSessionListener) HTTP2Session(org.eclipse.jetty.http2.HTTP2Session) Session(org.eclipse.jetty.http2.api.Session) ISession(org.eclipse.jetty.http2.ISession) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with Ignore

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);
    }
}
Also used : Random(java.util.Random) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) IOException(java.io.IOException) Dumpable(org.eclipse.jetty.util.component.Dumpable) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 25 with Ignore

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) {
    }
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) SSLException(javax.net.ssl.SSLException) Socket(java.net.Socket) ServletException(javax.servlet.ServletException) SocketException(java.net.SocketException) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Ignore (org.junit.Ignore)5092 Test (org.junit.Test)4807 File (java.io.File)445 ArrayList (java.util.ArrayList)374 IOException (java.io.IOException)217 HashMap (java.util.HashMap)187 List (java.util.List)171 CountDownLatch (java.util.concurrent.CountDownLatch)118 Map (java.util.Map)103 LocalDate (java.time.LocalDate)94 Dataset (org.apache.jena.query.Dataset)93 InputStream (java.io.InputStream)89 Date (java.util.Date)88 Random (java.util.Random)85 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)83 Properties (java.util.Properties)78 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)78 HashSet (java.util.HashSet)71 ByteArrayOutputStream (java.io.ByteArrayOutputStream)70 ExecutorService (java.util.concurrent.ExecutorService)70