wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r816947 [1/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
Author: bluk
Date: Sat Sep 19 19:38:24 2009
New Revision: 816947

URL: http://svn.apache.org/viewvc?rev=816947&view=rev
Log:
Port tests to use Wink RestClient

See [WINK-99]

Added:
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkApacheWebContainerTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkWebContainerTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkApacheHttpHeadersTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkHttpHeadersTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/WinkApacheProvidersMethodsTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/WinkProvidersMethodsTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkApacheRequestMethodsTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/WinkRequestMethodsTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/WinkApacheSecurityContextTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/WinkSecurityContextTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoDetailedMethodTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoInjectionTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkApacheURIInfoNormalizationTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoDetailedMethodTest.java   (with props)
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoInjectionTest.java
      - copied, changed from r816798, incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/WinkURIInfoNormalizationTest.java   (with props)
Modified:
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/JAXRSWebContainerTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/JAXRSHttpHeadersTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/ProvidersMethodsTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/request/RequestMethodsTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/SecurityContextTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/JAXRSWebContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/JAXRSWebContainerTest.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/environment/servlets/JAXRSWebContainerTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/JAXRSWebContainerTest.java Sat Sep 19 19:38:24 2009
@@ -31,7 +31,7 @@
  */
 public class JAXRSWebContainerTest extends TestCase {
 
-    public String getBaseURI() {
+    private static String getBaseURI() {
         if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI() + "/environment/webcontainer/context";
         }
@@ -39,14 +39,18 @@
             + "/environment/webcontainer/context";
     }
 
+    private HttpClient client;
+
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests that a HTTPServletRequest can be injected.
      * 
      * @throws Exception
      */
     public void testHTTPServletRequestInjection() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI());
         try {
             client.executeMethod(getMethod);
@@ -68,8 +72,6 @@
      * @throws Exception
      */
     public void testHTTPServletResponseInjection() throws Exception {
-        HttpClient client = new HttpClient();
-
         PostMethod postMethod = new PostMethod(getBaseURI());
         try {
             client.executeMethod(postMethod);
@@ -88,8 +90,6 @@
      * @throws Exception
      */
     public void testServletContextInjection() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/servletcontext");
         try {
             client.executeMethod(getMethod);
@@ -107,8 +107,6 @@
      * @throws Exception
      */
     public void testServletConfigInjection() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/servletconfig");
         try {
             client.executeMethod(getMethod);

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkApacheWebContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkApacheWebContainerTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkApacheWebContainerTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkApacheWebContainerTest.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.environment.servlets;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheWebContainerTest extends WinkWebContainerTest {
+
+    @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/environment/servlets/WinkApacheWebContainerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkWebContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkWebContainerTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkWebContainerTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/environment/servlets/WinkWebContainerTest.java Sat Sep 19 19:38:24 2009
@@ -0,0 +1,94 @@
+/*
+ * 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.environment.servlets;
+
+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 WinkWebContainerTest extends TestCase {
+
+    private static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI() + "/environment/webcontainer/context";
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/webcontainer"
+            + "/environment/webcontainer/context";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests that a HTTPServletRequest can be injected.
+     * 
+     * @throws Exception
+     */
+    public void testHTTPServletRequestInjection() throws Exception {
+        ClientResponse response = client.resource(getBaseURI()).get();
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            assertEquals(204, response.getStatusCode());
+        } else {
+            assertEquals(200, response.getStatusCode());
+            assertTrue(getBaseURI().endsWith(response.getEntity(String.class)));
+        }
+    }
+
+    /**
+     * Tests that an injected HTTPServletResponse can take over the response
+     * instead of further processing by the runtime engine.
+     * 
+     * @throws Exception
+     */
+    public void testHTTPServletResponseInjection() throws Exception {
+        ClientResponse response = client.resource(getBaseURI()).post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("responseheadervalue", response.getHeaders().getFirst("responseheadername"));
+        assertEquals("Hello World -- I was committted", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests that a ServletContext can be injected.
+     * 
+     * @throws Exception
+     */
+    public void testServletContextInjection() throws Exception {
+        ClientResponse response = client.resource(getBaseURI() + "/servletcontext").get();
+        assertEquals(200, response.getStatusCode());
+        assertTrue(response.getEntity(String.class).contains("testing 1-2-3"));
+    }
+
+    /**
+     * Tests that a ServletConfig can be injected.
+     * 
+     * @throws Exception
+     */
+    public void testServletConfigInjection() throws Exception {
+        ClientResponse response = client.resource(getBaseURI() + "/servletconfig").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("WebContainerTests", response.getEntity(String.class));
+    }
+}

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

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/JAXRSHttpHeadersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/JAXRSHttpHeadersTest.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/httpheaders/JAXRSHttpHeadersTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/JAXRSHttpHeadersTest.java Sat Sep 19 19:38:24 2009
@@ -36,13 +36,19 @@
  */
 public class JAXRSHttpHeadersTest extends TestCase {
 
-    public static String getBaseURI() {
+    private static String getBaseURI() {
         if(ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/httpheaders";
     }
 
+    private HttpClient client;
+
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests {@link HttpHeaders#getAcceptableLanguages()} that if given no
      * acceptable languages, that it will return the server default locale back.
@@ -51,7 +57,6 @@
      * @throws HttpException
      */
     public void testAcceptableLanguagesNoneGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablelanguages");
         try {
@@ -71,7 +76,6 @@
      * @throws IOException
      */
     public void testAcceptableLanguagesOneGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablelanguages");
         getMethod.setRequestHeader("Accept-Language", "de");
@@ -92,7 +96,6 @@
      * @throws IOException
      */
     public void testAcceptableLanguagesManyGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablelanguages");
         getMethod.setRequestHeader("Accept-Language", "de, en, zh");
@@ -118,7 +121,6 @@
      * @throws HttpException
      */
     public void testAcceptableLanguagesManyGivenQSort() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablelanguages");
         getMethod.setRequestHeader("Accept-Language", "de;q=0.6, en;q=0.8, zh;q=0.7");
@@ -140,7 +142,6 @@
      * @throws HttpException
      */
     public void testAcceptableMediaTypesNoneGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablemediatypes");
         try {
@@ -161,7 +162,6 @@
      * @throws HttpException
      */
     public void testAcceptableMediaTypesOneGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablemediatypes");
         getMethod.setRequestHeader("Accept", "text/plain");
@@ -184,7 +184,6 @@
      * @throws HttpException
      */
     public void testAcceptableMediaTypesManyGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/context/httpheaders/acceptablemediatypes");
         getMethod
@@ -210,7 +209,6 @@
      * @throws HttpException
      */
     public void testMediaTypesRequestTextPlain() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod =
             new PostMethod(getBaseURI() + "/context/httpheaders/requestmediatype");
         postMethod.setRequestEntity(new StringRequestEntity("Hello world!", "text/plain", "UTF-8"));
@@ -219,8 +217,6 @@
             assertEquals(200, postMethod.getStatusCode());
             String responseBody = postMethod.getResponseBodyAsString();
             assertEquals("mediatype:text/plain:", responseBody);
-            // assertEquals("application/xml",
-            // postMethod.getResponseHeader("Content-Type").getValue());
         } finally {
             postMethod.releaseConnection();
         }
@@ -233,8 +229,7 @@
      * @throws IOException
      * @throws HttpException
      */
-    public void testMediaTypesRequestJSON() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
+    public void testMediaTypesRequestCustomContentType() throws HttpException, IOException {
         PostMethod postMethod =
             new PostMethod(getBaseURI() + "/context/httpheaders/requestmediatype");
         postMethod.setRequestEntity(new StringRequestEntity("Hello world!", "defg/abcd", "UTF-8"));
@@ -255,7 +250,6 @@
      * @throws HttpException
      */
     public void testMediaTypesRequestNoRequestEntity() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod =
             new PostMethod(getBaseURI() + "/context/httpheaders/requestmediatype");
         try {
@@ -276,7 +270,6 @@
      * @throws HttpException
      */
     public void testLanguageNoneGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/language");
         postMethod.setRequestEntity(new StringRequestEntity("Hello world!", "text/plain", "UTF-8"));
         try {
@@ -297,7 +290,6 @@
      * @throws HttpException
      */
     public void testLanguageEnglishGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/language");
         postMethod.setRequestEntity(new StringRequestEntity("Hello world!", "text/plain", "UTF-8"));
         postMethod.setRequestHeader("Content-Language", "en");
@@ -319,7 +311,6 @@
      * @throws HttpException
      */
     public void testLanguageChineseGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/language");
         postMethod.setRequestEntity(new StringRequestEntity("Hello world!", "text/plain", "UTF-8"));
         postMethod.setRequestHeader("Content-Language", "zh");
@@ -340,7 +331,6 @@
      * @throws HttpException
      */
     public void testCookiesNone() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/cookies");
         try {
             client.executeMethod(postMethod);
@@ -359,7 +349,6 @@
      * @throws HttpException
      */
     public void testCookiesOneGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/cookies");
         postMethod.addRequestHeader("Cookie", "foo=bar");
         try {
@@ -379,7 +368,6 @@
      * @throws HttpException
      */
     public void testCookiesManyGiven() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/cookies");
         postMethod.addRequestHeader("Cookie", "foo=bar");
         postMethod.addRequestHeader("Cookie", "foo2=bar2");
@@ -401,7 +389,6 @@
      * @throws HttpException
      */
     public void testRequestHeaderNoneGivenIllegalArgument() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/");
         try {
             client.executeMethod(getMethod);
@@ -421,7 +408,6 @@
      * @throws HttpException
      */
     public void testRequestHeaderNonexistentHeader() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/?name=foo");
         try {
             client.executeMethod(getMethod);
@@ -441,7 +427,6 @@
      * @throws HttpException
      */
     public void testRequestHeaderSingleValue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/?name=foo");
         getMethod.setRequestHeader("foo", "bar");
         try {
@@ -462,7 +447,6 @@
      * @throws HttpException
      */
     public void testRequestHeaderMultipleValue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/?name=foo");
         getMethod.addRequestHeader("foo", "bar");
         getMethod.addRequestHeader("foo", "bar2");
@@ -485,7 +469,6 @@
      * @throws HttpException
      */
     public void testRequestHeaderCaseInsensitive() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/?name=foo");
         getMethod.addRequestHeader("FOO", "bar");
         getMethod.addRequestHeader("FoO", "bar2");
@@ -507,7 +490,6 @@
      * @throws HttpException
      */
     public void testRequestHeadersBasicHeader() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/requestheaders");
         try {
             client.executeMethod(getMethod);
@@ -531,7 +513,6 @@
      * @throws HttpException
      */
     public void testRequestHeadersSingleValue() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/requestheaders");
         getMethod.addRequestHeader("fOo", "bAr");
         try {
@@ -554,7 +535,6 @@
      * @throws HttpException
      */
     public void testRequestHeadersMultipleValues() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         GetMethod getMethod = new GetMethod(getBaseURI() + "/context/httpheaders/requestheaders");
         getMethod.addRequestHeader("fOo", "bAr");
         getMethod.addRequestHeader("abc", "xyz");

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkApacheHttpHeadersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkApacheHttpHeadersTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkApacheHttpHeadersTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkApacheHttpHeadersTest.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.httpheaders;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheHttpHeadersTest extends WinkHttpHeadersTest {
+
+    @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/httpheaders/WinkApacheHttpHeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkHttpHeadersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkHttpHeadersTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkHttpHeadersTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/httpheaders/WinkHttpHeadersTest.java Sat Sep 19 19:38:24 2009
@@ -0,0 +1,569 @@
+/*
+ * 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.httpheaders;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.EntityType;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.common.internal.MultivaluedMapImpl;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class WinkHttpHeadersTest extends TestCase {
+
+    private static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/httpheaders";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableLanguages()} that if given no
+     * acceptable languages, that it will return the server default locale back.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testAcceptableLanguagesNoneGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/acceptablelanguages").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("acceptablelanguages:", response.getEntity(new EntityType<String>() {
+        }));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableLanguages()} that if given a
+     * language, it will be the only language in the list.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testAcceptableLanguagesOneGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablelanguages")
+                .header("Accept-Language", "de").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("acceptablelanguages:de:", response.getEntity(new EntityType<String>() {
+        }));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableLanguages()} that if given multiple
+     * languages, all will be returned in the list.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testAcceptableLanguagesManyGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablelanguages")
+                .header("Accept-Language", "de", "en", "zh").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(new EntityType<String>() {
+        });
+        assertTrue(responseBody, responseBody.startsWith("acceptablelanguages:"));
+        assertTrue(responseBody, responseBody.contains(":de:"));
+        assertTrue(responseBody, responseBody.contains(":en:"));
+        assertTrue(responseBody, responseBody.contains(":zh:"));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableLanguages()} that if given multiple
+     * languages, all will be returned in the list sorted by their quality
+     * value.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testAcceptableLanguagesManyGivenQSort() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablelanguages")
+                .header("Accept-Language", "de;q=0.6", "en;q=0.8", "zh;q=0.7").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(new EntityType<String>() {
+        });
+        assertEquals("acceptablelanguages:en:zh:de:", responseBody);
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablelanguages")
+                .header("Accept-Language", "de;q=0.6").header("Accept-Language", "en;q=0.8")
+                .header("Accept-Language", "zh;q=0.7").get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(new EntityType<String>() {
+        });
+        assertEquals("acceptablelanguages:en:zh:de:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableMediaTypes()} that if given no
+     * Accept header, wildcard/wildcard is returned.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testAcceptableMediaTypesNoneGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablemediatypes").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(new EntityType<String>() {
+        });
+        assertEquals("acceptablemediatypes:*/*:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableMediaTypes()} that if given a
+     * single Accept header value, it is returned.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testAcceptableMediaTypesOneGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablemediatypes")
+                .accept(MediaType.TEXT_PLAIN).get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:", responseBody);
+        assertEquals(MediaType.TEXT_PLAIN, response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
+                .accept(MediaType.TEXT_PLAIN_TYPE).get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:", responseBody);
+        assertEquals(MediaType.TEXT_PLAIN, response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders//acceptablemediatypes")
+                .header("accept", MediaType.TEXT_PLAIN).get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:", responseBody);
+        assertEquals(MediaType.TEXT_PLAIN, response.getHeaders().getFirst("Content-Type"));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getAcceptableMediaTypes()} that if given
+     * multiple Accept header values, the values are sorted by q-value.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testAcceptableMediaTypesManyGiven() throws HttpException, IOException {
+        Map<String, String> qMap1 = new HashMap<String, String>();
+        qMap1.put("q", "1.0");
+        MediaType textPlainTypeQ1 = new MediaType("text", "plain", qMap1);
+
+        Map<String, String> qMap06 = new HashMap<String, String>();
+        qMap06.put("q", "0.6");
+        MediaType wildCardQ06 = new MediaType("*", "*", qMap06);
+
+        Map<String, String> qMap07 = new HashMap<String, String>();
+        qMap07.put("q", "0.7");
+        MediaType jsonQ07 = new MediaType("application", "json", qMap07);
+
+        Map<String, String> qMap08 = new HashMap<String, String>();
+        qMap08.put("q", "0.8");
+        MediaType textXMLQ08 = new MediaType("text", "xml", qMap08);
+
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
+                .accept(textPlainTypeQ1, wildCardQ06, jsonQ07, textXMLQ08).get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
+        assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
+                .accept(textPlainTypeQ1).accept(wildCardQ06).accept(jsonQ07).accept(textXMLQ08)
+                .get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
+        assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
+                .header("Accept",
+                        "text/plain;q=1.0,*/*;q=0.6, application/json;q=0.7,text/xml;q=0.8").get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
+        assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
+                .header("Accept", "text/plain;q=1.0").header("Accept", "*/*;q=0.6")
+                .header("Accept", "application/json;q=0.7").header("Accept", "text/xml;q=0.8")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
+        assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getMediaType()} that if given a text/plain, the
+     * method will return text/plain.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testMediaTypesRequestTextPlain() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestmediatype")
+                .contentType(MediaType.TEXT_PLAIN).post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("mediatype:text/plain:", responseBody);
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestmediatype")
+                .contentType("text/plain").post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("mediatype:text/plain:", responseBody);
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestmediatype")
+                .header("Content-Type", "text/plain").post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("mediatype:text/plain:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getMediaType()} when a non-standard content type
+     * is sent in.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testMediaTypesRequestCustomContentType() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestmediatype")
+                .contentType("defg/abcd").post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("mediatype:defg/abcd:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getMediaType()} when no request entity is given.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testMediaTypesRequestNoRequestEntity() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestmediatype").post(null);
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("mediatype:null:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getLanguage()} when no language is given in the
+     * request.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testLanguageNoneGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/language").post(null);
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("language:null:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getLanguage()} when English language is given in
+     * the request.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testLanguageEnglishGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/language")
+                .contentType("text/plain").header(HttpHeaders.CONTENT_LANGUAGE, "en")
+                .post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("language:en:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getLanguage()} when Chinese language is given in
+     * the request.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testLanguageChineseGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/language")
+                .contentType("text/plain").header(HttpHeaders.CONTENT_LANGUAGE, "zh")
+                .post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("language:zh:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getCookies()} when no cookies are given.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testCookiesNone() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/cookies")
+                .contentType("text/plain").header(HttpHeaders.CONTENT_LANGUAGE, "zh")
+                .post("Hello world!");
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("cookies:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getCookies()} when given a single cookie.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testCookiesOneGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/cookies")
+                .cookie(new Cookie("foo", "bar")).post(null);
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("cookies:foo=bar:", responseBody);
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/cookies").cookie("foo=bar")
+                .post(null);
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("cookies:foo=bar:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getCookies()} when given multiple cookies.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testCookiesManyGiven() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/cookies")
+                .cookie(new Cookie("foo", "bar")).cookie(new Cookie("foo2", "bar2")).post(null);
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("cookies:foo=bar:foo2=bar2:", responseBody);
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/cookies").cookie("foo=bar")
+                .cookie("foo2=bar2").post(null);
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("cookies:foo=bar:foo2=bar2:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeader(String)} when given a null
+     * value.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeaderNoneGivenIllegalArgument() throws HttpException, IOException {
+        ClientResponse response = client.resource(getBaseURI() + "/context/httpheaders/").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:null:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeader(String)} when requesting header
+     * values for a non-existent header name.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeaderNonexistentHeader() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/" + "?name=foo").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:null:", responseBody);
+
+        response =
+            client.resource(getBaseURI() + "/context/httpheaders/").queryParam("name", "foo").get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:null:", responseBody);
+
+        MultivaluedMap<String, String> map = new MultivaluedMapImpl<String, String>();
+        map.put("name", new ArrayList<String>());
+        response = client.resource(getBaseURI() + "/context/httpheaders/").queryParams(map).get();
+        assertEquals(200, response.getStatusCode());
+        responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:null:", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeader(String)} when requesting header
+     * value for a single header name.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeaderSingleValue() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/" + "?name=foo").header("foo",
+                                                                                         "bar")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:[bar]", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeader(String)} when requesting
+     * multiple header value for a single header name.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeaderMultipleValue() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/" + "?name=foo").header("foo",
+                                                                                         "bar")
+                .header("foo", "bar2").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:[bar, bar2]", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeader(String)} when requesting
+     * multiple header value for a single header name when using
+     * case-insensitive names.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeaderCaseInsensitive() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/" + "?name=foo").header("FOO",
+                                                                                         "bar")
+                .header("FoO", "bar2").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+        assertEquals("requestheader:[bar, bar2]", responseBody);
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeaders()} when making a basic
+     * HttpClient request.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeadersBasicHeader() throws HttpException, IOException {
+
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestheaders").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+
+        assertTrue(responseBody, responseBody.contains("requestheaders:"));
+        assertTrue(responseBody, responseBody.contains(":host=") || responseBody.contains(":Host="));
+        assertTrue(responseBody, responseBody.contains(":user-agent=") || responseBody
+            .contains(":User-Agent="));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeaders()} when having a custom
+     * header.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeadersSingleValue() throws HttpException, IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestheaders").header("fOo",
+                                                                                         "bAr")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+
+        assertTrue(responseBody, responseBody.contains("requestheaders:"));
+        assertTrue(responseBody, responseBody.contains(":fOo=[bAr]") || responseBody
+            .contains(":foo=[bAr]"));
+    }
+
+    /**
+     * Tests {@link HttpHeaders#getRequestHeaders()} when having multiple values
+     * and multiple custom headers.
+     * 
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testRequestHeadersMultipleValues() throws HttpException, IOException {
+
+        ClientResponse response =
+            client.resource(getBaseURI() + "/context/httpheaders/requestheaders").header("fOo",
+                                                                                         "bAr")
+                .header("fOo", "2bAr").header("abc", "xyz").get();
+        assertEquals(200, response.getStatusCode());
+        String responseBody = response.getEntity(String.class);
+
+        assertTrue(responseBody, responseBody.contains("requestheaders:"));
+        assertTrue(responseBody, responseBody.contains(":fOo=[2bAr, bAr]") || responseBody
+            .contains(":foo=[2bAr, bAr]"));
+        assertTrue(responseBody, responseBody.contains(":abc=[xyz]"));
+    }
+}

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

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/ProvidersMethodsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/ProvidersMethodsTest.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/providers/ProvidersMethodsTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/ProvidersMethodsTest.java Sat Sep 19 19:38:24 2009
@@ -35,13 +35,18 @@
 
 public class ProvidersMethodsTest extends TestCase {
 
-    public String getBaseURI() {
-        if(ServerEnvironmentInfo.isRestFilterUsed()) {
+    private static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/providers";
     }
 
+    private HttpClient client;
+
+    public void setUp() {
+        client = new HttpClient();
+    }
 
     /**
      * Tests that
@@ -53,8 +58,6 @@
      * @throws IOException
      */
     public void testContextResolverNoMatch() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.Throwable&mediaType=*%2F*");
@@ -77,16 +80,14 @@
      * @throws IOException
      */
     public void testContextResolverMatchSingle() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.Exception&mediaType=*%2F*");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
@@ -101,8 +102,6 @@
      * @throws IOException
      */
     public void testContextResolverNoMatchBySpecificMediaType() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.Exception&mediaType=my%2Ftype");
@@ -123,16 +122,14 @@
      * @throws IOException
      */
     public void testContextResolverMatchBySpecificMediaType() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.Exception&mediaType=text%2Fxml");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
@@ -147,16 +144,14 @@
      */
     public void testContextResolverMatchBySpecificMediaTypeTypeWildcard() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.Exception&mediaType=*%2Fxml");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
@@ -171,46 +166,48 @@
      */
     public void testContextResolverMatchBySpecificMediaTypeSubtypeWildcard() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.Exception&mediaType=text%2F*");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.MyExceptionContextResolver", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
     }
 
-//    /**
-//     * Tests that when finding a {@link ContextResolver} both the application
-//     * provided and runtime provided context resolvers are searched. Invokes
-//     * with a specific JAXB class and verifies that the final context is a
-//     * JAXBContext. In this case, the runtime provided context resolver is used.
-//     * 
-//     * @throws HttpException
-//     * @throws IOException
-//     */
-//    public void testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeWildcardInvokeWithClassInvokeRuntimeProvided()
-//        throws HttpException, IOException {
-//        HttpClient client = new HttpClient();
-//
-//        GetMethod getMethod =
-//            new GetMethod(
-//                          getBaseURI() + "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=*%2F*&invokeWithClassName=org.apache.wink.itest.providers.otherxml.OtherRootElement");
-//        try {
-//            client.executeMethod(getMethod);
-//            assertEquals(200, getMethod.getStatusCode());
-//            assertTrue(getMethod.getResponseBodyAsString(), getMethod.getResponseBodyAsString()
-//                .contains("JAXBContext"));
-//        } finally {
-//            getMethod.releaseConnection();
-//        }
-//    }
+    // /**
+    // * Tests that when finding a {@link ContextResolver} both the application
+    // * provided and runtime provided context resolvers are searched. Invokes
+    // * with a specific JAXB class and verifies that the final context is a
+    // * JAXBContext. In this case, the runtime provided context resolver is
+    // used.
+    // *
+    // * @throws HttpException
+    // * @throws IOException
+    // */
+    // public void
+    // testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeWildcardInvokeWithClassInvokeRuntimeProvided()
+    // throws HttpException, IOException {
+    // HttpClient client = new HttpClient();
+    //
+    // GetMethod getMethod =
+    // new GetMethod(
+    // getBaseURI() +
+    // "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=*%2F*&invokeWithClassName=org.apache.wink.itest.providers.otherxml.OtherRootElement");
+    // try {
+    // client.executeMethod(getMethod);
+    // assertEquals(200, getMethod.getStatusCode());
+    // assertTrue(getMethod.getResponseBodyAsString(),
+    // getMethod.getResponseBodyAsString()
+    // .contains("JAXBContext"));
+    // } finally {
+    // getMethod.releaseConnection();
+    // }
+    // }
 
     /**
      * Tests that when finding a {@link ContextResolver} both the application
@@ -224,8 +221,6 @@
      */
     public void testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeWildcardInvokeWithClassInvokeApplicationProvided()
         throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=*%2F*&invokeWithClassName=org.apache.wink.itest.providers.xml.RootElement");
@@ -239,78 +234,85 @@
         }
     }
 
-//    /**
-//     * Tests that when there are multiple {@link ContextResolver}s that could
-//     * respond to a given type, that a proxy is returned that will call all of
-//     * them.
-//     * 
-//     * @throws HttpException
-//     * @throws IOException
-//     */
-//    public void testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificTextXML()
-//        throws HttpException, IOException {
-//        HttpClient client = new HttpClient();
-//
-//        GetMethod getMethod =
-//            new GetMethod(
-//                          getBaseURI() + "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=text%2Fxml");
-//        try {
-//            client.executeMethod(getMethod);
-//            assertEquals(200, getMethod.getStatusCode());
-//            assertTrue(getMethod.getResponseBodyAsString().startsWith("$Proxy"));
-//        } finally {
-//            getMethod.releaseConnection();
-//        }
-//    }
-
-//    /**
-//     * Tests that when the application provided {@link ContextResolver} which
-//     * has a {@link Produces} annotation with text/xml is not the
-//     * ContextResolver returned when searching for application/json media type.
-//     * 
-//     * @throws HttpException
-//     * @throws IOException
-//     */
-//    public void testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificApplicationJSON()
-//        throws HttpException, IOException {
-//        HttpClient client = new HttpClient();
-//
-//        GetMethod getMethod =
-//            new GetMethod(
-//                          getBaseURI() + "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=application%2Fjson");
-//        try {
-//            client.executeMethod(getMethod);
-//            assertEquals(200, getMethod.getStatusCode());
-//            assertTrue(getMethod.getResponseBodyAsString().contains("JAXBContext"));
-//        } finally {
-//            getMethod.releaseConnection();
-//        }
-//    }
-
-//    /**
-//     * Tests that when the application provided {@link ContextResolver} which
-//     * has a {@link Produces} annotation with text/xml is not called when an
-//     * application/json is searched. This method should be able to invoke the
-//     * runtime provided JAXBContext ContextResolver but return null.
-//     * 
-//     * @throws HttpException
-//     * @throws IOException
-//     */
-//    public void testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificApplicationJSONInvokeNegative()
-//        throws HttpException, IOException {
-//        HttpClient client = new HttpClient();
-//
-//        GetMethod getMethod =
-//            new GetMethod(
-//                          getBaseURI() + "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=application%2Fjson&invokeWithClassName=org.apache.wink.itest.providers.xml.RootElement");
-//        try {
-//            client.executeMethod(getMethod);
-//            assertEquals(200, getMethod.getStatusCode());
-//            assertEquals("null", getMethod.getResponseBodyAsString());
-//        } finally {
-//            getMethod.releaseConnection();
-//        }
-//    }
+    // /**
+    // * Tests that when there are multiple {@link ContextResolver}s that could
+    // * respond to a given type, that a proxy is returned that will call all of
+    // * them.
+    // *
+    // * @throws HttpException
+    // * @throws IOException
+    // */
+    // public void
+    // testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificTextXML()
+    // throws HttpException, IOException {
+    // HttpClient client = new HttpClient();
+    //
+    // GetMethod getMethod =
+    // new GetMethod(
+    // getBaseURI() +
+    // "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=text%2Fxml");
+    // try {
+    // client.executeMethod(getMethod);
+    // assertEquals(200, getMethod.getStatusCode());
+    // assertTrue(getMethod.getResponseBodyAsString().startsWith("$Proxy"));
+    // } finally {
+    // getMethod.releaseConnection();
+    // }
+    // }
+
+    // /**
+    // * Tests that when the application provided {@link ContextResolver} which
+    // * has a {@link Produces} annotation with text/xml is not the
+    // * ContextResolver returned when searching for application/json media
+    // type.
+    // *
+    // * @throws HttpException
+    // * @throws IOException
+    // */
+    // public void
+    // testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificApplicationJSON()
+    // throws HttpException, IOException {
+    // HttpClient client = new HttpClient();
+    //
+    // GetMethod getMethod =
+    // new GetMethod(
+    // getBaseURI() +
+    // "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=application%2Fjson");
+    // try {
+    // client.executeMethod(getMethod);
+    // assertEquals(200, getMethod.getStatusCode());
+    // assertTrue(getMethod.getResponseBodyAsString().contains("JAXBContext"));
+    // } finally {
+    // getMethod.releaseConnection();
+    // }
+    // }
+
+    // /**
+    // * Tests that when the application provided {@link ContextResolver} which
+    // * has a {@link Produces} annotation with text/xml is not called when an
+    // * application/json is searched. This method should be able to invoke the
+    // * runtime provided JAXBContext ContextResolver but return null.
+    // *
+    // * @throws HttpException
+    // * @throws IOException
+    // */
+    // public void
+    // testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificApplicationJSONInvokeNegative()
+    // throws HttpException, IOException {
+    // HttpClient client = new HttpClient();
+    //
+    // GetMethod getMethod =
+    // new GetMethod(
+    // getBaseURI() +
+    // "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=application%2Fjson&invokeWithClassName=org.apache.wink.itest.providers.xml.RootElement");
+    // try {
+    // client.executeMethod(getMethod);
+    // assertEquals(200, getMethod.getStatusCode());
+    // assertEquals("null", getMethod.getResponseBodyAsString());
+    // } finally {
+    // getMethod.releaseConnection();
+    // }
+    // }
 
     /**
      * Tests that when the application provided {@link ContextResolver} which
@@ -324,8 +326,6 @@
      */
     public void testMultipleContextResolverRuntimeAndApplicationMatchByMediaTypeSpecificTextXMLInvoke()
         throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=javax.xml.bind.JAXBContext&mediaType=text%2Fxml&invokeWithClassName=org.apache.wink.itest.providers.xml.RootElement");
@@ -348,8 +348,6 @@
      */
     public void testContextResolverMatchMultipleSortByProducesWildcardType() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=abcd%2Fxml&invokeWithClassName=java.lang.Short&returnToStringValue=true");
@@ -371,8 +369,6 @@
      */
     public void testContextResolverMatchMultipleSortByProducesWildcardSubtype()
         throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=text%2Fabcd&invokeWithClassName=java.lang.Short&returnToStringValue=true");
@@ -394,8 +390,6 @@
      */
     public void testContextResolverMatchMultipleSortByProducesAllWildcard() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=abcd%2Fdef&invokeWithClassName=java.lang.Short&returnToStringValue=true");
@@ -418,8 +412,6 @@
      */
     public void testContextResolverMatchMultipleSortByProducesFindOne() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=text%2Fxml&invokeWithClassName=java.lang.Integer&returnToStringValue=true");
@@ -431,8 +423,6 @@
             getMethod.releaseConnection();
         }
 
-        client = new HttpClient();
-
         getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=text%2Fxml&invokeWithClassName=java.lang.Long&returnToStringValue=true");
@@ -454,8 +444,6 @@
      */
     public void testContextResolverMatchAnyMoreSpecificThanWildcards() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=text%2Fxml&invokeWithClassName=java.lang.Short&returnToStringValue=true");
@@ -480,16 +468,14 @@
      */
     public void testContextResolverNoProducesMatchNotExpectedMediaType() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/contextresolver?className=java.lang.String&mediaType=my%2Ftype");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.MyStringContextForAllWildcard",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.MyStringContextForAllWildcard", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
@@ -502,16 +488,14 @@
      * @throws IOException
      */
     public void testGetExceptionMapperAppSuppliedProvider() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/exception?className=org.apache.wink.itest.providers.MyException");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.ExceptionMapperForMyException",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.ExceptionMapperForMyException", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
@@ -527,16 +511,14 @@
      */
     public void testGetExceptionMapperAppSuppliedInheritanceTree() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/exception?className=org.apache.wink.itest.providers.MyException2");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
-            assertEquals("org.apache.wink.itest.providers.ExceptionMapperForMyException",
-                         getMethod.getResponseBodyAsString());
+            assertEquals("org.apache.wink.itest.providers.ExceptionMapperForMyException", getMethod
+                .getResponseBodyAsString());
         } finally {
             getMethod.releaseConnection();
         }
@@ -550,8 +532,6 @@
      * @throws IOException
      */
     public void testGetExceptionMapperNoMatching() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/exception?className=java.lang.Throwable");
@@ -573,8 +553,6 @@
      * @throws IOException
      */
     public void testGetMessageBodyWriterSortByProducesMediaType() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodywriter?className=java.lang.Integer&mediaType=text%2Fxml");
@@ -615,8 +593,6 @@
      */
     public void testGetMessageBodyWriterSortByProducesMediaTypeWithWildcards()
         throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodywriter?className=java.lang.Short&mediaType=application%2Fjson");
@@ -637,9 +613,8 @@
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
             String response = getMethod.getResponseBodyAsString();
-            assertTrue(response,
-                       response
-                           .contains("org.apache.wink.itest.providers.MyMessageBodyWriterJSONForShort"));
+            assertTrue(response, response
+                .contains("org.apache.wink.itest.providers.MyMessageBodyWriterJSONForShort"));
         } finally {
             getMethod.releaseConnection();
         }
@@ -683,8 +658,6 @@
      */
     public void testGetMessageBodyWriterWhichInheritsWriterInterface() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodywriter?className=java.util.List&mediaType=abcd%2Fefgh");
@@ -692,8 +665,7 @@
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
             String response = getMethod.getResponseBodyAsString();
-            assertEquals("org.apache.wink.itest.providers.MyMessageBodyWriterInherited",
-                         response);
+            assertEquals("org.apache.wink.itest.providers.MyMessageBodyWriterInherited", response);
         } finally {
             getMethod.releaseConnection();
         }
@@ -708,8 +680,6 @@
      * @throws IOException
      */
     public void testGetMessageBodyWriterSortByIsWritable() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodywriter?className=java.lang.Integer&mediaType=application%2Fjson");
@@ -791,8 +761,6 @@
      */
     public void testGetMessageBodyWriterUserPrecedenceOverRuntime() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodywriter?className=java.lang.String&mediaType=text%2Fplain");
@@ -800,8 +768,7 @@
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
             String response = getMethod.getResponseBodyAsString();
-            assertEquals("org.apache.wink.itest.providers.MyStringWriterForStrings",
-                         response);
+            assertEquals("org.apache.wink.itest.providers.MyStringWriterForStrings", response);
         } finally {
             getMethod.releaseConnection();
         }
@@ -817,8 +784,6 @@
      * @throws IOException
      */
     public void testGetMessageBodyWriterNoMatching() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodywriter?className=java.lang.Float&mediaType=application%2Fjson");
@@ -854,8 +819,6 @@
      * @throws HttpException
      */
     public void testGetMessageBodyReaderNoMatching() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodyreader?className=java.lang.Float&mediaType=mynonexistenttype%2Fmysubtype");
@@ -890,8 +853,6 @@
      * @throws IOException
      */
     public void testGetMessageBodyReaderSortByIsReadable() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodyreader?className=java.lang.Integer&mediaType=application%2Fjson");
@@ -971,8 +932,6 @@
      * @throws IOException
      */
     public void testGetMessageBodyReaderSortByConsumesMediaType() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodyreader?className=java.lang.Integer&mediaType=text%2Fxml");
@@ -1013,8 +972,6 @@
      */
     public void testGetMessageBodyReaderSortByConsumesMediaTypeWithWildcards()
         throws HttpException, IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodyreader?className=java.lang.Short&mediaType=application%2Fjson");
@@ -1080,8 +1037,6 @@
      */
     public void testGetMessageBodyReaderUserPrecedenceOverRuntime() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodyreader?className=java.lang.String&mediaType=text%2Fplain");
@@ -1094,7 +1049,6 @@
         } finally {
             getMethod.releaseConnection();
         }
-
     }
 
     /**
@@ -1108,8 +1062,6 @@
      */
     public void testGetMessageBodyReaderWhichInheritsReaderInterface() throws HttpException,
         IOException {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(
                           getBaseURI() + "/context/providers/messagebodyreader?className=java.util.Set&mediaType=tuv%2Fwxyz");

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/WinkApacheProvidersMethodsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/WinkApacheProvidersMethodsTest.java?rev=816947&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/WinkApacheProvidersMethodsTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/providers/WinkApacheProvidersMethodsTest.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.providers;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheProvidersMethodsTest extends WinkProvidersMethodsTest {
+
+    @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/providers/WinkApacheProvidersMethodsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message