|
46 | 46 | import java.util.SortedSet; |
47 | 47 |
|
48 | 48 | import javax.ws.rs.CookieParam; |
| 49 | +import javax.ws.rs.DefaultValue; |
49 | 50 | import javax.ws.rs.FormParam; |
50 | 51 | import javax.ws.rs.GET; |
51 | 52 | import javax.ws.rs.HeaderParam; |
@@ -155,6 +156,47 @@ public void testStringParamInResponse() { |
155 | 156 |
|
156 | 157 | } |
157 | 158 |
|
| 159 | + @Test |
| 160 | + public void testMyBeanFormParamDefault() { |
| 161 | + Form form = new Form(); |
| 162 | + Response response = target().path("resource/myBeanFormDefault") |
| 163 | + .request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); |
| 164 | + String str = response.readEntity(String.class); |
| 165 | + assertEquals("*form-default*", str); |
| 166 | + } |
| 167 | + |
| 168 | + @Test |
| 169 | + public void testMyBeanQueryParamDefault() { |
| 170 | + final Response response = target().path("resource/myBeanQueryDefault") |
| 171 | + .request().get(); |
| 172 | + final String str = response.readEntity(String.class); |
| 173 | + assertEquals("*query-default*", str); |
| 174 | + } |
| 175 | + |
| 176 | + @Test |
| 177 | + public void testMyBeanMatrixParamDefault() { |
| 178 | + final Response response = target().path("resource/myBeanMatrixDefault") |
| 179 | + .request().get(); |
| 180 | + final String str = response.readEntity(String.class); |
| 181 | + assertEquals("*matrix-default*", str); |
| 182 | + } |
| 183 | + |
| 184 | + @Test |
| 185 | + public void testMyBeanCookieParamDefault() { |
| 186 | + final Response response = target().path("resource/myBeanCookieDefault") |
| 187 | + .request().get(); |
| 188 | + final String str = response.readEntity(String.class); |
| 189 | + assertEquals("*cookie-default*", str); |
| 190 | + } |
| 191 | + |
| 192 | + @Test |
| 193 | + public void testMyBeanHeaderParamDefault() { |
| 194 | + final Response response = target().path("resource/myBeanHeaderDefault") |
| 195 | + .request().get(); |
| 196 | + final String str = response.readEntity(String.class); |
| 197 | + assertEquals("*header-default*", str); |
| 198 | + } |
| 199 | + |
158 | 200 | @Path("resource") |
159 | 201 | public static class Resource { |
160 | 202 | @POST |
@@ -199,6 +241,36 @@ public String postMyBean(@QueryParam("q") SortedSet<MyBean> query) { |
199 | 241 | return sb.toString(); |
200 | 242 | } |
201 | 243 |
|
| 244 | + @POST |
| 245 | + @Path("myBeanFormDefault") |
| 246 | + public String postMyBeanFormDefault(@DefaultValue("form-default") @FormParam("form") MyBean pathParam) { |
| 247 | + return pathParam.getValue(); |
| 248 | + } |
| 249 | + |
| 250 | + @GET |
| 251 | + @Path("myBeanQueryDefault") |
| 252 | + public String getMyBeanQueryDefault(@DefaultValue("query-default") @QueryParam("q") MyBean queryParam) { |
| 253 | + return queryParam.getValue(); |
| 254 | + } |
| 255 | + |
| 256 | + @GET |
| 257 | + @Path("myBeanMatrixDefault") |
| 258 | + public String getMyBeanMatrixDefault(@DefaultValue("matrix-default") @MatrixParam("m") MyBean matrixParam) { |
| 259 | + return matrixParam.getValue(); |
| 260 | + } |
| 261 | + |
| 262 | + @GET |
| 263 | + @Path("myBeanCookieDefault") |
| 264 | + public String getMyBeanCookieDefault(@DefaultValue("cookie-default") @CookieParam("c") MyBean cookieParam) { |
| 265 | + return cookieParam.getValue(); |
| 266 | + } |
| 267 | + |
| 268 | + @GET |
| 269 | + @Path("myBeanHeaderDefault") |
| 270 | + public String getMyBeanHeaderDefault(@DefaultValue("header-default") @HeaderParam("h") MyBean headerParam) { |
| 271 | + return headerParam.getValue(); |
| 272 | + } |
| 273 | + |
202 | 274 | @POST |
203 | 275 | @Path("string/{path}") |
204 | 276 | public String postString(@PathParam("path") String pathParam, @MatrixParam("matrix") String matrix, |
|
0 commit comments