This repository was archived by the owner on Mar 3, 2026. It is now read-only.
forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryStringTest.java
More file actions
63 lines (49 loc) · 1.52 KB
/
Copy pathQueryStringTest.java
File metadata and controls
63 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package apps;
import io.jooby.App;
import io.jooby.AppTest;
import io.jooby.WebClient;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@AppTest
public class QueryStringTest extends App {
{
get("/", ctx -> ctx.query().raw());
get("/queryStringMap", ctx -> ctx.query().toMap());
get("/search", ctx -> ctx.query("q").value());
get("/searchList", ctx -> ctx.query("q").toList());
}
@Test
public void queryString(WebClient client) throws IOException {
client.get("/?", rsp -> {
assertEquals("", rsp.body().string());
});
client.get("/?q", rsp -> {
assertEquals("q", rsp.body().string());
});
client.get("/?foo=1&bar=2", rsp -> {
assertEquals("foo=1&bar=2", rsp.body().string());
});
}
@Test
public void queryStringMap(WebClient client) throws IOException {
client.get("/queryStringMap?", rsp -> {
assertEquals("{}", rsp.body().string());
});
client.get("/queryStringMap?q", rsp -> {
assertEquals("{q=[]}", rsp.body().string());
});
client.get("/queryStringMap?foo=1&bar=2", rsp -> {
assertEquals("{foo=[1], bar=[2]}", rsp.body().string());
});
}
@Test
public void queryParam(WebClient client) throws IOException {
client.get("/search?q=find something", rsp -> {
assertEquals("find something", rsp.body().string());
});
client.get("/searchList?q=foo&q=bar", rsp -> {
assertEquals("[foo, bar]", rsp.body().string());
});
}
}