|
|
|
|
@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
public class EndpointHandlerMappingTests { |
|
|
|
|
|
|
|
|
|
private final StaticApplicationContext context = new StaticApplicationContext(); |
|
|
|
|
|
|
|
|
|
private Method method; |
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
@ -50,8 +51,8 @@ public class EndpointHandlerMappingTests {
@@ -50,8 +51,8 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void withoutPrefix() throws Exception { |
|
|
|
|
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("/b")); |
|
|
|
|
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("a")); |
|
|
|
|
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("b")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpointA, endpointB)); |
|
|
|
|
mapping.setApplicationContext(this.context); |
|
|
|
|
@ -65,8 +66,8 @@ public class EndpointHandlerMappingTests {
@@ -65,8 +66,8 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void withPrefix() throws Exception { |
|
|
|
|
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("/b")); |
|
|
|
|
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("a")); |
|
|
|
|
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("b")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpointA, endpointB)); |
|
|
|
|
mapping.setApplicationContext(this.context); |
|
|
|
|
@ -81,7 +82,7 @@ public class EndpointHandlerMappingTests {
@@ -81,7 +82,7 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test(expected = HttpRequestMethodNotSupportedException.class) |
|
|
|
|
public void onlyGetHttpMethodForNonActionEndpoints() throws Exception { |
|
|
|
|
TestActionEndpoint endpoint = new TestActionEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestActionEndpoint endpoint = new TestActionEndpoint(new TestEndpoint("a")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpoint)); |
|
|
|
|
mapping.setApplicationContext(this.context); |
|
|
|
|
@ -92,7 +93,7 @@ public class EndpointHandlerMappingTests {
@@ -92,7 +93,7 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void postHttpMethodForActionEndpoints() throws Exception { |
|
|
|
|
TestActionEndpoint endpoint = new TestActionEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestActionEndpoint endpoint = new TestActionEndpoint(new TestEndpoint("a")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpoint)); |
|
|
|
|
mapping.setApplicationContext(this.context); |
|
|
|
|
@ -102,7 +103,7 @@ public class EndpointHandlerMappingTests {
@@ -102,7 +103,7 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test(expected = HttpRequestMethodNotSupportedException.class) |
|
|
|
|
public void onlyPostHttpMethodForActionEndpoints() throws Exception { |
|
|
|
|
TestActionEndpoint endpoint = new TestActionEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestActionEndpoint endpoint = new TestActionEndpoint(new TestEndpoint("a")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpoint)); |
|
|
|
|
mapping.setApplicationContext(this.context); |
|
|
|
|
@ -113,7 +114,7 @@ public class EndpointHandlerMappingTests {
@@ -113,7 +114,7 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void disabled() throws Exception { |
|
|
|
|
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpoint)); |
|
|
|
|
mapping.setDisabled(true); |
|
|
|
|
@ -124,8 +125,8 @@ public class EndpointHandlerMappingTests {
@@ -124,8 +125,8 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void duplicatePath() throws Exception { |
|
|
|
|
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestActionEndpoint other = new TestActionEndpoint(new TestEndpoint("/a")); |
|
|
|
|
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a")); |
|
|
|
|
TestActionEndpoint other = new TestActionEndpoint(new TestEndpoint("a")); |
|
|
|
|
EndpointHandlerMapping mapping = new EndpointHandlerMapping( |
|
|
|
|
Arrays.asList(endpoint, other)); |
|
|
|
|
mapping.setDisabled(true); |
|
|
|
|
@ -141,8 +142,8 @@ public class EndpointHandlerMappingTests {
@@ -141,8 +142,8 @@ public class EndpointHandlerMappingTests {
|
|
|
|
|
|
|
|
|
|
private static class TestEndpoint extends AbstractEndpoint<Object> { |
|
|
|
|
|
|
|
|
|
TestEndpoint(String path) { |
|
|
|
|
super(path); |
|
|
|
|
TestEndpoint(String id) { |
|
|
|
|
super(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|