|
1 | 1 | package org.nutz.mvc.init;
|
2 | 2 |
|
3 |
| -import static org.junit.Assert.assertEquals; |
4 |
| - |
5 | 3 | import org.junit.Test;
|
6 | 4 | import org.nutz.mvc.AbstractMvcTest;
|
7 | 5 | import org.nutz.mvc.init.conf.RestModule;
|
8 | 6 |
|
| 7 | +import static org.junit.Assert.assertEquals; |
| 8 | + |
9 | 9 | public class RestModuleTest extends AbstractMvcTest {
|
10 | 10 |
|
11 | 11 | protected void initServletConfig() {
|
@@ -89,4 +89,58 @@ public void test_pathArgs_01() throws Exception {
|
89 | 89 | String re = response.getAsString();
|
90 | 90 | assertEquals("xyz?a=45&b=23", re);
|
91 | 91 | }
|
| 92 | + |
| 93 | + @Test |
| 94 | + public void test_abc_options() throws Exception { |
| 95 | + request.setPathInfo("/abc"); |
| 96 | + request.setMethod("Options"); |
| 97 | + servlet.service(request, response); |
| 98 | + String re = response.getAsString(); |
| 99 | + assertEquals("options", re); |
| 100 | + } |
| 101 | + |
| 102 | + @Test |
| 103 | + public void test_abc_patch() throws Exception { |
| 104 | + request.setPathInfo("/abc"); |
| 105 | + request.setMethod("Patch"); |
| 106 | + servlet.service(request, response); |
| 107 | + String re = response.getAsString(); |
| 108 | + assertEquals("patch", re); |
| 109 | + } |
| 110 | + |
| 111 | + @Test |
| 112 | + public void test_oag_options() throws Exception { |
| 113 | + request.setPathInfo("/oag"); |
| 114 | + request.setMethod("Options"); |
| 115 | + servlet.service(request, response); |
| 116 | + String re = response.getAsString(); |
| 117 | + assertEquals("options&get", re); |
| 118 | + } |
| 119 | + |
| 120 | + @Test |
| 121 | + public void test_oag_get() throws Exception { |
| 122 | + request.setPathInfo("/oag"); |
| 123 | + request.setMethod("Get"); |
| 124 | + servlet.service(request, response); |
| 125 | + String re = response.getAsString(); |
| 126 | + assertEquals("options&get", re); |
| 127 | + } |
| 128 | + |
| 129 | + @Test |
| 130 | + public void test_oap_options() throws Exception { |
| 131 | + request.setPathInfo("/oap"); |
| 132 | + request.setMethod("Options"); |
| 133 | + servlet.service(request, response); |
| 134 | + String re = response.getAsString(); |
| 135 | + assertEquals("options&post", re); |
| 136 | + } |
| 137 | + |
| 138 | + @Test |
| 139 | + public void test_oap_post() throws Exception { |
| 140 | + request.setPathInfo("/oap"); |
| 141 | + request.setMethod("Post"); |
| 142 | + servlet.service(request, response); |
| 143 | + String re = response.getAsString(); |
| 144 | + assertEquals("options&post", re); |
| 145 | + } |
92 | 146 | }
|
0 commit comments