|
| 1 | +/* |
| 2 | + * Jooby https://jooby.io |
| 3 | + * Apache License Version 2.0 https://jooby.io/LICENSE.txt |
| 4 | + * Copyright 2014 Edgar Espina |
| 5 | + */ |
| 6 | +package tests.i3786; |
| 7 | + |
| 8 | +import static org.junit.jupiter.api.Assertions.*; |
| 9 | + |
| 10 | +import org.junit.jupiter.api.Test; |
| 11 | + |
| 12 | +import io.jooby.apt.ProcessorRunner; |
| 13 | +import io.jooby.test.MockContext; |
| 14 | +import io.jooby.test.MockRouter; |
| 15 | + |
| 16 | +public class Issue3786 { |
| 17 | + @Test |
| 18 | + public void shouldCheckBase() throws Exception { |
| 19 | + new ProcessorRunner(new C3786()) |
| 20 | + .withRouter( |
| 21 | + app -> { |
| 22 | + var router = new MockRouter(app); |
| 23 | + assertEquals("base", router.get("/inherited", new MockContext()).value()); |
| 24 | + assertEquals( |
| 25 | + "withPath", router.get("/inherited/withPath", new MockContext()).value()); |
| 26 | + assertEquals("base: 123", router.get("/inherited/123", new MockContext()).value()); |
| 27 | + assertEquals( |
| 28 | + "GET/inherited/childOnly", |
| 29 | + router.get("/inherited/childOnly", new MockContext()).value()); |
| 30 | + assertEquals( |
| 31 | + "POST/inherited/childOnly", |
| 32 | + router.post("/inherited/childOnly", new MockContext()).value()); |
| 33 | + }); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void shouldCheckOverride() throws Exception { |
| 38 | + new ProcessorRunner(new D3786()) |
| 39 | + .withRouter( |
| 40 | + app -> { |
| 41 | + var router = new MockRouter(app); |
| 42 | + assertEquals("base", router.get("/overrideMethod", new MockContext()).value()); |
| 43 | + assertEquals( |
| 44 | + "withPath", router.get("/overrideMethod/withPath", new MockContext()).value()); |
| 45 | + assertEquals( |
| 46 | + "base: 123", router.get("/overrideMethod/123", new MockContext()).value()); |
| 47 | + assertEquals( |
| 48 | + "/overrideMethod/childOnly", |
| 49 | + router.get("/overrideMethod/childOnly", new MockContext()).value()); |
| 50 | + assertEquals( |
| 51 | + "/overrideMethod/user", |
| 52 | + router.post("/overrideMethod/user", new MockContext()).value()); |
| 53 | + }); |
| 54 | + } |
| 55 | +} |
0 commit comments