コード例 #1
0
  @Test
  public void testWithInvalidEncoding() {
    On.get("/").json(req -> U.map("uri", req.uri(), "query", req.query(), "data", req.data()));

    String resp =
        Msc.connect(
            "localhost",
            8888,
            (in, reader, out) -> {
              out.writeBytes("GET /?a=[%A%]&b=bb!&c=%&d=%% HTTP/1.0\n\n");
              return Flow.of(reader.lines()).findLast().get();
            });

    verify(resp);
  }
コード例 #2
0
  @Test
  public void testSyncAsyncMix() {

    On.get("/")
        .plain(
            (Resp resp, Integer n) -> {
              if (n % 2 == 0) return n;

              return Jobs.after(3, TimeUnit.MILLISECONDS).run(() -> resp.result(n * 10).done());
            });

    for (int i = 0; i < ROUNDS; i++) {
      int expected = i % 2 == 0 ? i : i * 10;
      Self.get("/?n=" + i).expect("" + expected);
    }
  }