wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r816947 [3/3] - in /incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest: environment/servlets/ httpheaders/ providers/ request/ securitycontext/ uriinfo/
Date Sat, 19 Sep 2009 19:38:26 GMT
Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java?rev=816947&r1=816946&r2=816947&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java Sat Sep 19 19:38:24 2009
@@ -37,7 +37,7 @@
  */
 public class URIInfoDetailedMethodTest extends TestCase {
 
-    public static String appBase = "/uriinfo";
+    private static String appBase = "/uriinfo";
 
     static {
         if (ServerEnvironmentInfo.isRestFilterUsed()) {
@@ -45,13 +45,20 @@
         }
     }
 
-    public String getBaseURI() {
+    private static String getBaseURI() {
         if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/uriinfo";
     }
 
+    protected HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests the {@link UriInfo#getAbsolutePath()}.
      * 
@@ -59,7 +66,6 @@
      * @throws IOException
      */
     public void testURIInfoGetAbsolutePath() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getAbsolutePath");
         try {
@@ -79,7 +85,6 @@
      * @throws IOException
      */
     public void testURIInfoGetAbsoluteBuilder() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getAbsolutePathBuilder");
         try {
@@ -99,7 +104,6 @@
      * @throws IOException
      */
     public void testURIInfoGetBaseUri() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getBaseUri");
         try {
@@ -118,7 +122,6 @@
      * @throws IOException
      */
     public void testURIInfoGetBaseUriBuilder() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getBaseUriBuilder");
         try {
@@ -148,7 +151,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPath() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPath");
         try {
@@ -167,7 +169,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathDecoded() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathDecodedTrue");
         try {
@@ -221,7 +222,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedResourcesSimple() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedResources");
         try {
@@ -241,7 +241,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedResourcesSubresource() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed/matchedresources");
         try {
@@ -265,7 +264,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedURIs() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIs");
         try {
@@ -284,7 +282,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedURIsSubresource() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/matcheduris");
         try {
             client.executeMethod(getMethod);
@@ -309,7 +306,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedURIsDecodeTrue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIsDecodedTrue");
@@ -329,7 +325,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedURIsDecodeFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIsDecodedFalse");
@@ -349,7 +344,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedURIsSublocatorDecodeTrue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed/matchedurisdecoded/!%40%23%24%25%5E%26*()?decoded=true");
@@ -370,7 +364,6 @@
      * @throws IOException
      */
     public void testURIInfoGetMatchedURIsSublocatorDecodeFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed/matchedurisdecoded/!%40%23%24%25%5E%26*()?decoded=false");
@@ -391,7 +384,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersZero() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParameters");
         try {
@@ -410,7 +402,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersOne() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/");
         try {
@@ -456,7 +447,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersMany() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar/xyz");
         try {
@@ -485,7 +475,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersZeroDecodedFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParametersDecodedFalse");
@@ -505,7 +494,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersOneDecodedFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/?decoded=false");
         try {
@@ -557,7 +545,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersManyDecodedFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar/xyz?decoded=false");
@@ -588,7 +575,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersZeroDecodedTrue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParametersDecodedTrue");
@@ -608,7 +594,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersOneDecodedTrue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/?decoded=true");
         try {
@@ -659,7 +644,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathParametersManyDecodedTrue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/!%40%23%24%25%5E%26*()/bar/xyz?decoded=true");
@@ -690,7 +674,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathSegments() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathSegments");
         try {
@@ -733,7 +716,6 @@
      * @throws IOException
      */
     public void testURIInfoGetPathSegmentsDecodedFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse");
@@ -777,7 +759,6 @@
      * @throws IOException
      */
     public void testURIInfoGetQueryParametersZero() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/queryparams");
         try {
             client.executeMethod(getMethod);
@@ -795,7 +776,6 @@
      * @throws IOException
      */
     public void testURIInfoGetQueryParametersOne() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getQueryParameters");
         try {
@@ -835,7 +815,6 @@
      * @throws IOException
      */
     public void testURIInfoGetQueryParametersMany() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q2=value2");
@@ -866,7 +845,6 @@
      * @throws IOException
      */
     public void testURIInfoGetQueryParametersManyDecodedFalse() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=!%40%23%24%25%5E%26*()&q2=value2&decoded=false");
@@ -887,7 +865,6 @@
      * @throws IOException
      */
     public void testURIInfoGetRequestUri() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUri");
         try {
@@ -907,7 +884,6 @@
      * @throws IOException
      */
     public void testURIInfoGetRequestUriBuilder() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUriBuilder");
         try {

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java?rev=816947&r1=816946&r2=816947&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java Sat Sep 19 19:38:24 2009
@@ -33,13 +33,20 @@
  */
 public class URIInfoInjectionTest extends TestCase {
 
-    public String getBaseURI() {
+    private static String getBaseURI() {
         if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/uriinfo";
     }
 
+    private HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests that a URIInfo object is injected into method parameters.
      * 
@@ -47,7 +54,6 @@
      * @throws HttpException
      */
     public void testURIInfoParamInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/param");
         try {
             client.executeMethod(getMethod);
@@ -64,7 +70,6 @@
      * @throws HttpException
      */
     public void testURIInfoBeanMethodInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/bean");
         try {
             client.executeMethod(getMethod);
@@ -81,7 +86,6 @@
      * @throws HttpException
      */
     public void testURIInfoConstructorInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/constructor");
         try {
             client.executeMethod(getMethod);
@@ -98,7 +102,6 @@
      * @throws HttpException
      */
     public void testURIInfoFieldMemberInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/field");
         try {
             client.executeMethod(getMethod);
@@ -115,7 +118,6 @@
      * @throws HttpException
      */
     public void testURIInfoNotBeanMethod() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/notbeanmethod");
         try {
             client.executeMethod(getMethod);

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java?rev=816947&r1=816946&r2=816947&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java Sat Sep 19 19:38:24 2009
@@ -30,7 +30,7 @@
     private static String appRoot = "/uriinfo";
 
     static {
-        if(ServerEnvironmentInfo.isRestFilterUsed()) {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
             appRoot = "";
         }
     }
@@ -42,14 +42,19 @@
         return ServerEnvironmentInfo.getBaseURI() + appRoot;
     }
 
+    private HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests that a normal "good" path is returned.
      * 
      * @throws Exception
      */
     public void testPathNormal() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo?info=path");
         try {
             client.executeMethod(getMethod);
@@ -67,8 +72,6 @@
      * @throws Exception
      */
     public void testRemoveResourcePathThenAddItBack() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo/../uriinfo" + "?info=path");
         try {
             client.executeMethod(getMethod);
@@ -139,8 +142,6 @@
      * @throws Exception
      */
     public void testAddPathThenRemoveIt() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo/something/../" + "?info=path");
         try {
             client.executeMethod(getMethod);
@@ -188,7 +189,6 @@
      * @throws Exception
      */
     public void testCapitalization() throws Exception {
-        HttpClient client = new HttpClient();
         String contextRoot = ServerEnvironmentInfo.getContextRoot();
         if (!"".equals(contextRoot)) {
             contextRoot = "/" + contextRoot;
@@ -270,8 +270,6 @@
      * @throws Exception
      */
     public void testPercentEncoding() throws Exception {
-        HttpClient client = new HttpClient();
-
         /*
          * regular query
          */

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoDetailedMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoDetailedMethodTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoDetailedMethodTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoDetailedMethodTest.java Sat Sep 19 19:38:24 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 org.apache.wink.itest.uriinfo;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheURIInfoDetailedMethodTest extends WinkURIInfoDetailedMethodTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoDetailedMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoInjectionTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoInjectionTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoInjectionTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoInjectionTest.java Sat Sep 19 19:38:24 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 org.apache.wink.itest.uriinfo;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheURIInfoInjectionTest extends WinkURIInfoInjectionTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoInjectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoNormalizationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoNormalizationTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoNormalizationTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoNormalizationTest.java Sat Sep 19 19:38:24 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.wink.itest.uriinfo;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheURIInfoNormalizationTest extends WinkURIInfoNormalizationTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoNormalizationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoDetailedMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoDetailedMethodTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoDetailedMethodTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoDetailedMethodTest.java Sat Sep 19 19:38:24 2009
@@ -0,0 +1,681 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.wink.itest.uriinfo;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.UriInfo;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class WinkURIInfoDetailedMethodTest extends TestCase {
+
+    private static String appBase = "/uriinfo";
+
+    static {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            appBase = "";
+        }
+    }
+
+    private static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/uriinfo";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests the {@link UriInfo#getAbsolutePath()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetAbsolutePath() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getAbsolutePath")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(getBaseURI() + "/context/uriinfo/detailed", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getAbsolutePathBuilder()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetAbsoluteBuilder() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getAbsolutePathBuilder")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(getBaseURI().replace(ServerEnvironmentInfo.getHostname(), "abcd") + "/context/uriinfo/detailed",
+                     response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getBaseUri()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetBaseUri() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getBaseUri").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(getBaseURI() + "/", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getBaseUriBuilder()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetBaseUriBuilder() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getBaseUriBuilder")
+                .get();
+        assertEquals(200, response.getStatusCode());
+
+        String contextRoot = ServerEnvironmentInfo.getContextRoot();
+        if (!"".equals(contextRoot)) {
+            contextRoot = "/" + contextRoot;
+        }
+        String baseUri =
+            "http://" + "abcd"
+                + ":"
+                + ServerEnvironmentInfo.getPort()
+                + contextRoot
+                + appBase
+                + "/";
+        assertEquals(baseUri, response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPath()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPath() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPath").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPath(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathDecoded() throws HttpException, IOException {
+        /*
+         * the client automatically encodes URIs
+         */
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathDecodedTrue")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathDecodedFalse")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/decoded/!@%23$%25%5E&*()?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed/decoded/!@%23$%25%5E&*()", response
+            .getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/decoded/!%40%23%24%25%5E%26*()?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed/decoded/!@#$%^&*()", response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedResources()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedResourcesSimple() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedResources")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(UriInfoDetailedMethods.class.getName() + ":", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedResources()} in a sub resource method.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedResourcesSubresource() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/matchedresources").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(UriInfoDetailedMethods.class.getName() + ":"
+            + "-"
+            + MatchedResourcesSubResource.class.getName()
+            + ":"
+            + UriInfoDetailedMethods.class.getName()
+            + ":", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedURIs()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedURIs() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIs")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed" + ":", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedURIs()} in a sub-resource method.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedURIsSubresource() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/matcheduris").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed/matcheduris" + ":"
+            + "context/uriinfo/detailed"
+            + ":"
+            + "-"
+            + "context/uriinfo/detailed/matcheduris"
+            + ":"
+            + "context/uriinfo/detailed"
+            + ":", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedURIs(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedURIsDecodeTrue() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIsDecodedTrue")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed" + ":", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedURIs(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedURIsDecodeFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIsDecodedFalse")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed" + ":", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedURIs(boolean)} in a sub-locator.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedURIsSublocatorDecodeTrue() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/matchedurisdecoded/!%40%23%24%25%5E%26*()?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed/matchedurisdecoded/!@#$%^&*()", response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getMatchedURIs(boolean)} in a sub-locator.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetMatchedURIsSublocatorDecodeFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/matchedurisdecoded/!@%23$%25%5E&*()?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context/uriinfo/detailed/matchedurisdecoded/!@%23$%25%5E&*()", response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersZero() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParameters")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersOne() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/:", response.getEntity(String.class));
+
+        response = client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=:", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/foo").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/foo:", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/foo/bar").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/foo/bar:", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersMany() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar/xyz")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=foo:p2=b:p3=ar/xyz:", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=foo:p2=b:p3=ar:", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersZeroDecodedFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParametersDecodedFalse")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersOneDecodedFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/:", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!@%23$%25%5E&*()?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/!@%23$%25%5E&*():", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!@%23$%25%5E&*()/!@%23$%25%5E&*()?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/!@%23$%25%5E&*()/!@%23$%25%5E&*():", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersManyDecodedFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar/xyz?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=foo:p2=b:p3=ar/xyz:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar?decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=foo:p2=b:p3=ar:", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersZeroDecodedTrue() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParametersDecodedTrue")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersOneDecodedTrue() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/:", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!%40%23%24%25%5E%26*()?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/!@#$%^&*():", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!%40%23%24%25%5E%26*()/!%40%23%24%25%5E%26*()?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=/!@#$%^&*()/!@#$%^&*():", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathParametersManyDecodedTrue() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/!%40%23%24%25%5E%26*()/bar/xyz?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=!@#$%^&*():p2=b:p3=ar/xyz:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/!%40%23%24%25%5E%26*()/bar?decoded=true")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("p1=!@#$%^&*():p2=b:p3=ar:", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathSegments()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathSegments() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathSegments")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context#:uriinfo#:detailed#:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context;matrixp1=value1;matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegments")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context#foo=bar:matrixp1=value1:matrixp2=value2::uriinfo#:detailed#:",
+                     response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context;matrixp1=!%40%23%24%25%5E%26*();matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegments")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context#foo=bar:matrixp1=!@#$%^&*():matrixp2=value2::uriinfo#:detailed#:",
+                     response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getPathSegments(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetPathSegmentsDecodedFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context#:uriinfo#:detailed#:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context;matrixp1=value1;matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context#foo=bar:matrixp1=value1:matrixp2=value2::uriinfo#:detailed#:",
+                     response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context;matrixp1=!@%23$%25%5E&*();matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("context#foo=bar:matrixp1=!@%23$%25%5E&*():matrixp2=value2::uriinfo#:detailed#:",
+                     response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getQueryParameters()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetQueryParametersZero() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed/queryparams").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getQueryParameters()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetQueryParametersOne() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getQueryParameters")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("reqInfo=getQueryParameters:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q1=value2")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("q1=value1:value2:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q1=value2")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("q1=value1:value2:", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getQueryParameters()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetQueryParametersMany() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q2=value2")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("q1=value1:q2=value2:", response.getEntity(String.class));
+
+        response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=!%40%23%24%25%5E%26*()&q2=value2")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("q1=!@#$%^&*():q2=value2:", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getQueryParameters(boolean)}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetQueryParametersManyDecodedFalse() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=!%40%23%24%25%5E%26*()&q2=value2&decoded=false")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("decoded=false:q1=!%40%23%24%25%5E%26*():q2=value2:", response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getRequestUri()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetRequestUri() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUri").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUri", response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests the {@link UriInfo#getRequestUriBuilder()}.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testURIInfoGetRequestUriBuilder() throws HttpException, IOException {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUriBuilder")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        String expected =
+            (getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUriBuilder")
+                .replace(ServerEnvironmentInfo.getHostname(), "abcd");
+        assertEquals(expected, response.getEntity(String.class));
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoDetailedMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoInjectionTest.java (from r816798, incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoInjectionTest.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoInjectionTest.java&p1=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java&r1=816798&r2=816947&rev=816947&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoInjectionTest.java Sat Sep 19 19:38:24 2009
@@ -14,7 +14,7 @@
  * "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.
+ * under the License.    
  */
 
 package org.apache.wink.itest.uriinfo;
@@ -23,23 +23,27 @@
 
 import junit.framework.TestCase;
 
-import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
 import org.apache.wink.test.integration.ServerEnvironmentInfo;
 
-/**
- * Tests that the UriInfo can be injected via various means.
- */
-public class URIInfoInjectionTest extends TestCase {
+public class WinkURIInfoInjectionTest extends TestCase {
 
-    public String getBaseURI() {
+    private static String getBaseURI() {
         if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/uriinfo";
     }
 
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
     /**
      * Tests that a URIInfo object is injected into method parameters.
      * 
@@ -47,14 +51,8 @@
      * @throws HttpException
      */
     public void testURIInfoParamInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-        GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/param");
-        try {
-            client.executeMethod(getMethod);
-            assertEquals(204, getMethod.getStatusCode());
-        } finally {
-            getMethod.releaseConnection();
-        }
+        ClientResponse response = client.resource(getBaseURI() + "/context/uriinfo/param").get();
+        assertEquals(204, response.getStatusCode());
     }
 
     /**
@@ -64,14 +62,8 @@
      * @throws HttpException
      */
     public void testURIInfoBeanMethodInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-        GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/bean");
-        try {
-            client.executeMethod(getMethod);
-            assertEquals(204, getMethod.getStatusCode());
-        } finally {
-            getMethod.releaseConnection();
-        }
+        ClientResponse response = client.resource(getBaseURI() + "/context/uriinfo/bean").get();
+        assertEquals(204, response.getStatusCode());
     }
 
     /**
@@ -81,14 +73,9 @@
      * @throws HttpException
      */
     public void testURIInfoConstructorInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-        GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/constructor");
-        try {
-            client.executeMethod(getMethod);
-            assertEquals(204, getMethod.getStatusCode());
-        } finally {
-            getMethod.releaseConnection();
-        }
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/uriinfo/constructor").get();
+        assertEquals(204, response.getStatusCode());
     }
 
     /**
@@ -98,14 +85,8 @@
      * @throws HttpException
      */
     public void testURIInfoFieldMemberInjection() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-        GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/field");
-        try {
-            client.executeMethod(getMethod);
-            assertEquals(204, getMethod.getStatusCode());
-        } finally {
-            getMethod.releaseConnection();
-        }
+        ClientResponse response = client.resource(getBaseURI() + "/context/uriinfo/field").get();
+        assertEquals(204, response.getStatusCode());
     }
 
     /**
@@ -115,14 +96,8 @@
      * @throws HttpException
      */
     public void testURIInfoNotBeanMethod() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-        GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/notbeanmethod");
-        try {
-            client.executeMethod(getMethod);
-            assertEquals(204, getMethod.getStatusCode());
-        } finally {
-            getMethod.releaseConnection();
-        }
+        ClientResponse response = client.resource(getBaseURI() + "/context/uriinfo/notbeanmethod").get();
+        assertEquals(204, response.getStatusCode());
     }
 
 }

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoNormalizationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoNormalizationTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoNormalizationTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoNormalizationTest.java Sat Sep 19 19:38:24 2009
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.wink.itest.uriinfo;
+
+import junit.framework.TestCase;
+
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class WinkURIInfoNormalizationTest extends TestCase {
+
+    private static String appRoot = "/uriinfo";
+
+    static {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            appRoot = "";
+        }
+    }
+
+    public String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + appRoot;
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests that a normal "good" path is returned.
+     * 
+     * @throws Exception
+     */
+    public void testPathNormal() throws Exception {
+        ClientResponse response = client.resource(getBaseURI() + "/uriinfo?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests that a path which removes the initial path to the resource class
+     * but adds it back in is okay.
+     * 
+     * @throws Exception
+     */
+    public void testRemoveResourcePathThenAddItBack() throws Exception {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/uriinfo/../uriinfo" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo", response.getEntity(String.class));
+
+        response = client.resource(getBaseURI() + "/uriinfo/." + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/", response.getEntity(String.class));
+
+        response = client.resource(getBaseURI() + "/uriinfo/./" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/uriinfo/./.././uriinfo/./" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/", response.getEntity(String.class));
+
+        response = client.resource(getBaseURI() + "/uriinfo/../uriinfo/" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/sub", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub/" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/sub/", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests adding some extra paths to resource paths and then removing them.
+     * 
+     * @throws Exception
+     */
+    public void testAddPathThenRemoveIt() throws Exception {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/uriinfo/something/../" + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/", response.getEntity(String.class));
+
+        response = client.resource(getBaseURI() + "/uriinfo/something/.." + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub/something/../"
+                + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/sub/", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub/something/.."
+                + "?info=path").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("uriinfo/sub/", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests that the capitalization is correct.
+     * 
+     * @throws Exception
+     */
+    public void testCapitalization() throws Exception {
+        String contextRoot = ServerEnvironmentInfo.getContextRoot();
+        if (!"".equals(contextRoot)) {
+            contextRoot = "/" + contextRoot;
+        }
+
+        ClientResponse response =
+            client.resource(getBaseURI() + "/uriinfo/something/../" + "?info=host").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(ServerEnvironmentInfo.getHostname().toLowerCase(), response
+            .getEntity(String.class));
+
+        /*
+         * should be the same as first test above
+         */
+        response =
+            client.resource("http://" + ServerEnvironmentInfo.getHostname()
+                + ":"
+                + ServerEnvironmentInfo.getPort()
+                + contextRoot
+                + appRoot
+                + "/uriinfo/something/../"
+                + "?info=host").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(ServerEnvironmentInfo.getHostname().toLowerCase(), response
+            .getEntity(String.class));
+
+        /*
+         * uppercased
+         */
+        response =
+            client.resource("http://" + ServerEnvironmentInfo.getHostname().toUpperCase()
+                + ":"
+                + ServerEnvironmentInfo.getPort()
+                + contextRoot
+                + appRoot
+                + "/uriinfo/something/../"
+                + "?info=host").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals(ServerEnvironmentInfo.getHostname().toUpperCase(), response
+            .getEntity(String.class));
+
+        /*
+         * uppercased
+         */
+        response =
+            client.resource("HTTP://" + ServerEnvironmentInfo.getHostname().toUpperCase()
+                + ":"
+                + ServerEnvironmentInfo.getPort()
+                + contextRoot
+                + appRoot
+                + "/uriinfo/something/../"
+                + "?info=protocol").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("http", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests that the capitalization is correct.
+     * 
+     * @throws Exception
+     */
+    public void testPercentEncoding() throws Exception {
+        /*
+         * regular query
+         */
+        ClientResponse response =
+            client.resource(getBaseURI() + "/uriinfo/something/../" + "?info=query&hello1=%3F")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("info=query&hello1=?", response.getEntity(String.class));
+
+        /*
+         * raw query
+         */
+        response =
+            client.resource(getBaseURI()
+                + "/uriinfo/something/../"
+                + "?info=rawquery&hello1=%3F").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("info=rawquery&hello1=%3F", response.getEntity(String.class));
+
+        response =
+            client.resource(getBaseURI()
+                + "/uriinfo/something/../"
+                + "?info=query&hello%31=%3F").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("info=query&hello1=?", response.getEntity(String.class));
+
+        /*
+         * %75 should eventually be normalized to /uriinfo/something %31 should
+         * be normalized to 1
+         */
+        response =
+            client.resource(getBaseURI()
+                + "/%75riinfo/something/../"
+                + "?info=rawquery&hello%31=%3F").get();
+        assertEquals(200, response.getStatusCode());
+        /*
+         * in this case, the %31 should remain encoded
+         */
+        assertEquals("info=rawquery&hello%31=%3F", response.getEntity(String.class));
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoNormalizationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message