You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by jr...@apache.org on 2009/07/14 21:47:02 UTC

svn commit: r794036 [3/3] - in /incubator/wink/trunk/wink-integration-test/wink-server-integration-test: ./ wink-jaxrs-test-params/ wink-jaxrs-test-params/src/ wink-jaxrs-test-params/src/main/ wink-jaxrs-test-params/src/main/java/ wink-jaxrs-test-param...

Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/ParamQueryNotSetTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/ParamQueryNotSetTest.java?rev=794036&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/ParamQueryNotSetTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/ParamQueryNotSetTest.java Tue Jul 14 19:47:00 2009
@@ -0,0 +1,685 @@
+/*
+ * 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.jaxrs.test.params;
+
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class ParamQueryNotSetTest extends TestCase {
+
+    protected HttpClient  httpclient = new HttpClient();
+
+    private static Random r          = new Random();
+
+    private String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/params";
+    }
+
+    /**
+     * 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/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/PathSegmentTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/PathSegmentTest.java?rev=794036&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/PathSegmentTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/PathSegmentTest.java Tue Jul 14 19:47:00 2009
@@ -0,0 +1,104 @@
+/*
+ * 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.jaxrs.test.params;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class PathSegmentTest extends TestCase {
+
+    private static HttpClient httpclient = new HttpClient();
+
+    public String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/params/params/pathsegment";
+    }
+
+    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-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-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-somepath-[abc, 123]-val", httpMethod
+                .getResponseBodyAsString());
+        } finally {
+            httpMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java?rev=794036&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java Tue Jul 14 19:47:00 2009
@@ -0,0 +1,381 @@
+/*
+ * 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.jaxrs.test.params;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+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 org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Tests the <code>@QueryParam</code> annotation on a simple JAX-RS resource.
+ * 
+ * @see QueryParamResource
+ */
+public class QueryParamTest extends TestCase {
+
+    protected HttpClient        httpclient = new HttpClient();
+
+    final private static String BASE_URI   = ServerEnvironmentInfo.getBaseURI() + "/params/";
+
+    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();
+        }
+    }
+}