PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java

https://github.com/liucong/cxf
Java | 333 lines | 237 code | 56 blank | 40 comment | 0 complexity | 63fb335cb6e9eda639038f52df8d3df0 MD5 | raw file
Possible License(s): Apache-2.0
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.apache.cxf.jaxrs;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.UUID;
  23. import javax.annotation.Resource;
  24. import javax.servlet.ServletConfig;
  25. import javax.servlet.ServletContext;
  26. import javax.servlet.http.HttpServletRequest;
  27. import javax.servlet.http.HttpServletResponse;
  28. import javax.ws.rs.Consumes;
  29. import javax.ws.rs.CookieParam;
  30. import javax.ws.rs.DefaultValue;
  31. import javax.ws.rs.FormParam;
  32. import javax.ws.rs.HeaderParam;
  33. import javax.ws.rs.MatrixParam;
  34. import javax.ws.rs.Path;
  35. import javax.ws.rs.PathParam;
  36. import javax.ws.rs.Produces;
  37. import javax.ws.rs.QueryParam;
  38. import javax.ws.rs.core.Context;
  39. import javax.ws.rs.core.HttpHeaders;
  40. import javax.ws.rs.core.PathSegment;
  41. import javax.ws.rs.core.Request;
  42. import javax.ws.rs.core.SecurityContext;
  43. import javax.ws.rs.core.UriInfo;
  44. import javax.ws.rs.ext.ContextResolver;
  45. import javax.ws.rs.ext.Providers;
  46. import javax.xml.bind.JAXBContext;
  47. import javax.xml.bind.annotation.XmlRootElement;
  48. import org.apache.cxf.jaxrs.impl.PathSegmentImpl;
  49. public class Customer extends AbstractCustomer implements CustomerInfo {
  50. @XmlRootElement(name = "CustomerBean")
  51. public static class CustomerBean {
  52. private String a;
  53. private Long b;
  54. private List<String> c;
  55. private CustomerBean d;
  56. //CHECKSTYLE:OFF
  57. public List<CustomerBean> e;
  58. //CHECKSTYLE:ON
  59. public void setA(String aString) {
  60. this.a = aString;
  61. }
  62. public void setB(Long bLong) {
  63. this.b = bLong;
  64. }
  65. public void setC(List<String> cStringList) {
  66. this.c = cStringList;
  67. }
  68. public void setD(CustomerBean dCustomerBean) {
  69. this.d = dCustomerBean;
  70. }
  71. public String getA() {
  72. return a;
  73. }
  74. public Long getB() {
  75. return b;
  76. }
  77. public List<String> getC() {
  78. return c;
  79. }
  80. public CustomerBean getD() {
  81. return d;
  82. }
  83. }
  84. @Context private ContextResolver<JAXBContext> cr;
  85. private UriInfo uriInfo;
  86. @Context private HttpHeaders headers;
  87. @Context private Request request;
  88. @Context private SecurityContext sContext;
  89. @Context private Providers bodyWorkers;
  90. @Resource private HttpServletRequest servletRequest;
  91. @Resource private HttpServletResponse servletResponse;
  92. @Resource private ServletContext servletContext;
  93. @Context private HttpServletRequest servletRequest2;
  94. @Context private HttpServletResponse servletResponse2;
  95. @Context private ServletContext servletContext2;
  96. private ServletContext servletContext3;
  97. @Context private UriInfo uriInfo2;
  98. private String queryParam;
  99. @QueryParam("b")
  100. private String b;
  101. private String name;
  102. public Customer() {
  103. }
  104. public Customer(@Context UriInfo info) {
  105. uriInfo = info;
  106. }
  107. public Customer(@Context UriInfo info,
  108. @QueryParam("a") String queryParam) {
  109. uriInfo = info;
  110. this.queryParam = queryParam;
  111. }
  112. public String getName() {
  113. return name;
  114. }
  115. public void setName(String n) {
  116. name = n;
  117. }
  118. public String getB() {
  119. return b;
  120. }
  121. public void testQueryBean(@QueryParam("") CustomerBean cb) {
  122. }
  123. public void testPathBean(@PathParam("") CustomerBean cb) {
  124. }
  125. public void testFormBean(@FormParam("") CustomerBean cb) {
  126. }
  127. public void testMatrixBean(@MatrixParam("") CustomerBean cb) {
  128. }
  129. public UriInfo getUriInfo() {
  130. return uriInfo;
  131. }
  132. public UriInfo getUriInfo2() {
  133. return uriInfo2;
  134. }
  135. @Context
  136. public void setUriInfo(UriInfo ui) {
  137. uriInfo = ui;
  138. }
  139. public void setUriInfoContext(UriInfo ui) {
  140. }
  141. @Context
  142. public void setServletContext(ServletContext sc) {
  143. servletContext3 = sc;
  144. }
  145. public ServletContext getThreadLocalServletContext() {
  146. return servletContext3;
  147. }
  148. @QueryParam("a")
  149. public void setA(String a) {
  150. queryParam = a;
  151. }
  152. public String getQueryParam() {
  153. return queryParam;
  154. }
  155. public HttpHeaders getHeaders() {
  156. return headers;
  157. }
  158. public Request getRequest() {
  159. return request;
  160. }
  161. public Providers getBodyWorkers() {
  162. return bodyWorkers;
  163. }
  164. public SecurityContext getSecurityContext() {
  165. return sContext;
  166. }
  167. public HttpServletRequest getServletRequest() {
  168. return servletRequest2;
  169. }
  170. public HttpServletResponse getServletResponse() {
  171. return servletResponse2;
  172. }
  173. public ServletContext getServletContext() {
  174. return servletContext2;
  175. }
  176. public HttpServletRequest getServletRequestResource() {
  177. return servletRequest;
  178. }
  179. public HttpServletResponse getServletResponseResource() {
  180. return servletResponse;
  181. }
  182. public ServletContext getServletContextResource() {
  183. return servletContext;
  184. }
  185. public ContextResolver getContextResolver() {
  186. return cr;
  187. }
  188. @Produces("text/xml")
  189. @Consumes("text/xml")
  190. public void test() {
  191. // complete
  192. }
  193. @Produces("text/xml")
  194. public void getItAsXML() {
  195. // complete
  196. }
  197. @Produces("text/plain")
  198. public void getItPlain() {
  199. // complete
  200. }
  201. @Produces("text/xml")
  202. public void testQuery(@QueryParam("query") String queryString,
  203. @QueryParam("query") int queryInt) {
  204. // complete
  205. }
  206. @Produces("text/xml")
  207. public void testPathSegment(@PathParam("ps") PathSegment ps,
  208. @PathParam("ps") String path) {
  209. // complete
  210. }
  211. @Produces("text/xml")
  212. public void testMultipleQuery(@QueryParam("query") String queryString,
  213. @QueryParam("query2") String queryString2,
  214. @QueryParam("query3") Long queryString3,
  215. @QueryParam("query4") boolean queryBoolean4,
  216. @QueryParam("query5") String queryString4) {
  217. // complete
  218. }
  219. @Produces("text/xml")
  220. public void testMatrixParam(@MatrixParam("p1") String mp1,
  221. @MatrixParam("p2") String mp2,
  222. @MatrixParam("p3") String mp3,
  223. @MatrixParam("p4") String mp4,
  224. @MatrixParam("p4") List<String> mp4List) {
  225. // complete
  226. }
  227. public void testCustomerParam(@QueryParam("p1") Customer c, @QueryParam("p2") Customer[] c2) {
  228. // complete
  229. }
  230. public void testCustomerParam2(@QueryParam("p1") String[] p) {
  231. // complete
  232. }
  233. public void testFromStringParam(@QueryParam("p1") UUID uuid,
  234. @QueryParam("p2") CustomerGender gender,
  235. @QueryParam("p3") CustomerGender gender2) {
  236. // complete
  237. }
  238. // CHECKSTYLE:OFF
  239. public void testWrongType(@QueryParam("p1") HashMap map) {
  240. // complete
  241. }
  242. // CHECKSTYLE:ON
  243. public void testWrongType2(@QueryParam("p1") CustomerGender g) {
  244. // complete
  245. }
  246. public void testFormParam(@FormParam("p1") String fp1,
  247. @FormParam("p2") List<String> fp2) {
  248. // complete
  249. }
  250. public void testCookieParam(@CookieParam("c1") String c1,
  251. @CookieParam("c2") @DefaultValue("c2Value") String c2) {
  252. // complete
  253. }
  254. public void testParams(@Context UriInfo info,
  255. @Context HttpHeaders hs,
  256. @Context Request r,
  257. @Context SecurityContext s,
  258. @Context Providers workers,
  259. @HeaderParam("Foo") String h,
  260. @HeaderParam("Foo") List<String> l) {
  261. // complete
  262. }
  263. public void testServletParams(@Context HttpServletRequest req,
  264. @Context HttpServletResponse res,
  265. @Context ServletContext context,
  266. @Context ServletConfig config) {
  267. // complete
  268. }
  269. @Path("{id1}/{id2}")
  270. public void testConversion(@PathParam("id1") PathSegmentImpl id1,
  271. @PathParam("id2") SimpleFactory f) {
  272. // complete
  273. }
  274. public void testContextResolvers(@Context ContextResolver<JAXBContext> resolver) {
  275. // complete
  276. }
  277. };