@@ -42,6 +42,18 @@ public void redirect() throws Exception {
42
42
redirectedUrl ("/resource/1" ).match (getRedirectedUrlStubMvcResult ("/resource/1" ));
43
43
}
44
44
45
+ @ Test
46
+ public void redirectNonMatching () {
47
+ assertThatExceptionOfType (AssertionError .class ).isThrownBy (() ->
48
+ redirectedUrl ("/resource/2" ).match (getRedirectedUrlStubMvcResult ("/resource/1" )));
49
+ }
50
+
51
+ @ Test
52
+ public void redirectNonMatchingBecauseNotRedirect () {
53
+ assertThatExceptionOfType (AssertionError .class ).isThrownBy (() ->
54
+ redirectedUrl ("/resource/1" ).match (getForwardedUrlStubMvcResult ("/resource/1" )));
55
+ }
56
+
45
57
@ Test
46
58
public void redirectWithUrlTemplate () throws Exception {
47
59
redirectedUrlTemplate ("/orders/{orderId}/items/{itemId}" , 1 , 2 ).match (getRedirectedUrlStubMvcResult ("/orders/1/items/2" ));
@@ -58,11 +70,29 @@ public void redirectWithNonMatchingPattern() throws Exception {
58
70
redirectedUrlPattern ("/resource/" ).match (getRedirectedUrlStubMvcResult ("/resource/1" )));
59
71
}
60
72
73
+ @ Test
74
+ public void redirectWithNonMatchingPatternBecauseNotRedirect () {
75
+ assertThatExceptionOfType (AssertionError .class ).isThrownBy (() ->
76
+ redirectedUrlPattern ("/resource/*" ).match (getForwardedUrlStubMvcResult ("/resource/1" )));
77
+ }
78
+
61
79
@ Test
62
80
public void forward () throws Exception {
63
81
forwardedUrl ("/api/resource/1" ).match (getForwardedUrlStubMvcResult ("/api/resource/1" ));
64
82
}
65
83
84
+ @ Test
85
+ public void forwardNonMatching () {
86
+ assertThatExceptionOfType (AssertionError .class ).isThrownBy (() ->
87
+ forwardedUrlPattern ("api/resource/2" ).match (getForwardedUrlStubMvcResult ("api/resource/1" )));
88
+ }
89
+
90
+ @ Test
91
+ public void forwardNonMatchingBecauseNotForward () {
92
+ assertThatExceptionOfType (AssertionError .class ).isThrownBy (() ->
93
+ forwardedUrlPattern ("api/resource/1" ).match (getRedirectedUrlStubMvcResult ("api/resource/1" )));
94
+ }
95
+
66
96
@ Test
67
97
public void forwardWithQueryString () throws Exception {
68
98
forwardedUrl ("/api/resource/1?arg=value" ).match (getForwardedUrlStubMvcResult ("/api/resource/1?arg=value" ));
@@ -84,6 +114,12 @@ public void forwardWithNonMatchingPattern() throws Exception {
84
114
forwardedUrlPattern ("/resource/" ).match (getForwardedUrlStubMvcResult ("/resource/1" )));
85
115
}
86
116
117
+ @ Test
118
+ public void forwardWithNonMatchingPatternBecauseNotForward () {
119
+ assertThatExceptionOfType (AssertionError .class ).isThrownBy (() ->
120
+ forwardedUrlPattern ("/resource/*" ).match (getRedirectedUrlStubMvcResult ("/resource/1" )));
121
+ }
122
+
87
123
private StubMvcResult getRedirectedUrlStubMvcResult (String redirectUrl ) throws Exception {
88
124
MockHttpServletResponse response = new MockHttpServletResponse ();
89
125
response .sendRedirect (redirectUrl );
0 commit comments