You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by ng...@apache.org on 2009/06/23 07:38:19 UTC
svn commit: r787553 [18/34] - in /incubator/wink/contrib/ibm-jaxrs/tests: ./
fvt/ fvt/demo/ fvt/demo/jaxrs/ fvt/demo/jaxrs/cache/
fvt/demo/jaxrs/cache/server/ fvt/demo/jaxrs/cache/test/
fvt/demo/jaxrs/datasource/ fvt/demo/jaxrs/datasource/server/ fvt/d...
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/MatrixParamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/MatrixParamTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/MatrixParamTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/MatrixParamTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,279 @@
+/*
+ * 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 jaxrs.tests.params.test;
+
+import java.io.IOException;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+
+import framework.defaults.test.DefaultURIInfo;
+import framework.defaults.test.FVTTestCase;
+
+/**
+ * Tests the <code>@MatrixParam</code>.
+ */
+public class MatrixParamTest extends FVTTestCase {
+
+ protected HttpClient httpclient = new HttpClient();
+
+ final private static String BASE_URI = DefaultURIInfo
+ .getClassDefaultBaseURI(MatrixParamTest.class)
+ + "/";
+
+ public static Test suite() {
+ return FVTTestCase.getTestSuite(MatrixParamTest.class,
+ jaxrs.tests.params.server.Application.class.getName());
+ }
+
+ protected String sendGoodRequestAndGetResponse(String aPartialRequestURL, Class<? extends HttpMethod> aClass) {
+ try {
+ HttpMethod httpMethod = aClass.newInstance();
+ httpMethod.setURI(new URI(BASE_URI + aPartialRequestURL, false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(result, 200);
+ return responseBody;
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Tests that no matrix parameters sent still calls proper resource.
+ */
+ public void testNoParam() {
+ assertEquals("deleteConstructorMatrixParam:null",
+ sendGoodRequestAndGetResponse("matrix", DeleteMethod.class));
+ assertEquals("getConstructorMatrixParam:null",
+ sendGoodRequestAndGetResponse("matrix", GetMethod.class));
+ assertEquals("putConstructorMatrixParam:null",
+ sendGoodRequestAndGetResponse("matrix", PutMethod.class));
+ assertEquals("postConstructorMatrixParam:null",
+ sendGoodRequestAndGetResponse("matrix", PostMethod.class));
+ }
+
+ /**
+ * Tests the constructor matrix parameter is processed.
+ */
+ public void testConstructorParam() {
+ assertEquals("getConstructorMatrixParam:HelloWorld",
+ sendGoodRequestAndGetResponse("matrix;cstrparam=HelloWorld",
+ GetMethod.class));
+ assertEquals("deleteConstructorMatrixParam:HelloWorld",
+ sendGoodRequestAndGetResponse("matrix;cstrparam=HelloWorld",
+ DeleteMethod.class));
+ assertEquals("putConstructorMatrixParam:HelloWorld",
+ sendGoodRequestAndGetResponse("matrix;cstrparam=HelloWorld",
+ PutMethod.class));
+ assertEquals("postConstructorMatrixParam:HelloWorld",
+ sendGoodRequestAndGetResponse("matrix;cstrparam=HelloWorld",
+ PostMethod.class));
+ }
+
+ /**
+ * Tests both the simple constructor and method matrix parameter are
+ * processed.
+ */
+ public void testSimpleMatrixParam() {
+ assertEquals("getSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;cstrparam=Hello;life=good",
+ GetMethod.class));
+ assertEquals("putSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;cstrparam=Hello;life=good",
+ PutMethod.class));
+ assertEquals("postSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;cstrparam=Hello;life=good",
+ PostMethod.class));
+ assertEquals("deleteSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;cstrparam=Hello;life=good",
+ DeleteMethod.class));
+ }
+
+ /**
+ * Tests that a no constructor matrix parameter is set.
+ */
+ public void testNoConstructorMatrixParamAndSimpleMatrixParam() {
+ assertEquals("deleteSimpleMatrixParam:null;erase",
+ sendGoodRequestAndGetResponse("matrix/simple;life=erase",
+ DeleteMethod.class));
+ assertEquals("getSimpleMatrixParam:null;good",
+ sendGoodRequestAndGetResponse("matrix/simple;life=good",
+ GetMethod.class));
+ assertEquals("postSimpleMatrixParam:null;new",
+ sendGoodRequestAndGetResponse("matrix/simple;life=new",
+ PostMethod.class));
+ assertEquals("putSimpleMatrixParam:null;progress",
+ sendGoodRequestAndGetResponse("matrix/simple;life=progress",
+ PutMethod.class));
+ }
+
+ /**
+ * Tests the constructor and simple matrix parameter can be out of order.
+ */
+ public void testOutOfOrderMatrixParam() {
+ assertEquals("getSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;life=good;cstrparam=Hello;",
+ GetMethod.class));
+ assertEquals("putSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;life=good;cstrparam=Hello;",
+ PutMethod.class));
+ assertEquals("postSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;life=good;cstrparam=Hello",
+ PostMethod.class));
+ assertEquals("deleteSimpleMatrixParam:Hello;good",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;life=good;cstrparam=Hello",
+ DeleteMethod.class));
+ }
+
+ /**
+ * Tests that matrix parameters are case sensitive.
+ */
+ public void testLowercaseMatrixParam() {
+ assertEquals("getSimpleMatrixParam:null;null",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;LIFE=good;cstrParam=Hello",
+ GetMethod.class));
+ assertEquals("postSimpleMatrixParam:null;null",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;LIFE=good;cstrParam=Hello",
+ PostMethod.class));
+ assertEquals("putSimpleMatrixParam:null;null",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;LIFE=good;cstrParam=Hello",
+ PutMethod.class));
+ assertEquals("deleteSimpleMatrixParam:null;null",
+ sendGoodRequestAndGetResponse(
+ "matrix/simple;LIFE=good;cstrParam=Hello",
+ DeleteMethod.class));
+ }
+
+ /**
+ * Tests multiple matrix parameters sent to same resource.
+ */
+ public void testMultipleMatrixParam() {
+ assertEquals(
+ "getMultipleMatrixParam:first;capital;done",
+ sendGoodRequestAndGetResponse(
+ "matrix/multiple;1st=first;ONEMOREPARAM=capital;onemoreparam=done",
+ GetMethod.class));
+ assertEquals(
+ "deleteMultipleMatrixParam:first;capital;done",
+ sendGoodRequestAndGetResponse(
+ "matrix/multiple;1st=first;ONEMOREPARAM=capital;onemoreparam=done",
+ DeleteMethod.class));
+ assertEquals(
+ "postMultipleMatrixParam:first;capital;done",
+ sendGoodRequestAndGetResponse(
+ "matrix/multiple;1st=first;ONEMOREPARAM=capital;onemoreparam=done",
+ PostMethod.class));
+ assertEquals(
+ "putMultipleMatrixParam:first;capital;done",
+ sendGoodRequestAndGetResponse(
+ "matrix/multiple;1st=first;ONEMOREPARAM=capital;onemoreparam=done",
+ PutMethod.class));
+ }
+
+ /**
+ * Tests that primitive types are accepted in matrix parameters.
+ */
+ public void testPrimitiveTypedMatrixParameter() {
+ assertEquals(
+ "getMatrixParameterPrimitiveTypes:false;12;3.14;3;b;1234567890;32456;123.0",
+ sendGoodRequestAndGetResponse(
+ "matrix/types/primitive;bool=false;intNumber=12;dbl=3.14;bite=3;ch=b;lng=1234567890;float=32456;short=123",
+ GetMethod.class));
+ }
+
+ /**
+ * Tests that primitive types are accepted in parameters.
+ */
+ public void testParameterTypeWithStringConstructor() {
+ assertEquals("getMatrixParameterStringConstructor:1234",
+ sendGoodRequestAndGetResponse(
+ "matrix/types/stringcstr;paramStringConstructor=1234",
+ GetMethod.class));
+ }
+
+ /**
+ * Tests that primitive types are accepted in parameters.
+ */
+ public void testParameterTypeWithValueOfMethod() {
+ assertEquals("getMatrixParameterValueOf:456789",
+ sendGoodRequestAndGetResponse(
+ "matrix/types/valueof;staticValueOf=456",
+ GetMethod.class));
+ }
+
+ /*
+ * TODO: More tests.
+ *
+ * Need to add urlencoding tests
+ *
+ * Need to add "weird" parameter tests (i.e. not standard inputs)
+ *
+ * Need to add precedence tests
+ *
+ * Need to add where both constructor and major get are in the same URL
+ *
+ * Need to add invalid tests.
+ *
+ * Need to add mixed tests and error tests for special parameters (i.e. not
+ * strings)
+ *
+ * Need to test cases where more/less inputs are given than expected
+ */
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/ParamQueryNotSetTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/ParamQueryNotSetTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/ParamQueryNotSetTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/ParamQueryNotSetTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,736 @@
+/*
+ * 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 jaxrs.tests.params.test;
+
+import java.util.Random;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+
+import framework.defaults.test.FVTTestCase;
+
+public class ParamQueryNotSetTest extends FVTTestCase {
+
+ protected HttpClient httpclient = new HttpClient();
+
+ private static Random r = new Random();
+
+ public static Test suite() {
+ return FVTTestCase.getTestSuite(ParamQueryNotSetTest.class,
+ jaxrs.tests.params.server.Application.class.getName());
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testCharParamEmpty() throws Exception {
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/char");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals('\u0000' + "", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/char?letter=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals('a' + "", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/char?lette=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals('\u0000' + "", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/char;letter=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals('a' + "", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/char");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals('\u0000' + "", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/char;lette=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals('\u0000' + "", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testByteParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/byte");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ byte b = (byte) r.nextInt(Byte.MAX_VALUE);
+ System.out.println(b);
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/byte?b="
+ + b);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + b, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/byte?b1=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ b = (byte) r.nextInt(Byte.MAX_VALUE);
+ System.out.println(b);
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/byte;b="
+ + b);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + b, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/byte");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/byte;b1=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testDoubleParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/double");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ double d = r.nextDouble();
+ System.out.println(d);
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/double?d="
+ + d);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + d, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/double?d1=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ d = r.nextDouble();
+ System.out.println(d);
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/double;count=" + d);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + d, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/double");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/double;coun=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testFloatParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/float");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ float f = r.nextFloat();
+ System.out.println(f);
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/float?floatCount=" + f);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + f, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/float?floatCount1=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ f = r.nextFloat();
+ System.out.println(f);
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/float;floatCount=" + f);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + f, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/float");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/float;floatCoun=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0.0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testIntParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/int");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ int i = r.nextInt();
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/int?count="
+ + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + i, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/int?coun=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ i = r.nextInt();
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/int;count=" + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + i, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/int");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/int;coun=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testShortParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/short");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ short i = (short) r.nextInt(Short.MAX_VALUE);
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/short?smallCount=" + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + i, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/short?smallcount=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ i = (short) r.nextInt(Short.MAX_VALUE);
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/short;smallCount=" + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + i, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/short");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/short;smallCoun=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testLongParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/long");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ long i = r.nextLong();
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/long?longCount=" + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + i, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/long?longount=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ i = r.nextLong();
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/long;longCount=" + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("" + i, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/long");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/long;longCoun=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testSetParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/set");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ int i = r.nextInt();
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/set?bag="
+ + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("1", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI() + "/queryparamnotset/set?bg=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ i = r.nextInt();
+ System.out.println(i);
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/set;bag="
+ + i);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("1", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/set");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/set;bg=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that given a HttpMethod with a query or matrix parameter, if the
+ * parameter is not sent, then the default value is given back for basic
+ * Java types.
+ */
+ public void testListParamEmpty() throws Exception {
+ /*
+ * query parameters
+ */
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/list");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ char c = 'b';
+ System.out.println(c);
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/list?letter=" + c);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("1", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * don't send in the right query
+ */
+ getMethod = new GetMethod(getBaseURI()
+ + "/queryparamnotset/list?lette=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * matrix parameters
+ */
+ System.out.println(c);
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/list;letter=" + c);
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("1", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/matrixparamnotset/list");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI()
+ + "/matrixparamnotset/list;lette=a");
+ try {
+ httpclient.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("0", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/PathSegmentTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/PathSegmentTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/PathSegmentTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/PathSegmentTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,117 @@
+/*
+ * 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 jaxrs.tests.params.test;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+
+import framework.defaults.test.DefaultURIInfo;
+import framework.defaults.test.FVTTestCase;
+
+public class PathSegmentTest extends FVTTestCase {
+
+ private static HttpClient httpclient = new HttpClient();
+
+ public String getBaseURI() {
+ return DefaultURIInfo.getClassDefaultBaseURI(PathSegmentTest.class)
+ + "/params/pathsegment";
+ }
+
+ public static Test suite() {
+ return FVTTestCase.getTestSuite(PathSegmentTest.class,
+ jaxrs.tests.params.server.Application.class.getName());
+ }
+
+ public void testPathSegmentNoMatrixParameters() throws Exception {
+ GetMethod httpMethod = new GetMethod(getBaseURI() + "/somepath");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("somepath", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(getBaseURI() + "/123456");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("123456", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(getBaseURI() + "/123456;mp=3145");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("123456", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+
+ public void testPathSegmentMatrixParameters() throws Exception {
+ GetMethod httpMethod = new GetMethod(getBaseURI() + "/matrix/somepath");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("somepath-somepath-null-null", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(getBaseURI() + "/matrix/somepath;mp=val");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("somepath;mp=val-somepath-null-val", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(getBaseURI()
+ + "/matrix/somepath;mp=val;val=abc");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("somepath;mp=val;val=abc-somepath-[abc]-val",
+ httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(getBaseURI()
+ + "/matrix/somepath;mp=val;val=abc;val=123");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals(
+ "somepath;mp=val;val=abc;val=123-somepath-[abc, 123]-val",
+ httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/QueryParamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/QueryParamTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/QueryParamTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/test/QueryParamTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,425 @@
+/*
+ * 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 jaxrs.tests.params.test;
+
+import java.io.IOException;
+
+import jaxrs.tests.params.server.QueryParamResource;
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+
+import framework.defaults.test.DefaultURIInfo;
+import framework.defaults.test.FVTTestCase;
+
+/**
+ * Tests the <code>@QueryParam</code> annotation on a simple JAX-RS resource.
+ *
+ * @see QueryParamResource
+ */
+public class QueryParamTest extends FVTTestCase {
+
+ protected HttpClient httpclient = new HttpClient();
+
+ final private static String BASE_URI = DefaultURIInfo
+ .getClassDefaultBaseURI(QueryParamTest.class)
+ + "/";
+
+ public static Test suite() {
+ return FVTTestCase.getTestSuite(QueryParamTest.class,
+ jaxrs.tests.params.server.Application.class.getName());
+ }
+
+ protected String sendGoodRequestAndGetResponse(String aPartialRequestURL, Class<? extends HttpMethod> aClass) {
+ try {
+ HttpMethod httpMethod = aClass.newInstance();
+ httpMethod.setURI(new URI(BASE_URI + aPartialRequestURL, false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(result, 200);
+ return responseBody;
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Tests that no query parameters sent still calls proper resource.
+ */
+ public void testNoQueryParam() {
+ assertEquals("deleteConstructorQueryID:null",
+ sendGoodRequestAndGetResponse("query", DeleteMethod.class));
+ assertEquals("getConstructorQueryID:null",
+ sendGoodRequestAndGetResponse("query", GetMethod.class));
+ assertEquals("postConstructorQueryID:null",
+ sendGoodRequestAndGetResponse("query", PostMethod.class));
+ assertEquals("putConstructorQueryID:null",
+ sendGoodRequestAndGetResponse("query", PutMethod.class));
+ }
+
+ /**
+ * Tests the constructor query parameter is processed.
+ */
+ public void testConstructorQueryParam() {
+ assertEquals("deleteConstructorQueryID:HelloWorld",
+ sendGoodRequestAndGetResponse("query?queryid=HelloWorld",
+ DeleteMethod.class));
+ assertEquals("getConstructorQueryID:HelloWorld",
+ sendGoodRequestAndGetResponse("query?queryid=HelloWorld",
+ GetMethod.class));
+ assertEquals("postConstructorQueryID:HelloWorld",
+ sendGoodRequestAndGetResponse("query?queryid=HelloWorld",
+ PostMethod.class));
+ assertEquals("putConstructorQueryID:HelloWorld",
+ sendGoodRequestAndGetResponse("query?queryid=HelloWorld",
+ PutMethod.class));
+ }
+
+ /**
+ * Tests both the simple constructor and method parameter are processed.
+ */
+ public void testSimpleQueryParam() {
+ assertEquals("deleteSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?queryid=somequeryid&simpleParam=hi",
+ DeleteMethod.class));
+ assertEquals("getSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?queryid=somequeryid&simpleParam=hi",
+ GetMethod.class));
+ assertEquals("postSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?queryid=somequeryid&simpleParam=hi",
+ PostMethod.class));
+ assertEquals("putSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?queryid=somequeryid&simpleParam=hi",
+ PutMethod.class));
+ }
+
+ /**
+ * Tests that a no constructor query parameter is set.
+ */
+ public void testNoConstructorQueryParamAndSimpleQueryParam() {
+ assertEquals("deleteSimpleQueryParameter:null;hi",
+ sendGoodRequestAndGetResponse("query/simple/?simpleParam=hi",
+ DeleteMethod.class));
+ assertEquals("getSimpleQueryParameter:null;hi",
+ sendGoodRequestAndGetResponse("query/simple/?simpleParam=hi",
+ GetMethod.class));
+ assertEquals("postSimpleQueryParameter:null;hi",
+ sendGoodRequestAndGetResponse("query/simple/?simpleParam=hi",
+ PostMethod.class));
+ assertEquals("putSimpleQueryParameter:null;hi",
+ sendGoodRequestAndGetResponse("query/simple/?simpleParam=hi",
+ PutMethod.class));
+ }
+
+ /**
+ * Tests the constructor and simple query parameter can be out of order.
+ */
+ public void testOutOfOrderSimpleQueryParam() {
+ assertEquals("deleteSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?simpleParam=hi&queryid=somequeryid",
+ DeleteMethod.class));
+ assertEquals("getSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?simpleParam=hi&queryid=somequeryid",
+ GetMethod.class));
+ assertEquals("postSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?simpleParam=hi&queryid=somequeryid",
+ PostMethod.class));
+ assertEquals("putSimpleQueryParameter:somequeryid;hi",
+ sendGoodRequestAndGetResponse(
+ "query/simple?simpleParam=hi&queryid=somequeryid",
+ PutMethod.class));
+ }
+
+ /**
+ * Tests that query parameters are case sensitive.
+ */
+ public void testLowercaseQueryParam() {
+ assertEquals("getSimpleQueryParameter:null;null",
+ sendGoodRequestAndGetResponse(
+ "query/simple/?simpleparam=hi&QUERYID=abcd",
+ GetMethod.class));
+ assertEquals("postSimpleQueryParameter:null;null",
+ sendGoodRequestAndGetResponse(
+ "query/simple/?simpleparam=hi&QUERYID=abcd",
+ PostMethod.class));
+ assertEquals("putSimpleQueryParameter:null;null",
+ sendGoodRequestAndGetResponse(
+ "query/simple/?simpleparam=hi&QUERYID=abcd",
+ PutMethod.class));
+ assertEquals("deleteSimpleQueryParameter:null;null",
+ sendGoodRequestAndGetResponse(
+ "query/simple/?simpleparam=hi&QUERYID=abcd",
+ DeleteMethod.class));
+ }
+
+ /**
+ * Tests multiple query parameters sent to same resource.
+ */
+ public void testMultipleQueryParam() {
+ assertEquals(
+ "getMultiQueryParameter:somequeryid;hi;789;1moreparam2go",
+ sendGoodRequestAndGetResponse(
+ "query/multiple?queryid=somequeryid&multiParam1=hi&123Param=789&1MOREParam=1moreparam2go",
+ GetMethod.class));
+ assertEquals(
+ "deleteMultiQueryParameter:somequeryid;hi;789;1moreparam2go",
+ sendGoodRequestAndGetResponse(
+ "query/multiple?queryid=somequeryid&multiParam1=hi&123Param=789&1MOREParam=1moreparam2go",
+ DeleteMethod.class));
+ assertEquals(
+ "putMultiQueryParameter:somequeryid;hi;789;1moreparam2go",
+ sendGoodRequestAndGetResponse(
+ "query/multiple?queryid=somequeryid&multiParam1=hi&123Param=789&1MOREParam=1moreparam2go",
+ PutMethod.class));
+ assertEquals(
+ "postMultiQueryParameter:somequeryid;hi;789;1moreparam2go",
+ sendGoodRequestAndGetResponse(
+ "query/multiple?queryid=somequeryid&multiParam1=hi&123Param=789&1MOREParam=1moreparam2go",
+ PostMethod.class));
+ }
+
+ /**
+ * Tests that primitive types are accepted in query parameters.
+ */
+ public void testPrimitiveTypedQueryParameter() {
+ assertEquals(
+ "getQueryParameterPrimitiveTypes:false;12;3.14;3;b;1234567890;32456;123.0",
+ sendGoodRequestAndGetResponse(
+ "query/types/primitive?bool=false&intNumber=12&dbl=3.14&bite=3&ch=b&lng=1234567890&float=32456&short=123",
+ GetMethod.class));
+ }
+
+ /**
+ * Tests that primitive types are accepted in query parameters.
+ */
+ public void testParameterTypeWithStringConstructor() {
+ assertEquals("getQueryParameterStringConstructor:1234",
+ sendGoodRequestAndGetResponse(
+ "query/types/stringcstr?paramStringConstructor=1234",
+ GetMethod.class));
+ }
+
+ /**
+ * Tests that primitive types are accepted in query parameters.
+ */
+ public void testParameterTypeWithValueOfMethod() {
+ assertEquals("getQueryParameterValueOf:456789",
+ sendGoodRequestAndGetResponse(
+ "query/types/valueof?staticValueOf=456",
+ GetMethod.class));
+ }
+
+ public void testQueryParamException() throws Exception {
+ HttpClient httpclient = new HttpClient();
+
+ /*
+ * query constructor field exceptions
+ */
+ GetMethod httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/fieldstrcstr?CustomStringConstructorFieldQuery=throwWeb");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(499, httpMethod.getStatusCode());
+ assertEquals("ParamStringConstructor", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/fieldstrcstr?CustomStringConstructorFieldQuery=throwNull");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/fieldstrcstr?CustomStringConstructorFieldQuery=throwEx");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ /*
+ * query value of field exceptions
+ */
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/fieldvalueof?CustomValueOfFieldQuery=throwWeb");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(498, httpMethod.getStatusCode());
+ assertEquals("ParamValueOfWebAppEx", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/fieldvalueof?CustomValueOfFieldQuery=throwNull");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/fieldvalueof?CustomValueOfFieldQuery=throwEx");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ /*
+ * query string constructor property exceptions
+ */
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/propertystrcstr?CustomStringConstructorPropertyHeader=throwWeb");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(499, httpMethod.getStatusCode());
+ assertEquals("ParamStringConstructor", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/propertystrcstr?CustomStringConstructorPropertyHeader=throwNull");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/propertystrcstr?CustomStringConstructorPropertyHeader=throwEx");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ /*
+ * query value of property exceptions
+ */
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/propertyvalueof?CustomValueOfPropertyHeader=throwWeb");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(498, httpMethod.getStatusCode());
+ assertEquals("ParamValueOfWebAppEx", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/propertyvalueof?CustomValueOfPropertyHeader=throwNull");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/propertyvalueof?CustomValueOfPropertyHeader=throwEx");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+
+ httpMethod = new GetMethod(
+ BASE_URI
+ + "params/queryparam/exception/primitive?CustomNumQuery=notANumber");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ assertEquals("", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?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 name="jaxrs.tests.path" default="all">
+ <import file="../../../buildCommon.xml" />
+</project>
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,44 @@
+/*
+ * 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 jaxrs.tests.path.server;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Path 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(PathResource.class);
+ classes.add(PathWarningResource.class);
+ classes = Collections.unmodifiableSet(classes);
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,27 @@
+/*
+ * 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 jaxrs.tests.path.server;
+
+import javax.ws.rs.Path;
+
+@Path("/path")
+public class PathResource {
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathWarningResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathWarningResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathWarningResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/server/PathWarningResource.java Tue Jun 23 05:37:57 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 jaxrs.tests.path.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/pathwarnings")
+public class PathWarningResource {
+
+ @SuppressWarnings("unused")
+ @GET
+ @Path("/private")
+ private String getPrivateMethod() {
+ return "You shouldn't find me.";
+ }
+
+ @GET
+ @Path("/protected")
+ protected String getProtectedMethod() {
+ return "You shouldn't find me.";
+ }
+
+ @GET
+ @Path("/package")
+ String getPackageMethod() {
+ return "You shouldn't find me.";
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/test/PathWarningTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/test/PathWarningTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/test/PathWarningTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/path/test/PathWarningTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,120 @@
+/*
+ * 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 jaxrs.tests.path.test;
+
+import java.io.IOException;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.GetMethod;
+
+import framework.defaults.test.DefaultURIInfo;
+import framework.defaults.test.FVTTestCase;
+
+/**
+ *
+ */
+public class PathWarningTest extends FVTTestCase {
+
+ protected HttpClient httpclient = new HttpClient();
+
+ final private static String BASE_URI = DefaultURIInfo
+ .getClassDefaultBaseURI(PathWarningTest.class)
+ + "/pathwarnings";
+
+ public static Test suite() {
+ return FVTTestCase.getTestSuite(PathWarningTest.class,
+ jaxrs.tests.path.server.Application.class.getName());
+ }
+
+ public void testNonPublicMethodPathWarning() {
+ try {
+ GetMethod httpMethod = new GetMethod();
+ httpMethod.setURI(new URI(BASE_URI + "/private", false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(404, result);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ GetMethod httpMethod = new GetMethod();
+ httpMethod.setURI(new URI(BASE_URI + "/protected", false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(404, result);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ GetMethod httpMethod = new GetMethod();
+ httpMethod.setURI(new URI(BASE_URI + "/package", false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(404, result);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?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 name="jaxrs.tests.providers.messagebodyreader" default="all">
+ <import file="../../../../buildCommon.xml" />
+</project>
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/Application.java Tue Jun 23 05:37:57 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 jaxrs.tests.providers.messagebodyreader.server;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> clazzes = new HashSet<Class<?>>();
+ clazzes.add(ReaderResource.class);
+ return clazzes;
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ Set<Object> objs = new HashSet<Object>();
+ objs.add(new MessageBodyReaderAnnotationList());
+ objs.add(new MessageBodyReaderMediaTypeSet());
+ objs.add(new MessageBodyReaderGenericEntityTypeQueue());
+ objs.add(new MessageBodyReaderClassDeque());
+ objs.add(new MessageBodyReaderThrowsExceptions());
+ objs.add(new MessageBodyReaderIsReadableThrowsRuntimeException());
+ objs.add(new MessageBodyReaderIsReadableThrowsWebAppException());
+ objs.add(new MessageBodyReaderReadFromDifferent());
+ objs.add(new MessageBodyReaderGenericType());
+ return objs;
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/CustomAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/CustomAnnotation.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/CustomAnnotation.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/CustomAnnotation.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,32 @@
+/*
+ * 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 jaxrs.tests.providers.messagebodyreader.server;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.LOCAL_VARIABLE,
+ ElementType.PARAMETER })
+public @interface CustomAnnotation {
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderAnnotationList.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderAnnotationList.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderAnnotationList.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderAnnotationList.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,61 @@
+/*
+ * 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 jaxrs.tests.providers.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+@Consumes("text/plain")
+public class MessageBodyReaderAnnotationList implements MessageBodyReader<List> {
+
+ public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+ for (Annotation ann : arg2) {
+ if (MyReaderAnnotation.class.equals(ann.annotationType())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List readFrom(Class<List> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+ throws IOException, WebApplicationException {
+ String str = null;
+ try {
+ str = IOUtils.toString(arg5);
+ } catch (IOException e) {
+ throw new WebApplicationException(e);
+ }
+ return Arrays.asList(str.split("\r\n"));
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderClassDeque.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderClassDeque.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderClassDeque.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderClassDeque.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,59 @@
+/*
+ * 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 jaxrs.tests.providers.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Deque;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+public class MessageBodyReaderClassDeque implements MessageBodyReader<Object> {
+
+ public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+ if (arg0.equals(Deque.class)) {
+ return true;
+ }
+ return false;
+ }
+
+ public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+ throws IOException, WebApplicationException {
+ String str = null;
+ try {
+ str = IOUtils.toString(arg5);
+ } catch (IOException e) {
+ throw new WebApplicationException(e);
+ }
+ return new ArrayDeque<String>(Arrays.asList(str.split("\r\n")));
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericEntityTypeQueue.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericEntityTypeQueue.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericEntityTypeQueue.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericEntityTypeQueue.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,64 @@
+/*
+ * 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 jaxrs.tests.providers.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Queue;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+public class MessageBodyReaderGenericEntityTypeQueue implements MessageBodyReader<Queue> {
+
+ public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+ if (arg1 instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) arg1;
+ Type[] actualArgumentTypes = pt.getActualTypeArguments();
+ return actualArgumentTypes != null
+ && actualArgumentTypes.length == 1
+ && String.class.equals(actualArgumentTypes[0]);
+ }
+ return false;
+ }
+
+ public Queue readFrom(Class<Queue> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+ throws IOException, WebApplicationException {
+ String str = null;
+ try {
+ str = IOUtils.toString(arg5);
+ } catch (IOException e) {
+ throw new WebApplicationException(e);
+ }
+ return new ArrayDeque<String>(Arrays.asList(str.split("\r\n")));
+ }
+
+}