Skip to content

Commit 25e1336

Browse files
committed
Add test for splats with Jex
1 parent 1684aaf commit 25e1336

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

tests/test-jex/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<properties>
1818
<main.class>org.example.myapp.Main</main.class>
19-
<jex.version>1.0</jex.version>
19+
<jex.version>1.2</jex.version>
2020
<swagger.version>2.0.8</swagger.version>
2121
<jackson.version>2.12.0</jackson.version>
2222
<avaje-http-version>1.3-SNAPSHOT</avaje-http-version>

tests/test-jex/src/main/java/org/example/web/HelloController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import io.avaje.http.api.Get;
55
import io.avaje.http.api.Path;
66
import io.avaje.http.api.Produces;
7+
import io.avaje.jex.Context;
78

89
@Controller
910
@Path("/")
1011
public class HelloController {
1112

1213
@Get
1314
HelloDto getHello() {
14-
HelloDto dto= new HelloDto();
15+
HelloDto dto = new HelloDto();
1516
dto.id = 42;
1617
dto.name = "rob";
1718
return dto;
@@ -26,6 +27,12 @@ String getText() {
2627
@Produces("text/plain")
2728
@Get("other/{name}")
2829
String name(String name) {
29-
return "hi "+name;
30+
return "hi " + name;
31+
}
32+
33+
@Produces("text/plain")
34+
@Get("splat/{name}/*/other/*")
35+
String splat(String name, Context ctx) {
36+
return "got name:" + name + " splat0:" + ctx.splat(0) + " splat1:" + ctx.splat(1);
3037
}
3138
}

tests/test-jex/src/test/java/org/example/web/HelloControllerTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ void getName() {
3535
assertEquals("hi bazz", client.request().path("other/bazz").get().asString().body());
3636
assertEquals("hi bax", client.request().path("other/bax").get().asString().body());
3737
}
38+
39+
@Test
40+
void splat() {
41+
assertEquals("got name:one splat0:a/b splat1:x/y/z", client.request().path("splat/one/a/b/other/x/y/z").get().asString().body());
42+
}
3843
}

0 commit comments

Comments
 (0)