You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/08/07 05:10:46 UTC
svn commit: r801869 [7/21] - in /incubator/wink/trunk: wink-integration-test/
wink-integration-test/wink-server-integration-test-support/
wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/
wink-in...
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingGarage.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingGarage.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingGarage.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingGarage.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.carstorage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+@Path(value = "/parkinggarage")
+public class ParkingGarage extends ParkingLot {
+
+ private static Map<Integer, List<String>> cars = new HashMap<Integer, List<String>>();
+
+ @Context
+ protected UriInfo uriInfo;
+
+ @GET
+ @Path("/cars/{id}")
+ public Response getCars() {
+ StringBuffer sb = new StringBuffer();
+ String id = uriInfo.getPathParameters().getFirst("id");
+ if (id != null) {
+ List<String> carList = cars.get(Integer.valueOf(id));
+ for (String car : carList) {
+ sb.append(car).append(";");
+ }
+ }
+ Response resp = Response.ok(sb.toString()).build();
+ resp.getMetadata().putSingle("Invoked", "ParkingGarage.getCars");
+ return resp;
+ }
+
+ public Response addCar(String licenseNum) {
+ List<String> licenseNums = cars.get(1);
+ if (licenseNums == null) {
+ licenseNums = new ArrayList<String>();
+ cars.put(1, licenseNums);
+ }
+ licenseNums.add(licenseNum);
+ Response resp = Response.ok().build();
+ resp.getMetadata().putSingle("Invoked", "ParkingGarage.addCar");
+ return resp;
+ }
+
+ public Response removeCar(String licenseNum) {
+ cars.remove(licenseNum);
+ Response resp = Response.ok().build();
+ resp.getMetadata().putSingle("Invoked", "ParkingGarage.removeCar");
+ return resp;
+ }
+
+ public static void clear() {
+ cars.clear();
+ }
+
+ void setURIInfo(UriInfo uriInfo) {
+ this.uriInfo = uriInfo;
+ }
+
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingLot.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingLot.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingLot.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/ParkingLot.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.carstorage;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path(value = "/parkinglot")
+public class ParkingLot implements CarStorage {
+
+ Logger logger = LoggerFactory.getLogger(ParkingLot.class);
+
+ private static Set<String> cars = new HashSet<String>();
+
+ @GET
+ @Path(value = "/cars")
+ public Response getCars() {
+ StringBuffer sb = new StringBuffer();
+ for (String car : cars) {
+ sb.append(car).append(";");
+ }
+ Response resp = Response.ok(sb.toString()).build();
+ resp.getMetadata().putSingle("Invoked", "ParkingLot.getCars");
+ return resp;
+ }
+
+ @POST
+ @Path(value = "/cars")
+ public Response addCar(String licenseNum) {
+ cars.add(licenseNum);
+ Response resp = Response.ok().build();
+ resp.getMetadata().putSingle("Invoked", "ParkingLot.addCar");
+ return resp;
+ }
+
+ @DELETE
+ public Response removeCar(String licenseNum) {
+ cars.remove(licenseNum);
+ Response resp = Response.ok().build();
+ resp.getMetadata().putSingle("Invoked", "ParkingLot.removeCar");
+ return resp;
+ }
+
+ @Path("/cars/remove/{type}")
+ public ParkingLot removeCarSubLocater(@PathParam("type") String type) {
+ if ("ParkingLot".equals(type))
+ return this;
+ if ("ParkingGarage".equals(type))
+ return new ParkingGarage();
+ if ("CarFerry".equals(type))
+ return new CarFerry();
+ return null;
+ }
+
+ public static void clear() {
+ cars.clear();
+ }
+
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Apple.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Apple.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Apple.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Apple.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.fruits;
+
+import javax.ws.rs.PathParam;
+
+public class Apple extends Fruit {
+
+ public String getFruitName(@PathParam("p") String suffix) {
+ return Apple.class.getName() + ";" + suffix;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Fruit.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Fruit.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Fruit.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Fruit.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.fruits;
+
+import javax.ws.rs.Encoded;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+@Path("fruit")
+@Encoded
+public class Fruit {
+
+ @GET
+ public String getFruitName(@PathParam("p") String suffix) {
+ return Fruit.class.getName() + ";" + suffix;
+ }
+
+ @Path("{p}")
+ public Fruit getFruit(@PathParam("p") String fruit) {
+ if ("fruit%20suffix".equals(fruit))
+ return this;
+ if ("apple%20suffix".equals(fruit))
+ return new Apple();
+ if ("orange%20suffix".equals(fruit))
+ return new Orange();
+ return null;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Orange.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Orange.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Orange.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/fruits/Orange.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.fruits;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.PathParam;
+
+public class Orange extends Fruit {
+
+ @POST
+ public String getFruitName(@PathParam("p") String suffix) {
+ return Orange.class.getName() + ";" + suffix;
+ }
+}
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/geronimo-web.xml (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-inheritance/src/main/webapp/WEB-INF/geronimo-web.xml)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/geronimo-web.xml?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/geronimo-web.xml&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-inheritance/src/main/webapp/WEB-INF/geronimo-web.xml&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/web.xml?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/web.xml (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/webapp/WEB-INF/web.xml Fri Aug 7 03:10:22 2009
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+ <display-name>Archetype Created Web Application</display-name>
+ <servlet>
+ <servlet-name>Inheritance</servlet-name>
+ <servlet-class>${wink.rest.servlet}</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.apache.wink.itest.InheritanceApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Inheritance</servlet-name>
+ <url-pattern>/inheritance/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/test/java/org/apache/wink/itest/InheritanceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/test/java/org/apache/wink/itest/InheritanceTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/test/java/org/apache/wink/itest/InheritanceTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/test/java/org/apache/wink/itest/InheritanceTest.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class InheritanceTest extends TestCase {
+
+ protected HttpClient httpClient = new HttpClient();
+
+ final private static String PARKING_LOT_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/inheritance/parkinglot";
+
+ final private static String PARKING_GARAGE_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/inheritance/parkinggarage";
+
+ final private static String CARPORT_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/inheritance/carport";
+
+ final private static String CARFERRY_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/inheritance/carferry";
+
+ final private static String CLASS_C_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/inheritance/classc";
+
+ final private static String FRUIT_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/inheritance/fruit";
+
+ public void testOverrideInterfaceAnnotations() throws Exception {
+ PostMethod postMethod = new PostMethod(PARKING_LOT_URI + "/cars");
+ GetMethod getMethod = new GetMethod(PARKING_LOT_URI + "/cars");
+ try {
+ String licenseNum = "103DIY";
+ postMethod.setRequestEntity(new ByteArrayRequestEntity(licenseNum.getBytes(),
+ "text/xml"));
+ httpClient.executeMethod(postMethod);
+ Header header = postMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("ParkingLot.addCar", header.getValue());
+ httpClient.executeMethod(getMethod);
+ String resp = getMethod.getResponseBodyAsString();
+ assertTrue(resp.contains(licenseNum));
+ header = getMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("ParkingLot.getCars", header.getValue());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ postMethod.releaseConnection();
+ getMethod.releaseConnection();
+ }
+ }
+
+ public void testOverrideSuperClassAnnotations() throws Exception {
+ PostMethod postMethod = new PostMethod(PARKING_GARAGE_URI + "/cars");
+ GetMethod getMethod = new GetMethod(PARKING_GARAGE_URI + "/cars/1");
+ try {
+ String licenseNum = "103DIY";
+ postMethod.setRequestEntity(new ByteArrayRequestEntity(licenseNum.getBytes(),
+ "text/xml"));
+ httpClient.executeMethod(postMethod);
+ Header header = postMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("ParkingGarage.addCar", header.getValue());
+ httpClient.executeMethod(getMethod);
+ String resp = getMethod.getResponseBodyAsString();
+ assertTrue(resp.contains(licenseNum));
+ header = getMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("ParkingGarage.getCars", header.getValue());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ postMethod.releaseConnection();
+ getMethod.releaseConnection();
+ }
+ }
+
+ public void testInheritAnnotationsFromInterface() throws Exception {
+ PostMethod postMethod = new PostMethod(CARPORT_URI + "/carstorage");
+ GetMethod getMethod = new GetMethod(CARPORT_URI + "/carstorage");
+ try {
+ String licenseNum = "103DIY";
+ postMethod.setRequestEntity(new ByteArrayRequestEntity(licenseNum.getBytes(),
+ "text/xml"));
+ httpClient.executeMethod(postMethod);
+ Header header = postMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("Carport.addCar", header.getValue());
+ httpClient.executeMethod(getMethod);
+ String resp = getMethod.getResponseBodyAsString();
+ assertTrue(resp.contains(licenseNum));
+ header = getMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("Carport.getCars", header.getValue());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ postMethod.releaseConnection();
+ getMethod.releaseConnection();
+ }
+ }
+
+ public void testInheritAnnotationsFromSuperClass() throws Exception {
+ PostMethod postMethod = new PostMethod(CARFERRY_URI + "/cars");
+ GetMethod getMethod = new GetMethod(CARFERRY_URI + "/cars/1");
+ try {
+ String licenseNum = "103DIY";
+ postMethod.setRequestEntity(new ByteArrayRequestEntity(licenseNum.getBytes(),
+ "text/xml"));
+ httpClient.executeMethod(postMethod);
+ Header header = postMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("CarFerry.addCar", header.getValue());
+ httpClient.executeMethod(getMethod);
+ String resp = getMethod.getResponseBodyAsString();
+ assertTrue(resp.contains(licenseNum));
+ header = getMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("CarFerry.getCars", header.getValue());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ postMethod.releaseConnection();
+ getMethod.releaseConnection();
+ }
+ }
+
+ public void testSuperClassOverInterface() throws Exception {
+ GetMethod getMethod = new GetMethod(CLASS_C_URI + "/abstract_method1/encoded%20string");
+ try {
+ httpClient.executeMethod(getMethod);
+ String resp = getMethod.getResponseBodyAsString();
+ assertEquals("ClassC Method1;encoded%20string", resp);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ public void testOverridePostWithGet() throws Exception {
+ GetMethod getMethod = new GetMethod(CLASS_C_URI + "/method2/encoded%20string");
+ PostMethod postMethod = new PostMethod(CLASS_C_URI);
+ try {
+ httpClient.executeMethod(getMethod);
+ String resp = getMethod.getResponseBodyAsString();
+ assertEquals("ClassC Method2;encoded string", resp);
+ httpClient.executeMethod(postMethod);
+ assertEquals(405, postMethod.getStatusCode());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ getMethod.releaseConnection();
+ postMethod.releaseConnection();
+ }
+ }
+
+ public void testSubResourceLocaterInheritance() throws Exception {
+ DeleteMethod deleteMethod = new DeleteMethod(PARKING_LOT_URI + "/cars/remove/ParkingLot");
+ GetMethod getMethod = new GetMethod(FRUIT_URI + "/fruit%20suffix");
+ PostMethod postMethod = new PostMethod(FRUIT_URI + "/orange%20suffix");
+ try {
+ // ParkingLot classes. Sub resource classes are potential root
+ // resources
+ httpClient.executeMethod(deleteMethod);
+ Header header = deleteMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("ParkingLot.removeCar", header.getValue());
+ deleteMethod.releaseConnection();
+ deleteMethod = new DeleteMethod(PARKING_LOT_URI + "/cars/remove/ParkingGarage");
+ httpClient.executeMethod(deleteMethod);
+ header = deleteMethod.getResponseHeader("Invoked");
+ assertNotNull(header);
+ assertEquals("ParkingGarage.removeCar", header.getValue());
+ deleteMethod.releaseConnection();
+ deleteMethod = new DeleteMethod(PARKING_LOT_URI + "/cars/remove/CarFerry");
+ httpClient.executeMethod(deleteMethod);
+ assertEquals(405, deleteMethod.getStatusCode());
+
+ // Fruit classes. Sub resource classes are not potential root
+ // resources
+ httpClient.executeMethod(getMethod);
+ String response = getMethod.getResponseBodyAsString();
+ assertEquals("org.apache.wink.itest.fruits.Fruit;fruit%20suffix",
+ response);
+ getMethod.releaseConnection();
+ getMethod = new GetMethod(FRUIT_URI + "/apple%20suffix");
+ httpClient.executeMethod(getMethod);
+ response = getMethod.getResponseBodyAsString();
+ assertEquals("org.apache.wink.itest.fruits.Apple;apple suffix", // parameters
+ // on
+ // class
+ // are
+ // not
+ // inherited
+ response);
+ getMethod.releaseConnection();
+ getMethod = new GetMethod(FRUIT_URI + "/orange%20suffix");
+ httpClient.executeMethod(getMethod);
+ assertEquals(405, getMethod.getStatusCode());
+ httpClient.executeMethod(postMethod);
+ response = postMethod.getResponseBodyAsString();
+ assertEquals("org.apache.wink.itest.fruits.Orange;orange suffix",
+ response);
+ assertEquals(200, postMethod.getStatusCode());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ deleteMethod.releaseConnection();
+ getMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/pom.xml?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/pom.xml (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/pom.xml Fri Aug 7 03:10:22 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project>
+ <parent>
+ <artifactId>wink-itest</artifactId>
+ <groupId>org.apache.wink</groupId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>wink-itest-params</artifactId>
+ <packaging>war</packaging>
+ <name>wink-jaxrs-test-params Maven Webapp</name>
+</project>
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/Application.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/Application.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/Application.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.wink.itest.form.FormParamResource;
+import org.apache.wink.itest.header.HeaderParamDefaultResource;
+import org.apache.wink.itest.header.HeaderParamExceptionResource;
+import org.apache.wink.itest.query.QueryParamsExceptionResource;
+
+/**
+ * Parameters annotation test application.
+ */
+public class Application extends javax.ws.rs.core.Application {
+
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ public Application() {
+ classes = new HashSet<Class<?>>();
+ classes.add(HeaderParamResource.class);
+ classes.add(MatrixParamResource.class);
+ classes.add(QueryParamResource.class);
+ classes.add(EncodingParamResource.class);
+ classes.add(AutoDecodeParamResource.class);
+ classes.add(DefaultValueResource.class);
+ classes.add(CookieParamResource.class);
+
+ classes.add(HeaderParamDefaultResource.class);
+ classes.add(HeaderParamExceptionResource.class);
+
+ classes.add(QueryParamsExceptionResource.class);
+
+ classes.add(FormParamResource.class);
+
+ classes.add(QueryParamNotSetResource.class);
+ classes.add(MatrixParamNotSetResource.class);
+
+ classes.add(PathSegmentResource.class);
+
+ // classes.add(MultipleEntityParamsResource.class);
+
+ classes = Collections.unmodifiableSet(classes);
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/AutoDecodeParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/AutoDecodeParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/AutoDecodeParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/AutoDecodeParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+
+@Path("/decodedparams")
+public class AutoDecodeParamResource {
+
+ final private String appVersion;
+
+ public AutoDecodeParamResource(@MatrixParam("appversion") String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ @GET
+ @Path("country/{location}")
+ public String getShopInCountryDecoded(@PathParam("location") String location) {
+ return "getShopInCountryDecoded:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Path("city")
+ public String getShopInCityDecoded(@QueryParam("location") String location) {
+ return "getShopInCityDecoded:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Path("street")
+ public String getShopOnStreetDecoded(@MatrixParam("location") String location) {
+ return "getShopOnStreetDecoded:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @POST
+ @Path("region")
+ public String getShopInRegionDecoded(@FormParam("location") String location) {
+ return "getShopInRegionDecoded:location=" + location + ";appversion=" + appVersion;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/CookieParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/CookieParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/CookieParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/CookieParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.core.Response;
+
+@Path("cookiemonster")
+public class CookieParamResource {
+
+ @PUT
+ @Produces("text/plain")
+ public Response swipe(@CookieParam("jar") @DefaultValue("0") String jarSwipes) {
+ return Response.ok("swiped:" + jarSwipes).cookie(new NewCookie("jar", (Integer
+ .valueOf(jarSwipes) + 1) + "")).build();
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/DefaultValueResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/DefaultValueResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/DefaultValueResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/DefaultValueResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+@Path("defaultvalue")
+public class DefaultValueResource {
+
+ private String version;
+
+ @DefaultValue("100")
+ @QueryParam("limit")
+ private String limit;
+
+ private String sort;
+
+ public DefaultValueResource(@HeaderParam("requestVersion") @DefaultValue("1.0") String version) {
+ this.version = version;
+ }
+
+ public static class Page {
+
+ private String offset;
+
+ public Page(String offset, int dummy) {
+ this.offset = offset;
+ System.out.println("Executed constructor");
+ }
+
+ public String getOffset() {
+ return offset;
+ }
+
+ public int getPage() {
+ return Integer.valueOf(offset) * 1; // Integer.valueOf(limit);
+ }
+
+ public static Page valueOf(String offset) {
+ return new Page(offset, 123);
+ }
+ }
+
+ @GET
+ public String getRow(@QueryParam("offset") @DefaultValue("0") Page page) {
+ return "getRow:" + "offset="
+ + page.getOffset()
+ + ";version="
+ + version
+ + ";limit="
+ + limit
+ + ";sort="
+ + sort;
+ }
+
+ @DefaultValue("normal")
+ @QueryParam("sort")
+ public void setSort(String sort) {
+ this.sort = sort;
+ }
+
+ public String getSort() {
+ return sort;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/EncodingParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/EncodingParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/EncodingParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/EncodingParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.Encoded;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+
+@Path("/encodingparam")
+public class EncodingParamResource {
+
+ final private String appVersion;
+
+ public EncodingParamResource(@Encoded @MatrixParam("appversion") String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ //
+ // @GET
+ // @Path("city/{city}")
+ // public String getShopInCity(@Encoded @QueryParam("q") String searchQuery,
+ // @PathParam("city") String city) {
+ // return "getShopInCity:q=" + searchQuery + ";city=" + city +
+ // ";appversion=" + appVersion;
+ // }
+
+ // @GET
+ // @Path("loc/{location}")
+ // @Encoded
+ // public String getShopInLocation(@QueryParam("q") String searchQuery,
+ // @Encoded @PathParam("location") String location) {
+ // return "getShopInLocation:q=" + searchQuery + ";location=" + location +
+ // ";appversion=" + appVersion;
+ // }
+
+ @GET
+ @Path("country/{location}")
+ public String getShopInCountry(@Encoded @PathParam("location") String location) {
+ return "getShopInCountry:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Path("method/country/{location}")
+ @Encoded
+ public String getShopInCountryMethod(@PathParam("location") String location) {
+ return "getShopInCountryMethod:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Encoded
+ @Path("method/city")
+ public String getShopInCityMethod(@QueryParam("location") String location) {
+ return "getShopInCityMethod:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Path("city")
+ public String getShopInCity(@Encoded @QueryParam("location") String location) {
+ return "getShopInCity:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Encoded
+ @Path("method/street")
+ public String getShopOnStreetMethod(@MatrixParam("location") String location) {
+ return "getShopOnStreetMethod:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @GET
+ @Path("street")
+ public String getShopOnStreet(@Encoded @MatrixParam("location") String location) {
+ return "getShopOnStreet:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @POST
+ @Path("region")
+ public String getShopInRegion(@Encoded @FormParam("location") String location) {
+ return "getShopInRegion:location=" + location + ";appversion=" + appVersion;
+ }
+
+ @POST
+ @Encoded
+ @Path("method/region")
+ public String getShopInRegionMethod(@FormParam("location") String location) {
+ return "getShopInRegionMethod:location=" + location + ";appversion=" + appVersion;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/HeaderParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/HeaderParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/HeaderParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/HeaderParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+/**
+ * Resource with<code>HeaderParam</code>.
+ *
+ * @see HeaderParam
+ */
+@Path("header")
+public class HeaderParamResource {
+
+ private String cstrHeaderParam;
+
+ @HeaderParam("Accept-Language")
+ private String acceptLanguage;
+
+ private String agent;
+
+ static public class HeaderValueOf {
+ private HeaderValueOf(String somevalue) {
+ }
+
+ public static HeaderValueOf valueOf(String someValue) {
+ if ("throwex".equals(someValue)) {
+ throw new WebApplicationException(499);
+ } else if ("throwruntimeex".equals(someValue)) {
+ throw new IllegalArgumentException();
+ }
+ return new HeaderValueOf(someValue);
+ }
+ }
+
+ static public class HeaderConstructor {
+ public HeaderConstructor(String somevalue) {
+ if ("throwex".equals(somevalue)) {
+ throw new WebApplicationException(499);
+ } else if ("throwruntimeex".equals(somevalue)) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ public HeaderParamResource(@HeaderParam("customHeaderParam") String cstrHeaderParam) {
+ this.cstrHeaderParam = cstrHeaderParam;
+ }
+
+ @GET
+ public Response getHeaderParam(@HeaderParam("Accept-Language") String methodLanguage) {
+ return Response.ok("getHeaderParam:" + cstrHeaderParam
+ + ";User-Agent:"
+ + agent
+ + ";Accept-Language:"
+ + acceptLanguage
+ + ";language-method:"
+ + methodLanguage).header("custResponseHeader", "secret").build();
+ }
+
+ @POST
+ public Response getHeaderParamPost(@HeaderParam("CustomHeader") HeaderValueOf customHeader,
+ @HeaderParam("CustomConstructorHeader") HeaderConstructor customHeader2) {
+ return Response.ok().entity("made successful call").build();
+ }
+
+ @HeaderParam("User-Agent")
+ public void setUserAgent(String aUserAgent) {
+ agent = aUserAgent;
+ }
+
+ public String getUserAgent() {
+ return agent;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamNotSetResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamNotSetResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamNotSetResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamNotSetResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+
+@Path("/matrixparamnotset")
+public class MatrixParamNotSetResource {
+
+ @Path("int")
+ @GET
+ public String getDefault(@MatrixParam("count") int count) {
+ return count + "";
+ }
+
+ @Path("short")
+ @GET
+ public String getDefault(@MatrixParam("smallCount") short smallCount) {
+ return smallCount + "";
+ }
+
+ @Path("long")
+ @GET
+ public String getDefault(@MatrixParam("longCount") long longCount) {
+ return longCount + "";
+ }
+
+ @Path("float")
+ @GET
+ public String getDefault(@MatrixParam("floatCount") float floatCount) {
+ return floatCount + "";
+ }
+
+ @Path("double")
+ @GET
+ public String getDefault(@MatrixParam("count") double count) {
+ return count + "";
+ }
+
+ @Path("byte")
+ @GET
+ public String getDefault(@MatrixParam("b") byte count) {
+ return count + "";
+ }
+
+ @Path("char")
+ @GET
+ public String getDefault(@MatrixParam("letter") char letter) {
+ return letter + "";
+ }
+
+ @Path("set")
+ @GET
+ public String getDefault(@MatrixParam("bag") Set<Integer> stuff) {
+ return stuff.size() + "";
+ }
+
+ @Path("list")
+ @GET
+ public String getDefault(@MatrixParam("letter") List<String> stuff) {
+ return stuff.size() + "";
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/MatrixParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+
+/**
+ * A simple resource to test <code>@MatrixParam</code>.
+ */
+@Path("/matrix")
+public class MatrixParamResource {
+
+ private String constructorParam;
+
+ /**
+ * Resource constructor.
+ *
+ * @param aConstructorParam a simple <code>@MatrixParam</code> constructor
+ * parameter
+ */
+ public MatrixParamResource(@MatrixParam("cstrparam") String aConstructorParam) {
+ this.constructorParam = aConstructorParam;
+ }
+
+ /**
+ * GET method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @GET
+ public String getConstructorMatrixParam() {
+ return "getConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * POST method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @POST
+ public String postConstructorMatrixParam() {
+ return "postConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * PUT method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @PUT
+ public String putConstructorMatrixParam() {
+ return "putConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * DELETE method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @DELETE
+ public String deleteConstructorMatrixParam() {
+ return "deleteConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * GET method for simple matrix parameter.
+ *
+ * @param life simple parameter
+ * @return transformed string
+ */
+ @GET
+ @Path("simple")
+ public String getSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "getSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * POST method for simple matrix parameter.
+ *
+ * @param life simple parameter
+ * @return transformed string
+ */
+ @POST
+ @Path("simple")
+ public String postSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "postSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * PUT method for simple matrix parameter.
+ *
+ * @param life simple parameter
+ * @return transformed string
+ */
+ @PUT
+ @Path("simple")
+ public String putSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "putSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * DELETE method for simple matrix parameter.
+ *
+ * @param life simple parameter
+ * @return transformed string
+ */
+ @DELETE
+ @Path("simple")
+ public String deleteSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "deleteSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * GET method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @GET
+ @Path("multiple")
+ public String getMultipleMatrixParam(@MatrixParam("1st") String first,
+ @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam,
+ @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "getMultipleMatrixParam:" + first
+ + ";"
+ + uppercaseOneMoreParam
+ + ";"
+ + lowercaseOneMoreParam;
+ }
+
+ /**
+ * POST method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @POST
+ @Path("multiple")
+ public String postMultipleMatrixParam(@MatrixParam("1st") String first,
+ @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam,
+ @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "postMultipleMatrixParam:" + first
+ + ";"
+ + uppercaseOneMoreParam
+ + ";"
+ + lowercaseOneMoreParam;
+ }
+
+ /**
+ * PUT method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @PUT
+ @Path("multiple")
+ public String putMultipleMatrixParam(@MatrixParam("1st") String first,
+ @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam,
+ @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "putMultipleMatrixParam:" + first
+ + ";"
+ + uppercaseOneMoreParam
+ + ";"
+ + lowercaseOneMoreParam;
+ }
+
+ /**
+ * DELETE method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @DELETE
+ @Path("multiple")
+ public String deleteMultipleMatrixParam(@MatrixParam("1st") String first,
+ @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam,
+ @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "deleteMultipleMatrixParam:" + first
+ + ";"
+ + uppercaseOneMoreParam
+ + ";"
+ + lowercaseOneMoreParam;
+ }
+
+ /**
+ * GET method to test primitive matrix typed parameters
+ *
+ * @param aBoolean
+ * @param anInteger
+ * @param aDouble
+ * @param aByte
+ * @param ch
+ * @param aLong
+ * @param aShort
+ * @param aFloat
+ * @return a transformed string
+ */
+ @GET
+ @Path("types/primitive")
+ public String getMatrixPrimitiveTypes(@MatrixParam("bool") Boolean aBoolean,
+ @MatrixParam("intNumber") int anInteger,
+ @MatrixParam("dbl") double aDouble,
+ @MatrixParam("bite") byte aByte,
+ @MatrixParam("ch") char ch,
+ @MatrixParam("lng") long aLong,
+ @MatrixParam("float") short aShort,
+ @MatrixParam("short") float aFloat) {
+ return "getMatrixParameterPrimitiveTypes:" + aBoolean
+ + ";"
+ + anInteger
+ + ";"
+ + aDouble
+ + ";"
+ + aByte
+ + ";"
+ + ch
+ + ";"
+ + aLong
+ + ";"
+ + aShort
+ + ";"
+ + aFloat;
+ }
+
+ /**
+ * A type with a public string constructor.
+ */
+ public static class ParamWithStringConstructor {
+ private String value = null;
+
+ /**
+ * Should not be called.
+ */
+ public ParamWithStringConstructor() {
+ value = "noconstructor";
+ }
+
+ /**
+ * Should not be called.
+ *
+ * @param anInt
+ */
+ public ParamWithStringConstructor(Integer anInt) {
+ value = "intconstructor";
+ }
+
+ /**
+ * String constructor
+ *
+ * @param aValue
+ */
+ public ParamWithStringConstructor(String aValue) {
+ this.value = aValue;
+ }
+
+ /**
+ * Transform the value to something else.
+ *
+ * @return a transformed value
+ */
+ public Integer transformedValue() {
+ return Integer.valueOf(value);
+ }
+ }
+
+ /**
+ * GET method to test matrix parameter types with a public string
+ * constructor.
+ *
+ * @param param parameter which has a string constructor
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/stringcstr")
+ public String getQueryParameterStringConstructor(@MatrixParam("paramStringConstructor") ParamWithStringConstructor param) {
+ return "getMatrixParameterStringConstructor:" + param.transformedValue();
+ }
+
+ /**
+ * Type with a public static valueOf method to test query parameters.
+ */
+ public static class ParamWithValueOf {
+ private String value = null;
+
+ protected ParamWithValueOf(String aValue, int aNum) {
+ value = aValue + aNum;
+ }
+
+ /**
+ * The transformed type value
+ *
+ * @return the transformed type value
+ */
+ public String transformedValue() {
+ return value;
+ }
+
+ /**
+ * Public static valueOf method.
+ *
+ * @param aValue string value to transform into type
+ * @return an instance of the type
+ */
+ public static ParamWithValueOf valueOf(String aValue) {
+ return new ParamWithValueOf(aValue, 789);
+ }
+ }
+
+ /**
+ * GET method to test matrix parameter with a static valueOf(String) method.
+ *
+ * @param param the parameter type has a static valueOf(String) method
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/valueof")
+ public String getQueryParameterValueOf(@MatrixParam("staticValueOf") ParamWithValueOf param) {
+ return "getMatrixParameterValueOf:" + param.transformedValue();
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/PathSegmentResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/PathSegmentResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/PathSegmentResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/PathSegmentResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.PathSegment;
+
+@Path("/params/pathsegment")
+public class PathSegmentResource {
+
+ @Path("{loc}")
+ @GET
+ public String helloPath(@PathParam("loc") PathSegment pathSegment) {
+ return pathSegment.getPath();
+ }
+
+ @Path("matrix/{loc}")
+ @GET
+ public String helloPath(@PathParam("loc") String path,
+ @PathParam("loc") PathSegment pathSegment,
+ @MatrixParam("mp") String matrix) {
+ return path + "-"
+ + pathSegment.getPath()
+ + "-"
+ + pathSegment.getMatrixParameters().get(matrix)
+ + "-"
+ + matrix;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamNotSetResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamNotSetResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamNotSetResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamNotSetResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/queryparamnotset")
+public class QueryParamNotSetResource {
+
+ @Path("int")
+ @GET
+ public String getDefault(@QueryParam("count") int count) {
+ return Integer.valueOf(count).toString();
+ }
+
+ @Path("short")
+ @GET
+ public String getDefault(@QueryParam("smallCount") short smallCount) {
+ return "" + smallCount;
+ }
+
+ @Path("long")
+ @GET
+ public String getDefault(@QueryParam("longCount") long longCount) {
+ return "" + longCount;
+ }
+
+ @Path("float")
+ @GET
+ public String getDefault(@QueryParam("floatCount") float floatCount) {
+ return "" + floatCount;
+ }
+
+ @Path("double")
+ @GET
+ public String getDefault(@QueryParam("d") double count) {
+ return "" + count;
+ }
+
+ @Path("byte")
+ @GET
+ @Produces("text/plain")
+ public String getDefault(@QueryParam("b") byte count) {
+ Logger logger = LoggerFactory.getLogger(QueryParamNotSetResource.class);
+ logger.error(count + "");
+ return "" + count;
+ }
+
+ @Path("char")
+ @GET
+ public String getDefault(@QueryParam("letter") char count) {
+ return count + "";
+ }
+
+ @Path("set")
+ @GET
+ public String getDefault(@QueryParam("bag") Set<Integer> stuff) {
+ return "" + stuff.size();
+ }
+
+ @Path("list")
+ @GET
+ public String getDefault(@QueryParam("letter") List<String> stuff) {
+ return "" + stuff.size();
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/QueryParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+/**
+ * A simple resource to test <code>@QueryParam</code>.
+ */
+@Path("query")
+public class QueryParamResource {
+
+ private String aQueryID = "notset";
+
+ /**
+ * Constructor that will not be called.
+ */
+ public QueryParamResource() {
+ /* this code should not be called ever */
+ aQueryID = "notvalid";
+ }
+
+ /**
+ * Constructor with simple query parameter.
+ *
+ * @param aQueryID a query parameter
+ */
+ public QueryParamResource(@QueryParam("queryid") String aQueryID) {
+ this.aQueryID = aQueryID;
+ }
+
+ /**
+ * GET method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @GET
+ public String getConstructorQueryID() {
+ return "getConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * PUT method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @PUT
+ public String putConstructorQueryID() {
+ return "putConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * POST method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @POST
+ public String postConstructorQueryID() {
+ return "postConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * DELETE method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @DELETE
+ public String deleteConstructorQueryID() {
+ return "deleteConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * GET method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @GET
+ @Path("simple")
+ public String getSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "getSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * PUT method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @DELETE
+ @Path("simple")
+ public String deleteSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "deleteSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * POST method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @PUT
+ @Path("simple")
+ public String putSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "putSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * GET method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @POST
+ @Path("simple")
+ public String postSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "postSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * GET method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @GET
+ @Path("multiple")
+ public String getMultiQueryParameter(@QueryParam("multiParam1") String multiparam1,
+ @QueryParam("123Param") String param123,
+ @QueryParam("1MOREParam") String oneMoreParam) {
+ return "getMultiQueryParameter:" + aQueryID
+ + ";"
+ + multiparam1
+ + ";"
+ + param123
+ + ";"
+ + oneMoreParam;
+ }
+
+ /**
+ * DELETE method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @DELETE
+ @Path("multiple")
+ public String deleteMultiQueryParameter(@QueryParam("multiParam1") String multiparam1,
+ @QueryParam("123Param") String param123,
+ @QueryParam("1MOREParam") String oneMoreParam) {
+ return "deleteMultiQueryParameter:" + aQueryID
+ + ";"
+ + multiparam1
+ + ";"
+ + param123
+ + ";"
+ + oneMoreParam;
+ }
+
+ /**
+ * POST method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @POST
+ @Path("multiple")
+ public String postMultiQueryParameter(@QueryParam("multiParam1") String multiparam1,
+ @QueryParam("123Param") String param123,
+ @QueryParam("1MOREParam") String oneMoreParam) {
+ return "postMultiQueryParameter:" + aQueryID
+ + ";"
+ + multiparam1
+ + ";"
+ + param123
+ + ";"
+ + oneMoreParam;
+ }
+
+ /**
+ * PUT method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @PUT
+ @Path("multiple")
+ public String putMultiQueryParameter(@QueryParam("multiParam1") String multiparam1,
+ @QueryParam("123Param") String param123,
+ @QueryParam("1MOREParam") String oneMoreParam) {
+ return "putMultiQueryParameter:" + aQueryID
+ + ";"
+ + multiparam1
+ + ";"
+ + param123
+ + ";"
+ + oneMoreParam;
+ }
+
+ /**
+ * GET method with multiple primitive typed query parameters.
+ *
+ * @param aBoolean
+ * @param anInteger
+ * @param aDouble
+ * @param aByte
+ * @param ch
+ * @param aLong
+ * @param aShort
+ * @param aFloat
+ * @return a concatenated string in method parameter order
+ */
+ @GET
+ @Path("types/primitive")
+ public String getQueryParameterPrimitiveTypes(@QueryParam("bool") Boolean aBoolean,
+ @QueryParam("intNumber") int anInteger,
+ @QueryParam("dbl") double aDouble,
+ @QueryParam("bite") byte aByte,
+ @QueryParam("ch") char ch,
+ @QueryParam("lng") long aLong,
+ @QueryParam("float") short aShort,
+ @QueryParam("short") float aFloat) {
+ return "getQueryParameterPrimitiveTypes:" + aBoolean
+ + ";"
+ + anInteger
+ + ";"
+ + aDouble
+ + ";"
+ + aByte
+ + ";"
+ + ch
+ + ";"
+ + aLong
+ + ";"
+ + aShort
+ + ";"
+ + aFloat;
+ }
+
+ /**
+ * A type with a public string constructor.
+ */
+ public static class ParamWithStringConstructor {
+ private String value = null;
+
+ /**
+ * Should not be called.
+ */
+ public ParamWithStringConstructor() {
+ value = "noconstructor";
+ }
+
+ /**
+ * Should not be called.
+ *
+ * @param anInt
+ */
+ public ParamWithStringConstructor(Integer anInt) {
+ value = "intconstructor";
+ }
+
+ /**
+ * String constructor
+ *
+ * @param aValue
+ */
+ public ParamWithStringConstructor(String aValue) {
+ this.value = aValue;
+ }
+
+ /**
+ * Transform the value to something else.
+ *
+ * @return a transformed value
+ */
+ public Integer transformedValue() {
+ return Integer.valueOf(value);
+ }
+ }
+
+ /**
+ * GET method to test parameter types with a public string constructor.
+ *
+ * @param param parameter which has a string constructor
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/stringcstr")
+ public String getQueryParameterStringConstructor(@QueryParam("paramStringConstructor") ParamWithStringConstructor param) {
+ return "getQueryParameterStringConstructor:" + param.transformedValue();
+ }
+
+ /**
+ * Type with a public static valueOf method to test query parameters.
+ */
+ public static class ParamWithValueOf {
+ private String value = null;
+
+ protected ParamWithValueOf(String aValue, int aNum) {
+ value = aValue + aNum;
+ }
+
+ /**
+ * The transformed type value
+ *
+ * @return the transformed type value
+ */
+ public String transformedValue() {
+ return value;
+ }
+
+ /**
+ * Public static valueOf method.
+ *
+ * @param aValue string value to transform into type
+ * @return an instance of the type
+ */
+ public static ParamWithValueOf valueOf(String aValue) {
+ return new ParamWithValueOf(aValue, 789);
+ }
+ }
+
+ /**
+ * GET method to test parameter with a static valueOf(String) method.
+ *
+ * @param param the parameter type has a static valueOf(String) method
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/valueof")
+ public String getQueryParameterValueOf(@QueryParam("staticValueOf") ParamWithValueOf param) {
+ return "getQueryParameterValueOf:" + param.transformedValue();
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/form/FormParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/form/FormParamResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/form/FormParamResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/form/FormParamResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.form;
+
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MultivaluedMap;
+
+@Path("params/form")
+public class FormParamResource {
+
+ public FormParamResource() {
+
+ }
+
+ @POST
+ @Path("withOnlyEntity")
+ public String getRes(MultivaluedMap<String, String> entity) {
+ return entity.toString();
+ }
+
+ @POST
+ @Path("withOneKeyAndEntity")
+ public String getRes(@FormParam("firstkey") String firstKey,
+ MultivaluedMap<String, String> entity) {
+ return "firstkey=" + firstKey + "&entity=" + entity.toString();
+ }
+
+ @POST
+ @Path("withStringEntity")
+ public String getStrEntity(String entity) {
+ return "str:" + entity;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/header/HeaderParamDefaultResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/header/HeaderParamDefaultResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/header/HeaderParamDefaultResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/main/java/org/apache/wink/itest/header/HeaderParamDefaultResource.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.header;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+@Path("/params/headerparam/default")
+public class HeaderParamDefaultResource {
+
+ private String customConstructorHeaderParam;
+
+ private String customPropertyHeaderParam;
+
+ private String agent;
+
+ @DefaultValue("english")
+ @HeaderParam("Accept-Language")
+ private String acceptLanguageHeaderParam;
+
+ public HeaderParamDefaultResource(@DefaultValue("MyCustomConstructorHeader") @HeaderParam("CustomConstructorHeader") String cstrHeaderParam) {
+ this.customConstructorHeaderParam = cstrHeaderParam;
+ }
+
+ public Response info(String customMethodHeader) {
+ Response r =
+ Response.status(Status.OK).header("RespCustomConstructorHeader",
+ customConstructorHeaderParam)
+ .header("RespAccept-Language", acceptLanguageHeaderParam)
+ .header("RespCustomMethodHeader", customMethodHeader)
+ .header("RespUserAgent", agent).header("RespCustomPropertyHeader",
+ customPropertyHeaderParam).build();
+ return r;
+ }
+
+ @DefaultValue("MyAgent")
+ @HeaderParam("User-Agent")
+ public void setUserAgent(String aUserAgent) {
+ agent = aUserAgent;
+ }
+
+ public String getUserAgent() {
+ return agent;
+ }
+
+ @DefaultValue("MyCustomPropertyHeader")
+ @HeaderParam("CustomPropertyHeader")
+ public void setCustomPropertyHeader(String customProperty) {
+ customPropertyHeaderParam = customProperty;
+ }
+
+ public String getCustomPropertyHeader() {
+ return customPropertyHeaderParam;
+ }
+
+ @GET
+ public Response getHeaderParam(@DefaultValue("MyCustomMethodHeader") @HeaderParam("CustomMethodHeader") String c) {
+ return info(c);
+ }
+
+ @POST
+ public Response postHeaderParam(@DefaultValue("MyCustomMethodHeader") @HeaderParam("CustomMethodHeader") String c) {
+ return info(c);
+ }
+
+ @PUT
+ public Response putHeaderParam(@DefaultValue("MyCustomMethodHeader") @HeaderParam("CustomMethodHeader") String c) {
+ return info(c);
+ }
+
+ @DELETE
+ public Response deleteHeaderParam(@DefaultValue("MyCustomMethodHeader") @HeaderParam("CustomMethodHeader") String c) {
+ return info(c);
+ }
+
+ /* FIXME: Check if ResponseBuilder header values can be null */
+}