You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/09/26 21:21:12 UTC

svn commit: r819192 [2/3] - in /incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src: main/resources/ main/resources/tests/ main/resources/tests/test-resources/ test/java/org/apache/wink/itest/addressbook/ test/java/org/apache/wink/ites...

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ValidationDuringTargettingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ValidationDuringTargettingTest.java?rev=819192&r1=819191&r2=819192&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ValidationDuringTargettingTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ValidationDuringTargettingTest.java Sat Sep 26 19:21:10 2009
@@ -38,6 +38,13 @@
         return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
     }
 
+    protected HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests that a GET method to various paths only differing by
      * {@link Produces} works.
@@ -45,8 +52,6 @@
      * @throws Exception
      */
     public void testGETOnlyDifferByProduces() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/targeting/resourceonlyproduces");
         try {
             getMethod.addRequestHeader("Accept", "application/json");
@@ -84,16 +89,6 @@
         } finally {
             getMethod.releaseConnection();
         }
-
-        // boolean isWarningThrown = true;
-        // try {
-        // FVTAssert.assertLogContainsException("WARN");
-        // FVTAssert.assertInstallLogContainsException("WARN");
-        // } catch (AssertionError e) {
-        // isWarningThrown = false;
-        // }
-        //
-        // assertFalse("Warning should not be emitted", isWarningThrown);
     }
 
     /**
@@ -103,8 +98,6 @@
      * @throws Exception
      */
     public void testGETOnlyDifferByConsumes() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod = new GetMethod(getBaseURI() + "/targeting/resourceonlyconsumes");
         getMethod.setRequestHeader("Content-Type", "application/json");
         try {
@@ -129,16 +122,6 @@
         } finally {
             getMethod.releaseConnection();
         }
-
-        // boolean isWarningThrown = true;
-        // try {
-        // FVTAssert.assertLogContainsException("WARN");
-        // FVTAssert.assertInstallLogContainsException("WARN");
-        // } catch (AssertionError e) {
-        // isWarningThrown = false;
-        // }
-        //
-        // assertFalse("Warning should not be emitted", isWarningThrown);
     }
 
     /**
@@ -148,8 +131,6 @@
      * @throws Exception
      */
     public void testGETOnlyDifferByConsumesAndProduces() throws Exception {
-        HttpClient client = new HttpClient();
-
         GetMethod getMethod =
             new GetMethod(getBaseURI() + "/targeting/resourceconsumesandproduces");
         getMethod.setRequestHeader("Content-Type", "application/json");
@@ -227,15 +208,5 @@
         } finally {
             getMethod.releaseConnection();
         }
-
-        // boolean isWarningThrown = true;
-        // try {
-        // FVTAssert.assertLogContainsException("WARN");
-        // FVTAssert.assertInstallLogContainsException("WARN");
-        // } catch (AssertionError e) {
-        // isWarningThrown = false;
-        // }
-        //
-        // assertFalse("Warning should not be emitted", isWarningThrown);
     }
 }

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheExceptionsDuringTargetingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheExceptionsDuringTargetingTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheExceptionsDuringTargetingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheExceptionsDuringTargetingTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.exceptions;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheExceptionsDuringTargetingTest extends WinkExceptionsWhileTargetingTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheExceptionsDuringTargetingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheNullValuesDuringTargetingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheNullValuesDuringTargetingTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheNullValuesDuringTargetingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheNullValuesDuringTargetingTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wink.itest.exceptions;
+
+import java.io.IOException;
+
+import javax.ws.rs.Consumes;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheNullValuesDuringTargetingTest extends WinkNullValuesDuringTargetingTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+
+    /**
+     * Tests that a request to a method with no content type, a request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    @Override
+    public void testNoContentTypeWithRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        /*
+         * with Wink client, content type is set to applcation/octet-stream if
+         * no content type specified
+         */
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
+                .post("calledWithString");
+        assertEquals(200, response.getStatusCode());
+        assertEquals("userReadercalledWithString", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheNullValuesDuringTargetingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheValidationDuringTargetingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheValidationDuringTargetingTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheValidationDuringTargetingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheValidationDuringTargetingTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.exceptions;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheValidationDuringTargetingTest extends WinkValidationDuringTargetingTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkApacheValidationDuringTargetingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkExceptionsWhileTargetingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkExceptionsWhileTargetingTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkExceptionsWhileTargetingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkExceptionsWhileTargetingTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,190 @@
+/*
+ * 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.exceptions;
+
+import javax.ws.rs.core.MediaType;
+
+import junit.framework.TestCase;
+
+import org.apache.wink.client.ClientWebException;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class WinkExceptionsWhileTargetingTest extends TestCase {
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests that a 404 error is thrown when no resource can be found for a
+     * path.
+     * 
+     * @throws Exception
+     */
+    public void test404WhenNoResourceExists() throws Exception {
+        try {
+            String response = client.resource(getBaseURI() + "/doesnotexist").get(String.class);
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(404, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, e.getResponse()
+                .getEntity(String.class));
+        }
+    }
+
+    /**
+     * Tests that a 405 error is thrown when no subresource can be found for a
+     * path.
+     * 
+     * @throws Exception
+     */
+    public void test405WhenNoMethodExistsOnExistingResource() throws Exception {
+        try {
+            String response =
+                client.resource(getBaseURI() + "/existingresource/").get(String.class);
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(405, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(405, e.getResponse()
+                .getEntity(String.class));
+        }
+    }
+
+    /**
+     * Tests that a 404 error is thrown when no subresource can be found for a
+     * path.
+     * 
+     * @throws Exception
+     */
+    public void test404WhenNoSubResourceExists() throws Exception {
+        try {
+            String response =
+                client.resource(getBaseURI() + "/existingresource/noexistsub").get(String.class);
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(404, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, e.getResponse()
+                .getEntity(String.class));
+        }
+
+        String response =
+            client.resource(getBaseURI() + "/targeting/resourcewithmethod").get(String.class);
+        assertEquals("Hello", response);
+
+        try {
+            response =
+                client.resource(getBaseURI() + "/targeting/resourcewithmethod/noexistsub")
+                    .get(String.class);
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(404, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, e.getResponse()
+                .getEntity(String.class));
+        }
+    }
+
+    /**
+     * Tests that a 405 error is thrown when other http methods exist on a
+     * resource but not the one looking for.
+     * 
+     * @throws Exception
+     */
+    public void test405WhenResourceMethodDoesNotExistButOthersDo() throws Exception {
+        try {
+            String response =
+                client.resource(getBaseURI() + "/existingresource/noexistsub").get(String.class);
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(404, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, e.getResponse()
+                .getEntity(String.class));
+        }
+        try {
+            String response =
+                client.resource(getBaseURI() + "/targeting/resourcewithmethod").post(String.class, null);
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(405, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(405, e.getResponse()
+                .getEntity(String.class));
+        }
+    }
+
+    /**
+     * Tests that a 415 error is thrown when request entity data sent is not
+     * acceptable by the resource.
+     * 
+     * @throws Exception
+     */
+    public void test415WhenResourceMethodDoesNotAcceptRequestEntity() throws Exception {
+        String response =
+            client.resource(getBaseURI() + "/targeting/resourcewithmethod")
+                .contentType(MediaType.TEXT_PLAIN).put(String.class, "some content");
+        assertEquals("some content", response);
+
+        try {
+            response =
+                client.resource(getBaseURI() + "/targeting/resourcewithmethod")
+                    .contentType("customplain/something").put(String.class, "some content");
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(415, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, e.getResponse()
+                .getEntity(String.class));
+        }
+    }
+
+    /**
+     * Tests that a 406 error is produced if server side cannot produce any
+     * acceptable content type.
+     * 
+     * @throws Exception
+     */
+    public void test406WhenResourceMethodDoesNotProduceResponseEntityType() throws Exception {
+        String response =
+            client.resource(getBaseURI() + "/targeting/resourcewithmethod")
+                .contentType(MediaType.TEXT_PLAIN).accept(MediaType.TEXT_PLAIN).put(String.class,
+                                                                                    "some content");
+        assertEquals("some content", response);
+
+        try {
+            response =
+                client.resource(getBaseURI() + "/targeting/resourcewithmethod")
+                    .contentType("text/plain").accept("text/customplain").put(String.class,
+                                                                              "some content");
+            fail(response);
+        } catch (ClientWebException e) {
+            assertEquals(406, e.getResponse().getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(406, e.getResponse()
+                .getEntity(String.class));
+        }
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkExceptionsWhileTargetingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkNullValuesDuringTargetingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkNullValuesDuringTargetingTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkNullValuesDuringTargetingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkNullValuesDuringTargetingTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,277 @@
+/*
+ * 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.exceptions;
+
+import java.io.IOException;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+
+import junit.framework.TestCase;
+
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.ClientWebException;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class WinkNullValuesDuringTargetingTest extends TestCase {
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests that a request to a method with no content type, no request entity,
+     * but with a {@link Consumes} method results in a 415 error.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithNoRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        try {
+            client.resource(getBaseURI() + "/targeting/nullresource/withconsumes")
+                .post(String.class, null);
+            fail();
+        } catch (ClientWebException e) {
+            assertEquals(415, e.getResponse().getStatusCode());
+            String responseBody = e.getResponse().getEntity(String.class);
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, responseBody);
+            if (responseBody == null || "".equals(responseBody)) {
+                assertNull(e.getResponse().getHeaders().getFirst("Content-Type"));
+            }
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no content type, a request entity,
+     * but with a {@link Consumes} method results in a 415 error.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        try {
+            client.resource(getBaseURI() + "/targeting/nullresource/withconsumes")
+                .post(String.class, new byte[] {0, 1, 2});
+            fail();
+        } catch (ClientWebException e) {
+            assertEquals(415, e.getResponse().getStatusCode());
+            String responseBody = e.getResponse().getEntity(String.class);
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, responseBody);
+            if (responseBody == null || "".equals(responseBody)) {
+                assertNull(e.getResponse().getHeaders().getFirst("Content-Type"));
+            }
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no content type, a request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        /*
+         * with Wink client, content type is set to applcation/octet-stream if
+         * no content type specified
+         */
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
+                .post("calledWithString");
+        assertEquals(200, response.getStatusCode());
+        assertEquals("calledWithString", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+    /**
+     * Tests that a request to a method with a content type, a request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
+                .contentType("custom/type").post("myString");
+        assertEquals(200, response.getStatusCode());
+        assertEquals("myString", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+    /**
+     * Tests that a request to a method with a content type, no request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithNoRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes")
+                .contentType("text/plain").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+    /**
+     * Tests that a request to a method with no content type, no request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithNoRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutconsumes").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("userReader", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+    /**
+     * Tests that a request to a method with a content type, no request entity,
+     * but with a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithNoRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withconsumes")
+                .contentType("text/plain").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+    /**
+     * Tests that a request to a method with a content type, a request entity,
+     * but with a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withconsumes")
+                .contentType("text/plain").post("mystring");
+        assertEquals(200, response.getStatusCode());
+        assertEquals("mystring", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+
+    /**
+     * Tests that a request to a method with an Accept header with a
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testAcceptHeaderIncomingRequestWithProducesMethod() throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withproduces")
+                .accept("custom/type; q=0.8").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("calledWithProduces", response.getEntity(String.class));
+        assertEquals("custom/type;q=0.8", response.getHeaders().getFirst("Content-Type"));
+    }
+
+    /**
+     * Tests that a request to a method with an Accept header with no
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testAcceptHeaderIncomingRequestWithNoProducesMethod() throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutproduces")
+                .accept("custom/type2; q=0.8").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("calledWithoutProduces", response.getEntity(String.class));
+        assertEquals("custom/type2;q=0.8", response.getHeaders().getFirst("Content-Type"));
+    }
+
+    /**
+     * Tests that a request to a method with no Accept header with a
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoAcceptHeaderIncomingRequestWithProducesMethod() throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withproduces").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("calledWithProduces", response.getEntity(String.class));
+        assertEquals("custom/type", response.getHeaders().getFirst("Content-Type"));
+    }
+
+    /**
+     * Tests that a request to a method with no Accept header with no
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoAcceptHeaderIncomingRequestWithNoProducesMethod() throws IOException {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/nullresource/withoutproduces").post(null);
+        assertEquals(200, response.getStatusCode());
+        assertEquals("calledWithoutProduces", response.getEntity(String.class));
+        String contentType =
+            (response.getHeaders().getFirst("Content-Type") == null) ? null : response.getHeaders()
+                .getFirst("Content-Type");
+        assertNotNull(contentType, contentType);
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkNullValuesDuringTargetingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkValidationDuringTargetingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkValidationDuringTargetingTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkValidationDuringTargetingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkValidationDuringTargetingTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,152 @@
+/*
+ * 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.exceptions;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import junit.framework.TestCase;
+
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class WinkValidationDuringTargetingTest extends TestCase {
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    /**
+     * Tests that a GET method to various paths only differing by
+     * {@link Produces} works.
+     * 
+     * @throws Exception
+     */
+    public void testGETOnlyDifferByProduces() throws Exception {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/resourceonlyproduces")
+                .accept(MediaType.APPLICATION_JSON).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello JSON Produces", response.getEntity(String.class));
+        assertEquals("application/json", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceonlyproduces")
+                .accept(MediaType.APPLICATION_XML).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello XML Produces", response.getEntity(String.class));
+        assertEquals("application/xml", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceonlyproduces")
+                .accept(MediaType.TEXT_XML).get();
+        assertEquals(406, response.getStatusCode());
+        ServerContainerAssertions.assertExceptionBodyFromServer(406, response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests that a GET method to various paths only differing by
+     * {@link Consumes} works.
+     * 
+     * @throws Exception
+     */
+    public void testGETOnlyDifferByConsumes() throws Exception {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/resourceonlyconsumes")
+                .contentType(MediaType.APPLICATION_JSON).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello JSON Consumes", response.getEntity(String.class));
+        assertEquals("text/plain", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceonlyconsumes")
+                .contentType(MediaType.TEXT_XML).get();
+        assertEquals(415, response.getStatusCode());
+        ServerContainerAssertions.assertExceptionBodyFromServer(415, response
+            .getEntity(String.class));
+    }
+
+    /**
+     * Tests that a GET method to various paths only differing by
+     * {@link Consumes} works.
+     * 
+     * @throws Exception
+     */
+    public void testGETOnlyDifferByConsumesAndProduces() throws Exception {
+        ClientResponse response =
+            client.resource(getBaseURI() + "/targeting/resourceconsumesandproduces")
+                .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello JSON Consumes And Produces", response.getEntity(String.class));
+        assertEquals("application/json", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceconsumesandproduces")
+                .contentType(MediaType.APPLICATION_JSON).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello JSON Consumes And Produces", response.getEntity(String.class));
+        assertEquals("application/json", response.getHeaders().getFirst("Content-Type"));
+
+        /*
+         * due to no request Accept header, this is actually undefined behavior
+         * whether it hits the JSON or the XML on the Produces side
+         */
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceconsumesandproduces")
+                .contentType(MediaType.APPLICATION_XML).get();
+        assertEquals(200, response.getStatusCode());
+        if ("application/json".equals(response.getHeaders().getFirst("Content-Type"))) {
+            assertEquals(200, response.getStatusCode());
+            assertEquals("Hello XML Consumes And JSON Produces", response.getEntity(String.class));
+            assertEquals("application/json", response.getHeaders().getFirst("Content-Type"));
+        } else {
+            assertEquals(200, response.getStatusCode());
+            assertEquals("Hello XML Consumes And Produces", response.getEntity(String.class));
+            assertEquals("application/xml", response.getHeaders().getFirst("Content-Type"));
+        }
+
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceconsumesandproduces")
+                .contentType(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello XML Consumes And Produces", response.getEntity(String.class));
+        assertEquals("application/xml", response.getHeaders().getFirst("Content-Type"));
+
+        response =
+            client.resource(getBaseURI() + "/targeting/resourceconsumesandproduces")
+                .contentType(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_JSON).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("Hello XML Consumes And JSON Produces", response.getEntity(String.class));
+        assertEquals("application/json", response.getHeaders().getFirst("Content-Type"));
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/WinkValidationDuringTargetingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/HeadersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/HeadersTest.java?rev=819192&r1=819191&r2=819192&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/HeadersTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/HeadersTest.java Sat Sep 26 19:21:10 2009
@@ -34,12 +34,10 @@
 
 public class HeadersTest extends TestCase {
 
-    private HttpClient          httpClient;
-
-    final private static String BASE_URI = getBaseURI() + "/headers";
+    private HttpClient httpClient;
 
     public static String getBaseURI() {
-        if(ServerEnvironmentInfo.isRestFilterUsed()) {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/headers";
@@ -48,7 +46,7 @@
     public void testGetWithCookies() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/cookie", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/cookie", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Cookie", "$Version=\"1\";login=\"jdoe\"");
             try {
@@ -72,7 +70,7 @@
     public void testGetWithLanguage() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/language", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/language", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Content-Language", "en-us");
             try {
@@ -96,7 +94,7 @@
     public void testGetWithContent() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/content", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/content", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Content-Type", "application/html");
             try {
@@ -120,7 +118,7 @@
     public void testGetWithAccept() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/accept", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/accept", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Accept", "text/*, text/html, text/html;level=1, */*");
             try {
@@ -150,7 +148,7 @@
     public void testGetWithAcceptLanguage() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/acceptlang", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/acceptlang", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Accept-Language", "fr");
             try {
@@ -174,7 +172,7 @@
     public void testGetHeadersWithCase() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/headercase", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/headercase", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Custom-Header", "MyValue");
             try {
@@ -198,7 +196,7 @@
     public void testGetHeadersAcceptAsParam() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/headeraccept", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/headeraccept", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Accept", "text/xml");
             try {
@@ -222,7 +220,7 @@
     public void testGetHeadersAcceptAsArg() throws Exception {
         try {
             GetMethod httpMethod = new GetMethod();
-            httpMethod.setURI(new URI(BASE_URI + "/headersasarg", false));
+            httpMethod.setURI(new URI(getBaseURI() + "/headers/headersasarg", false));
             httpClient = new HttpClient();
             httpMethod.setRequestHeader("Accept", "text/xml application/xml");
             httpMethod.setRequestHeader("Content-Type", "application/xml");

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkApacheHeadersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkApacheHeadersTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkApacheHeadersTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkApacheHeadersTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.headers;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheHeadersTest extends WinkHeadersTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkApacheHeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkHeadersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkHeadersTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkHeadersTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkHeadersTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,147 @@
+/*
+ * 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.headers;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+
+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 WinkHeadersTest extends TestCase {
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/headers";
+    }
+
+    public void testGetWithCookies() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/cookie"))
+                .cookie("$Version=\"1\";login=\"jdoe\"").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("jdoe", response.getHeaders().getFirst("login"));
+    }
+
+    public void testGetWithLanguage() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/language"))
+                .header("Content-Language", "en-us").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("en:US", response.getHeaders().getFirst("language"));
+    }
+
+    public void testGetWithContent() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/content"))
+                .contentType("application/html").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("application/html", response.getHeaders().getFirst("content"));
+    }
+
+    public void testGetWithAccept() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/accept"))
+                .accept("text/*, text/html, text/html;level=1, */*").get();
+        assertEquals(200, response.getStatusCode());
+        assertNotNull(response.getHeaders().getFirst("test-accept"));
+
+        // all q-values = 1, should come back like it was sent
+        String value = response.getHeaders().getFirst("test-accept");
+        assertTrue(value, value.endsWith("*/*"));
+        assertTrue(value, value.contains("text/*"));
+        assertTrue(value, value.contains("text/html"));
+        assertTrue(value, value.contains("text/html;level=1"));
+    }
+
+    public void testGetWithAcceptLanguage() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/acceptlang")).acceptLanguage("fr")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("fr", response.getHeaders().getFirst("acceptlang"));
+    }
+
+    public void testGetHeadersWithCase() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/headercase"))
+                .header("Custom-Header", "MyValue").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("MyValue", response.getHeaders().getFirst("Custom-Header"));
+    }
+
+    public void testGetHeadersAcceptAsParam() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/headeraccept")).accept("text/xml")
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("text/xml", response.getHeaders().getFirst("test-accept"));
+    }
+
+    public void testGetHeadersAcceptAsArg() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headers/headersasarg"))
+                .accept("text/xml application/xml").contentType(MediaType.APPLICATION_XML_TYPE)
+                .get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("text/xml application/xml", response.getHeaders().getFirst("test-accept"));
+        assertEquals("application/xml", response.getHeaders().getFirst("test-content-type"));
+    }
+
+    public void testAllowHeaders() throws Exception {
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/headersallow1/allow1")).options();
+        assertEquals(204, response.getStatusCode());
+
+        List<String> allowedMethods =
+            Arrays.asList(response.getHeaders().getFirst("Allow").split(", "));
+        assertEquals(3, allowedMethods.size());
+        assertTrue(allowedMethods.contains("HEAD"));
+        assertTrue(allowedMethods.contains("OPTIONS"));
+        assertTrue(allowedMethods.contains("GET"));
+
+        response = client.resource(new URI(getBaseURI() + "/headersallow2")).options();
+        assertEquals(204, response.getStatusCode());
+
+        allowedMethods = Arrays.asList(response.getHeaders().getFirst("Allow").split(", "));
+        System.out.println(allowedMethods);
+        assertEquals(6, allowedMethods.size());
+        assertTrue(allowedMethods.contains("HEAD"));
+        assertTrue(allowedMethods.contains("OPTIONS"));
+        assertTrue(allowedMethods.contains("GET"));
+        assertTrue(allowedMethods.contains("PUT"));
+        assertTrue(allowedMethods.contains("POST"));
+        assertTrue(allowedMethods.contains("DELETE"));
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/WinkHeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/LargeEntityTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/LargeEntityTest.java?rev=819192&r1=819191&r2=819192&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/LargeEntityTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/LargeEntityTest.java Sat Sep 26 19:21:10 2009
@@ -41,6 +41,13 @@
         return ServerEnvironmentInfo.getBaseURI() + "/largeentity";
     }
 
+    protected HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests sending a large string. Possible failures including the servlet
      * request buffer being too small, so the status headers do not get set
@@ -51,7 +58,6 @@
      */
     public void testSendLargeString() throws Exception {
         PostMethod postMethod = new PostMethod(getBaseURI() + "/large");
-        HttpClient client = new HttpClient();
         try {
 
             ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
@@ -102,7 +108,6 @@
     public void testSendLargeStringChunked() throws Exception {
         PostMethod postMethod = new PostMethod(getBaseURI() + "/large");
         postMethod.setContentChunked(true);
-        HttpClient client = new HttpClient();
         try {
 
             ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
@@ -146,7 +151,6 @@
      */
     public void testSendJAR() throws Exception {
         PostMethod postMethod = new PostMethod(getBaseURI() + "/large/zip");
-        HttpClient client = new HttpClient();
         try {
             System.out
                 .println(new File(
@@ -172,7 +176,6 @@
     public void testSendJARChunked() throws Exception {
         PostMethod postMethod = new PostMethod(getBaseURI() + "/large/zip");
         postMethod.setContentChunked(true);
-        HttpClient client = new HttpClient();
         try {
             System.out
                 .println(new File(

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkApacheClientLargeEntityTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkApacheClientLargeEntityTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkApacheClientLargeEntityTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkApacheClientLargeEntityTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.largeentity;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheClientLargeEntityTest extends WinkClientLargeEntityTest {
+
+    @Override
+    public void setUp() throws Exception {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkApacheClientLargeEntityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkClientLargeEntityTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkClientLargeEntityTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkClientLargeEntityTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkClientLargeEntityTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,98 @@
+/*
+ * 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.largeentity;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+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 WinkClientLargeEntityTest extends TestCase {
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/largeentity";
+    }
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        client = new RestClient();
+    }
+
+    /**
+     * Tests sending a large string. Possible failures including the servlet
+     * request buffer being too small, so the status headers do not get set
+     * correctly since the message body will have to be flushed out of the
+     * servlet response buffer.
+     * 
+     * @throws Exception
+     */
+    public void testSendLargeString() throws Exception {
+        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+        for (int c = 0; c < 5000000; ++c) {
+            originalContent.write(c);
+        }
+        byte[] entity = originalContent.toByteArray();
+        ClientResponse response =
+            client.resource(new URI(getBaseURI() + "/large")).contentType(MediaType.TEXT_XML_TYPE)
+                .post(entity);
+        assertEquals(277, response.getStatusCode());
+
+        InputStream respStream = response.getEntity(InputStream.class);
+        for (int c = 0; c < entity.length; ++c) {
+            int respByte = respStream.read();
+            assertEquals(entity[c] % 256, (byte)respByte);
+        }
+
+        StringBuffer sb = new StringBuffer();
+        for (int c = 0; c < 50; ++c) {
+            sb.append("abcdefghijklmnopqrstuvwxyz");
+        }
+        assertEquals(sb.toString(), response.getHeaders().getFirst("appendStringsHeader"));
+    }
+
+    /**
+     * Tests sending a JAR file.
+     * 
+     * @throws Exception
+     */
+    public void testSendJAR() throws Exception {
+        ClientResponse response =
+            client
+                .resource(getBaseURI() + "/large/zip")
+                .contentType("application/jar")
+                .post(new File(
+                               ServerEnvironmentInfo.getWorkDir() + "/wink-itest-targeting-0.2-incubating-SNAPSHOT.war"));
+        assertEquals(290, response.getStatusCode());
+        assertEquals("META-INF/DEPENDENCIES", response.getEntity(String.class));
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/WinkClientLargeEntityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java?rev=819192&r1=819191&r2=819192&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java Sat Sep 26 19:21:10 2009
@@ -34,12 +34,19 @@
 public class LifeCycleTest extends TestCase {
 
     public static String getBaseURI() {
-        if(ServerEnvironmentInfo.isRestFilterUsed()) {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/lifecycles";
     }
 
+    protected HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Tests that providers are singletons no matter what.
      * 
@@ -47,7 +54,6 @@
      * @throws IOException
      */
     public void testProvidersAreSingleton() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         StringBuffer sb = new StringBuffer();
         for (long c = 0; c < 5000; ++c) {
             sb.append("a");

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkApacheClientLifeCycleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkApacheClientLifeCycleTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkApacheClientLifeCycleTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkApacheClientLifeCycleTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.lifecycles;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheClientLifeCycleTest extends WinkClientLifeCycleTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkApacheClientLifeCycleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkClientLifeCycleTest.java (from r819007, incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkClientLifeCycleTest.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkClientLifeCycleTest.java&p1=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java&r1=819007&r2=819192&rev=819192&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/WinkClientLifeCycleTest.java Sat Sep 26 19:21:10 2009
@@ -16,63 +16,61 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.wink.itest.lifecycles;
 
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
 import org.apache.wink.test.integration.ServerEnvironmentInfo;
 
-public class LifeCycleTest extends TestCase {
+public class WinkClientLifeCycleTest extends TestCase {
 
     public static String getBaseURI() {
-        if(ServerEnvironmentInfo.isRestFilterUsed()) {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
             return ServerEnvironmentInfo.getBaseURI();
         }
         return ServerEnvironmentInfo.getBaseURI() + "/lifecycles";
     }
 
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
     /**
      * Tests that providers are singletons no matter what.
      * 
      * @throws HttpException
      * @throws IOException
+     * @throws URISyntaxException
      */
-    public void testProvidersAreSingleton() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
+    public void testProvidersAreSingleton() throws URISyntaxException {
         StringBuffer sb = new StringBuffer();
         for (long c = 0; c < 5000; ++c) {
             sb.append("a");
         }
 
-        DeleteMethod deleteMethod = new DeleteMethod(getBaseURI() + "/jaxrs/tests/lifecycles");
-        client.executeMethod(deleteMethod);
-        assertEquals(204, deleteMethod.getStatusCode());
+        ClientResponse response =
+            client.resource(getBaseURI() + "/jaxrs/tests/lifecycles").delete();
+        assertEquals(204, response.getStatusCode());
 
         for (int counter = 0; counter < 100; ++counter) {
-            PostMethod postMethod = new PostMethod(getBaseURI() + "/jaxrs/tests/lifecycles");
-            try {
-                postMethod.setRequestEntity(new StringRequestEntity(sb.toString(), "text/plain",
-                                                                    null));
-                client.executeMethod(postMethod);
-                assertEquals(200, postMethod.getStatusCode());
-                assertEquals(sb.toString(), postMethod.getResponseBodyAsString());
-            } finally {
-                postMethod.releaseConnection();
-            }
+            String responseBody =
+                client.resource(new URI(getBaseURI() + "/jaxrs/tests/lifecycles"))
+                    .contentType("text/plain").post(String.class, sb.toString());
+            assertEquals(sb.toString(), responseBody);
         }
 
-        GetMethod getMethod = new GetMethod(getBaseURI() + "/jaxrs/tests/lifecycles");
-        client.executeMethod(getMethod);
-        assertEquals(200, getMethod.getStatusCode());
-        assertEquals("1:100:100:101:100:1", getMethod.getResponseBodyAsString());
+        response = client.resource(getBaseURI() + "/jaxrs/tests/lifecycles").get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("1:100:100:101:100:1", response.getEntity(String.class));
     }
 }

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodTest.java Sat Sep 26 19:21:10 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.methodannotations;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheHttpMethodTest extends WinkHttpMethodTest {
+
+    @Override
+    public void setUp() {
+        client = new RestClient(new ApacheHttpClientConfig());
+    }
+
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodWarningsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodWarningsTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodWarningsTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodWarningsTest.java Sat Sep 26 19:21:10 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.methodannotations;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class WinkApacheHttpMethodWarningsTest extends WinkHttpMethodWarningsTest {
+
+    @Override
+    public void setUp() {
+        httpclient = new RestClient(new ApacheHttpClientConfig());
+    }
+
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkApacheHttpMethodWarningsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,106 @@
+/*
+ * 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.methodannotations;
+
+import java.util.List;
+
+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 WinkHttpMethodTest extends TestCase {
+
+    protected RestClient client;
+
+    @Override
+    public void setUp() {
+        client = new RestClient();
+    }
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI();
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/customannotations";
+    }
+
+    final private static String BASE_URI = getBaseURI() + "/httpmethod";
+
+    final private static String ALT_URI  = getBaseURI() + "/customhttpmethod";
+
+    /**
+     * Tests that it can find a custom GET HttpMethod annotation.
+     */
+    public void testUserDefinedGETAnnotation() {
+        ClientResponse response = client.resource(BASE_URI).get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("You found my GET method!", response.getEntity(String.class));
+    }
+
+    /**
+     * Tests that an OPTIONS request can be sent to resource containing only a
+     * GET method.
+     */
+    public void testOPTIONSRequest() {
+        ClientResponse response = client.resource(BASE_URI).options();
+        assertEquals(204, response.getStatusCode());
+        String allowHeader = response.getHeaders().getFirst("Allow");
+        assertTrue(allowHeader.contains("HEAD"));
+        assertTrue(allowHeader.contains("GET"));
+        assertTrue(allowHeader.contains("OPTIONS"));
+    }
+
+    /**
+     * Tests that a HEAD request can be sent to resource containing only a GET
+     * method.
+     */
+    public void testHEADRequest() {
+        ClientResponse response = client.resource(BASE_URI).head();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+        assertTrue(response.getHeaders().toString(), response.getHeaders().size() > 0);
+    }
+
+    /**
+     * Tests that a HEAD request can be sent to resource annotated with a custom
+     * HEAD annotation.
+     */
+    public void testCustomHEADRequest() {
+        ClientResponse response = client.resource(ALT_URI).head();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+        assertEquals("TRUE", response.getHeaders().getFirst("HEAD"));
+    }
+
+    /**
+     * Tests that a OPTIONS request can be sent to resource annotated with a
+     * custom OPTIONS annotation.
+     */
+    public void testCustomOPTIONSRequest() {
+        ClientResponse response = client.resource(ALT_URI).options();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("", response.getEntity(String.class));
+        List<String> allowHeader = response.getHeaders().get("Allow");
+        assertTrue(allowHeader.toString(), allowHeader.contains("HEAD"));
+        assertTrue(allowHeader.toString(), allowHeader.contains("OPTIONS"));
+        assertTrue(allowHeader.toString(), allowHeader.contains("GET"));
+    }
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodWarningsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodWarningsTest.java?rev=819192&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodWarningsTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodWarningsTest.java Sat Sep 26 19:21:10 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wink.itest.methodannotations;
+
+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 WinkHttpMethodWarningsTest extends TestCase {
+
+    protected RestClient httpclient;
+
+    @Override
+    public void setUp() {
+        httpclient = new RestClient();
+    }
+
+    public static String getBaseURI() {
+        if (ServerEnvironmentInfo.isRestFilterUsed()) {
+            return ServerEnvironmentInfo.getBaseURI() + "/httpmethodwarning";
+        }
+        return ServerEnvironmentInfo.getBaseURI() + "/customannotations" + "/httpmethodwarning";
+    }
+
+    /**
+     * Tests that two or more <code>@HttpMethod</code> annotated annotations on
+     * a method generates an error. Vague on specification but it seems to be an
+     * error if two or more annotations (which each have a HttpMethod annotation
+     * on them) are on the same resource method. Based on error, it is probably
+     * expected that the resource is unavailable. TODO: So this test could be
+     * that two custom annotations which are annotated each with
+     * <code>@HttpMethod</code> are annotated on the same method.
+     */
+    public void testTwoOrMoreAnnotationsOnMethodError() {
+        ClientResponse response = httpclient.resource(getBaseURI()).post(null);
+        assertEquals(404, response.getStatusCode());
+
+        response = httpclient.resource(getBaseURI()).put(null);
+        int result = response.getStatusCode();
+
+        String responseBody = response.getEntity(String.class);
+        System.out.println(responseBody);
+        /*
+         * if a filter is used, then the 404 will fall through to the container
+         */
+        assertTrue("The result is " + result, (result == 403 && "tomcat"
+            .equals(ServerEnvironmentInfo.getContainerName())) || result == 405
+            || result == 404);
+    }
+
+    /**
+     * Tests that non-public HttpMethod annotations generate a warning.
+     */
+    public void testNonPublicMethodsWarning() {
+        ClientResponse response = httpclient.resource(getBaseURI() + "/abcd").post(null);
+        assertEquals(404, response.getStatusCode());
+
+        response = httpclient.resource(getBaseURI()).delete();
+        int result = response.getStatusCode();
+        /*
+         * if a filter is used, then the 404 will fall through to the container
+         */
+        assertTrue("The result is " + result, (result == 403 && "tomcat"
+            .equals(ServerEnvironmentInfo.getContainerName())) || result == 405
+            || result == 404);
+    }
+
+}

Propchange: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/WinkHttpMethodWarningsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/nofindmethods/DoNotUseMethodNamesForHTTPVerbsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/nofindmethods/DoNotUseMethodNamesForHTTPVerbsTest.java?rev=819192&r1=819191&r2=819192&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/nofindmethods/DoNotUseMethodNamesForHTTPVerbsTest.java (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/nofindmethods/DoNotUseMethodNamesForHTTPVerbsTest.java Sat Sep 26 19:21:10 2009
@@ -44,6 +44,13 @@
         return ServerEnvironmentInfo.getBaseURI() + "/nofindmethods";
     }
 
+    protected HttpClient client;
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
     /**
      * Negative tests that method names that begin with HTTP verbs are not
      * invoked on a root resource.
@@ -52,7 +59,6 @@
      * @throws IOException
      */
     public void testMethodsNotValid() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         HttpMethod method =
             new PostMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/someresource");
         try {
@@ -104,7 +110,6 @@
      * @throws IOException
      */
     public void testSublocatorMethodsNotValid() throws HttpException, IOException {
-        HttpClient client = new HttpClient();
         HttpMethod method =
             new PostMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/sublocatorresource/sub");
         try {