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/08/07 05:10:46 UTC

svn commit: r801869 [19/21] - in /incubator/wink/trunk: wink-integration-test/ wink-integration-test/wink-server-integration-test-support/ wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ wink-i...

Added: 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=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ValidationDuringTargettingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ValidationDuringTargettingTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,238 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class ValidationDuringTargettingTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
+    }
+
+    /**
+     * Tests that a GET method to various paths only differing by
+     * {@link Produces} works.
+     * 
+     * @throws Exception
+     */
+    public void testGETOnlyDifferByProduces() throws Exception {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/targeting/resourceonlyproduces");
+        try {
+            getMethod.addRequestHeader("Accept", "application/json");
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello JSON Produces", getMethod.getResponseBodyAsString());
+            assertEquals("application/json", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceonlyproduces");
+
+        try {
+            getMethod.addRequestHeader("Accept", "application/xml");
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello XML Produces", getMethod.getResponseBodyAsString());
+            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceonlyproduces");
+
+        try {
+            getMethod.addRequestHeader("Accept", "text/xml");
+            client.executeMethod(getMethod);
+
+            assertEquals(406, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(406, getMethod
+                .getResponseBodyAsString());
+        } 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);
+    }
+
+    /**
+     * Tests that a GET method to various paths only differing by
+     * {@link Consumes} works.
+     * 
+     * @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 {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello JSON Consumes", getMethod.getResponseBodyAsString());
+            assertEquals("text/plain", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceonlyconsumes");
+        getMethod.setRequestHeader("Content-Type", "text/xml");
+
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(415, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, getMethod
+                .getResponseBodyAsString());
+        } 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);
+    }
+
+    /**
+     * Tests that a GET method to various paths only differing by
+     * {@link Consumes} works.
+     * 
+     * @throws Exception
+     */
+    public void testGETOnlyDifferByConsumesAndProduces() throws Exception {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod =
+            new GetMethod(getBaseURI() + "/targeting/resourceconsumesandproduces");
+        getMethod.setRequestHeader("Content-Type", "application/json");
+        getMethod.setRequestHeader("Accept", "application/json");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello JSON Consumes And Produces", getMethod.getResponseBodyAsString());
+            assertEquals("application/json", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceconsumesandproduces");
+        getMethod.setRequestHeader("Content-Type", "application/json");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello JSON Consumes And Produces", getMethod.getResponseBodyAsString());
+            assertEquals("application/json", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        /*
+         * due to no request Accept header, this is actually undefined behavior
+         * whether it hits the JSON or the XML on the Produces side
+         */
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceconsumesandproduces");
+        getMethod.setRequestHeader("Content-Type", "application/xml");
+        try {
+            client.executeMethod(getMethod);
+
+            if ("application/json".equals(getMethod.getResponseHeader("Content-Type").getValue())) {
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("Hello XML Consumes And JSON Produces", getMethod
+                    .getResponseBodyAsString());
+                assertEquals("application/json", getMethod.getResponseHeader("Content-Type")
+                    .getValue());
+            } else {
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("Hello XML Consumes And Produces", getMethod.getResponseBodyAsString());
+                assertEquals("application/xml", getMethod.getResponseHeader("Content-Type")
+                    .getValue());
+            }
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceconsumesandproduces");
+        getMethod.setRequestHeader("Content-Type", "application/xml");
+        getMethod.setRequestHeader("Accept", "application/xml");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello XML Consumes And Produces", getMethod.getResponseBodyAsString());
+            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI() + "/targeting/resourceconsumesandproduces");
+        getMethod.setRequestHeader("Content-Type", "application/xml");
+        getMethod.setRequestHeader("Accept", "application/json");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello XML Consumes And JSON Produces", getMethod
+                .getResponseBodyAsString());
+            assertEquals("application/json", getMethod.getResponseHeader("Content-Type").getValue());
+        } 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/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=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/HeadersTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/headers/HeadersTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,304 @@
+/*
+ * 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.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.OptionsMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class HeadersTest extends TestCase {
+
+    private HttpClient          httpClient;
+
+    final private static String BASE_URI = getBaseURI() + "/headers";
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/headers";
+    }
+
+    public void testGetWithCookies() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/cookie", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Cookie", "$Version=\"1\";login=\"jdoe\"");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("login"));
+                assertEquals("jdoe", httpMethod.getResponseHeader("login").getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetWithLanguage() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/language", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Content-Language", "en-us");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("language"));
+                assertEquals("en:US", httpMethod.getResponseHeader("language").getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetWithContent() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/content", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Content-Type", "application/html");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("content"));
+                assertEquals("application/html", httpMethod.getResponseHeader("content").getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetWithAccept() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/accept", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Accept", "text/*, text/html, text/html;level=1, */*");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("test-accept"));
+
+                // all q-values = 1, should come back like it was sent
+                String value = httpMethod.getResponseHeader("test-accept").getValue();
+                assertTrue(value, value.endsWith("*/*"));
+                assertTrue(value, value.contains("text/*"));
+                assertTrue(value, value.contains("text/html"));
+                assertTrue(value, value.contains("text/html;level=1"));
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetWithAcceptLanguage() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/acceptlang", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Accept-Language", "fr");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("acceptlang"));
+                assertEquals("fr", httpMethod.getResponseHeader("acceptlang").getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetHeadersWithCase() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/headercase", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Custom-Header", "MyValue");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("Custom-Header"));
+                assertEquals("MyValue", httpMethod.getResponseHeader("Custom-Header").getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetHeadersAcceptAsParam() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/headeraccept", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Accept", "text/xml");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("test-accept"));
+                assertEquals("text/xml", httpMethod.getResponseHeader("test-accept").getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testGetHeadersAcceptAsArg() throws Exception {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/headersasarg", false));
+            httpClient = new HttpClient();
+            httpMethod.setRequestHeader("Accept", "text/xml application/xml");
+            httpMethod.setRequestHeader("Content-Type", "application/xml");
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                assertEquals(200, result);
+                assertNotNull(httpMethod.getResponseHeader("test-accept"));
+                assertEquals("text/xml application/xml", httpMethod
+                    .getResponseHeader("test-accept").getValue());
+                assertNotNull(httpMethod.getResponseHeader("test-content-type"));
+                assertEquals("application/xml", httpMethod.getResponseHeader("test-content-type")
+                    .getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testAllowHeaders() throws Exception {
+        try {
+            OptionsMethod httpMethod = new OptionsMethod();
+            httpMethod.setURI(new URI(getBaseURI() + "/headersallow1/allow1", false));
+            httpClient = new HttpClient();
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                assertEquals(204, result);
+                assertNotNull(httpMethod.getResponseHeader("Allow"));
+                List<String> allowedMethods =
+                    Arrays.asList(httpMethod.getResponseHeader("Allow").getValue().split(", "));
+                System.out.println(allowedMethods);
+                assertEquals(3, allowedMethods.size());
+                assertTrue(allowedMethods.contains("HEAD"));
+                assertTrue(allowedMethods.contains("OPTIONS"));
+                assertTrue(allowedMethods.contains("GET"));
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        try {
+            OptionsMethod httpMethod = new OptionsMethod();
+            httpMethod.setURI(new URI(getBaseURI() + "/headersallow2", false));
+            httpClient = new HttpClient();
+            try {
+                int result = httpClient.executeMethod(httpMethod);
+                assertEquals(204, result);
+                assertNotNull(httpMethod.getResponseHeader("Allow"));
+                List<String> allowedMethods =
+                    Arrays.asList(httpMethod.getResponseHeader("Allow").getValue().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"));
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+}

Added: 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=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/LargeEntityTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/largeentity/LargeEntityTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,189 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.FileRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class LargeEntityTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/largeentity";
+    }
+
+    /**
+     * 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 {
+        PostMethod postMethod = new PostMethod(getBaseURI() + "/large");
+        HttpClient client = new HttpClient();
+        try {
+
+            ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+            for (int c = 0; c < 5000000; ++c) {
+                originalContent.write(c);
+            }
+            byte[] entity = originalContent.toByteArray();
+            postMethod.setRequestEntity(new ByteArrayRequestEntity(entity, "text/xml"));
+            client.executeMethod(postMethod);
+            assertEquals(277, postMethod.getStatusCode());
+
+            InputStream respStream = postMethod.getResponseBodyAsStream();
+            for (int c = 0; c < entity.length; ++c) {
+                int respByte = respStream.read();
+                assertEquals(entity[c] % 256, (byte)respByte);
+            }
+
+            // final int maxHeaderLength = 100;
+            // int headerLength = (entity.length < maxHeaderLength) ?
+            // entity.length : maxHeaderLength;
+            // byte[] headerBytes = new byte[headerLength];
+            // for (int c = 0; c < headerLength; ++c) {
+            // headerBytes[c] = entity[c];
+            // }
+            //
+
+            StringBuffer sb = new StringBuffer();
+            for (int c = 0; c < 50; ++c) {
+                sb.append("abcdefghijklmnopqrstuvwxyz");
+            }
+            // String expectedHeaderValue = new String(headerBytes, "UTF-8");
+            Header header = postMethod.getResponseHeader("appendStringsHeader");
+            assertNotNull(header);
+            assertEquals(sb.toString(), header.getValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * 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 testSendLargeStringChunked() throws Exception {
+        PostMethod postMethod = new PostMethod(getBaseURI() + "/large");
+        postMethod.setContentChunked(true);
+        HttpClient client = new HttpClient();
+        try {
+
+            ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+            for (int c = 0; c < 5000000; ++c) {
+                originalContent.write(c);
+            }
+            byte[] entity = originalContent.toByteArray();
+            postMethod.setRequestEntity(new ByteArrayRequestEntity(entity, "text/xml"));
+            client.executeMethod(postMethod);
+            assertEquals(277, postMethod.getStatusCode());
+
+            InputStream respStream = postMethod.getResponseBodyAsStream();
+            for (int c = 0; c < entity.length; ++c) {
+                int respByte = respStream.read();
+                assertEquals(entity[c] % 256, (byte)respByte);
+            }
+
+            // int headerLength = (entity.length < 2048) ? entity.length : 2048;
+            // byte[] headerBytes = new byte[headerLength];
+            // for (int c = 0; c < headerLength; ++c) {
+            // headerBytes[c] = entity[c];
+            // }
+
+            StringBuffer sb = new StringBuffer();
+            for (int c = 0; c < 50; ++c) {
+                sb.append("abcdefghijklmnopqrstuvwxyz");
+            }
+            // String expectedHeaderValue = new String(headerBytes, "UTF-8");
+            Header header = postMethod.getResponseHeader("appendStringsHeader");
+            assertNotNull(header);
+            assertEquals(sb.toString(), header.getValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests sending a JAR file.
+     * 
+     * @throws Exception
+     */
+    public void testSendJAR() throws Exception {
+        PostMethod postMethod = new PostMethod(getBaseURI() + "/large/zip");
+        HttpClient client = new HttpClient();
+        try {
+            System.out
+                .println(new File(
+                                  ServerEnvironmentInfo.getWorkDir() + "/wink-itest-targeting-0.1-incubating-SNAPSHOT.war")
+                    .getAbsoluteFile().getAbsolutePath());
+            postMethod.setRequestEntity(new FileRequestEntity(new File(ServerEnvironmentInfo
+                .getWorkDir() + "/wink-itest-targeting-0.1-incubating-SNAPSHOT.war"),
+                                                              "application/jar"));
+            client.executeMethod(postMethod);
+            assertEquals(290, postMethod.getStatusCode());
+            String resp = postMethod.getResponseBodyAsString();
+            assertEquals("META-INF/DEPENDENCIES", resp);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests sending a JAR file in chunked transfer format.
+     * 
+     * @throws Exception
+     */
+    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(
+                                  ServerEnvironmentInfo.getWorkDir() + "/wink-itest-targeting-0.1-incubating-SNAPSHOT.war")
+                    .getAbsoluteFile().getAbsolutePath());
+            postMethod.setRequestEntity(new FileRequestEntity(new File(ServerEnvironmentInfo
+                .getWorkDir() + "/wink-itest-targeting-0.1-incubating-SNAPSHOT.war"),
+                                                              "application/jar"));
+            client.executeMethod(postMethod);
+            assertEquals(290, postMethod.getStatusCode());
+            String resp = postMethod.getResponseBodyAsString();
+            assertEquals("META-INF/DEPENDENCIES", resp);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}

Added: 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=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/lifecycles/LifeCycleTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,75 @@
+/*
+ * 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 java.io.IOException;
+
+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.test.integration.ServerEnvironmentInfo;
+
+public class LifeCycleTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/lifecycles";
+    }
+
+    /**
+     * Tests that providers are singletons no matter what.
+     * 
+     * @throws HttpException
+     * @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");
+        }
+
+        DeleteMethod deleteMethod = new DeleteMethod(getBaseURI() + "/jaxrs/tests/lifecycles");
+        client.executeMethod(deleteMethod);
+        assertEquals(204, deleteMethod.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();
+            }
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/jaxrs/tests/lifecycles");
+        client.executeMethod(getMethod);
+        assertEquals(200, getMethod.getStatusCode());
+        assertEquals("1:100:100:101:100:1", getMethod.getResponseBodyAsString());
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/HttpMethodTest.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/HttpMethodTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/HttpMethodTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/HttpMethodTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,227 @@
+/*
+ * 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.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.OptionsMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Tests various <code>@HttpMethod</code> scenarios.
+ */
+public class HttpMethodTest extends TestCase {
+
+    protected HttpClient httpclient = new HttpClient();
+
+    public static String 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() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(200, result);
+                assertEquals("You found my GET method!", responseBody);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that an OPTIONS request can be sent to resource containing only a
+     * GET method.
+     */
+    public void testOPTIONSRequest() {
+        try {
+            OptionsMethod httpMethod = new OptionsMethod();
+            httpMethod.setURI(new URI(BASE_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(204, result);
+                Enumeration<?> allowedMethods = httpMethod.getAllowedMethods();
+                assertNotNull(allowedMethods);
+                assertTrue(allowedMethods.hasMoreElements());
+                List<String> methods = new ArrayList<String>();
+                while (allowedMethods.hasMoreElements()) {
+                    methods.add((String)allowedMethods.nextElement());
+                }
+                assertTrue(methods.contains("HEAD"));
+                assertTrue(methods.contains("GET"));
+                assertTrue(methods.contains("OPTIONS"));
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that a HEAD request can be sent to resource containing only a GET
+     * method.
+     */
+    public void testHEADRequest() {
+        try {
+            HeadMethod httpMethod = new HeadMethod();
+            httpMethod.setURI(new URI(BASE_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(200, result);
+                assertEquals(null, responseBody);
+                Header[] headers = httpMethod.getResponseHeaders();
+                assertNotNull(headers);
+                assertTrue("Response for HEAD request contained no headers", headers.length > 0);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that a HEAD request can be sent to resource annotated with a custom
+     * HEAD annotation.
+     */
+    public void testCustomHEADRequest() {
+        try {
+            HeadMethod httpMethod = new HeadMethod();
+            httpMethod.setURI(new URI(ALT_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(200, result);
+                assertEquals(null, responseBody);
+                Header header = httpMethod.getResponseHeader("HEAD");
+                assertNotNull(header);
+                assertEquals("TRUE", header.getValue());
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that a OPTIONS request can be sent to resource annotated with a
+     * custom OPTIONS annotation.
+     */
+    public void testCustomOPTIONSRequest() {
+        try {
+            OptionsMethod httpMethod = new OptionsMethod();
+            httpMethod.setURI(new URI(ALT_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(200, result);
+                assertEquals("", responseBody);
+                Header header = httpMethod.getResponseHeader("Allow");
+                assertNotNull(header);
+                String value = header.getValue();
+                assertTrue(value.contains("HEAD"));
+                assertTrue(value.contains("OPTIONS"));
+                assertTrue(value.contains("GET"));
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /*
+     * TODO: Add more tests. - Test custom (non-standard) HTTP Method. - Test
+     * OPTIONS method.
+     */
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/HttpMethodWarningsTest.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/HttpMethodWarningsTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/HttpMethodWarningsTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/methodannotations/HttpMethodWarningsTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,156 @@
+/*
+ * 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.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Tests various errors and warnings in <code>@HTTPMethod</code> conditions.
+ */
+public class HttpMethodWarningsTest extends TestCase {
+
+    protected HttpClient httpclient = new HttpClient();
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/customannotations";
+    }
+
+    final private static String BASE_URI = getBaseURI() + "/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() {
+        try {
+            PostMethod httpMethod = new PostMethod();
+            httpMethod.setURI(new URI(BASE_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(404, result);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        try {
+            PutMethod putMethod = new PutMethod();
+            putMethod.setURI(new URI(BASE_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(putMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = putMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(404, result);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                putMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that non-public HttpMethod annotations generate a warning.
+     */
+    public void testNonPublicMethodsWarning() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/abcd", false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(404, result);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        try {
+            DeleteMethod httpMethod = new DeleteMethod();
+            httpMethod.setURI(new URI(BASE_URI, false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(404, result);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+}

Added: incubator/wink/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=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/nofindmethods/DoNotUseMethodNamesForHTTPVerbsTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/nofindmethods/DoNotUseMethodNamesForHTTPVerbsTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,150 @@
+/*
+ * 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.nofindmethods;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * These tests are designed to make sure the runtime does not invoke methods
+ * that should not be invoked.
+ */
+public class DoNotUseMethodNamesForHTTPVerbsTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/nofindmethods";
+    }
+
+    /**
+     * Negative tests that method names that begin with HTTP verbs are not
+     * invoked on a root resource.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testMethodsNotValid() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+        HttpMethod method =
+            new PostMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/someresource");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method = new GetMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/someresource");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method = new PutMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/someresource");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method = new DeleteMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/someresource");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method = new GetMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/counter/root");
+        try {
+            client.executeMethod(method);
+            assertEquals(200, method.getStatusCode());
+            assertEquals("0", method.getResponseBodyAsString());
+        } finally {
+            method.releaseConnection();
+        }
+    }
+
+    /**
+     * Negative tests that method names that begin with HTTP verbs are not
+     * invoked on a sublocator method.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testSublocatorMethodsNotValid() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+        HttpMethod method =
+            new PostMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/sublocatorresource/sub");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method =
+            new GetMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/sublocatorresource/sub");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method =
+            new PutMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/sublocatorresource/sub");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method =
+            new DeleteMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/sublocatorresource/sub");
+        try {
+            client.executeMethod(method);
+            assertEquals(405, method.getStatusCode());
+        } finally {
+            method.releaseConnection();
+        }
+
+        method = new GetMethod(getBaseURI() + "/nousemethodnamesforhttpverbs/counter/sublocator");
+        try {
+            client.executeMethod(method);
+            assertEquals(200, method.getStatusCode());
+            assertEquals("0", method.getResponseBodyAsString());
+        } finally {
+            method.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/returntypes/ReturnTypeStatusTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/returntypes/ReturnTypeStatusTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/returntypes/ReturnTypeStatusTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/returntypes/ReturnTypeStatusTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,264 @@
+/*
+ * 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.returntypes;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.Response.Status;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Tests return type status codes.
+ */
+public class ReturnTypeStatusTest extends TestCase {
+
+    protected HttpClient httpclient = new HttpClient();
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/returntypes";
+    }
+
+    final private static String BASE_URI = getBaseURI() + "/returntypestatus";
+
+    /**
+     * Tests that a void return type results in a response that has:
+     * <ul>
+     * <li>HTTP status code of 204
+     * <li>empty response body
+     * </ul>
+     */
+    public void testVoidReturnType() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/void", false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(204, result);
+                assertNull(responseBody);
+                /*
+                 * TODO: actually make sure the method was called and not just
+                 * returned/voided
+                 */
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that a null return type on a method that returns an arbitrary
+     * object results in a response that has:
+     * <ul>
+     * <li>HTTP status code of 204
+     * <li>empty response body
+     * </ul>
+     */
+    public void testNullObjectReturnType() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/null", false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(204, result);
+                assertNull(responseBody);
+                /*
+                 * TODO: actually make sure the method was called and not just
+                 * returned/voided
+                 */
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that a null return on a method that is suppose to return a Response
+     * object type results in a response that has:
+     * <ul>
+     * <li>HTTP status code of 204
+     * <li>empty response body
+     * </ul>
+     */
+    public void testNullResponseReturnType() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/nullresponse", false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(204, result);
+                assertNull(responseBody);
+                /*
+                 * TODO: actually make sure the method was called and not just
+                 * returned/voided
+                 */
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests that the status code can be set and returned correctly via a method
+     * that returns a <code>Response</code> return type.
+     */
+    public void testStatusCodeSetResponseReturnType() {
+        for (Status status : Status.values()) {
+            try {
+                GetMethod httpMethod = new GetMethod();
+                httpMethod
+                    .setURI(new URI(BASE_URI + "/responsestatus?code=" + status.name(), false));
+                httpclient = new HttpClient();
+
+                try {
+                    int result = httpclient.executeMethod(httpMethod);
+                    System.out.println("Response status code: " + result);
+                    System.out.println("Response body: ");
+                    String responseBody = httpMethod.getResponseBodyAsString();
+                    System.out.println(responseBody);
+                    assertEquals(status.getStatusCode(), result);
+                    if (status.equals(Status.NO_CONTENT) || status.equals(Status.NOT_MODIFIED)) {
+                        assertEquals(null, responseBody);
+                    } else {
+                        assertEquals("Requested status: " + status.getStatusCode()
+                            + " "
+                            + status.name(), responseBody);
+                    }
+                } catch (IOException ioe) {
+                    ioe.printStackTrace();
+                    fail(ioe.getMessage());
+                } finally {
+                    httpMethod.releaseConnection();
+                }
+            } catch (URIException e) {
+                e.printStackTrace();
+                fail(e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Resource method returns a custom application response which does not have
+     * the status code set but does have an entity. Expect the status code to be
+     * 200 and the entity to be returned.
+     */
+    public void testStatusCodeNotSetResponseReturnType() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/CustomResponseStatusNotSet", false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(200, result);
+                assertEquals("CustomApplicationResponse", responseBody);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Resource method returns a custom application response which does not have
+     * the status code set and does not have an entity. Expect the status code
+     * to be 204 and no content.
+     */
+    public void testStatusCodeNotSetNullEntityResponseReturnType() {
+        try {
+            GetMethod httpMethod = new GetMethod();
+            httpMethod.setURI(new URI(BASE_URI + "/CustomNullResponseStatusNotSet", false));
+            httpclient = new HttpClient();
+
+            try {
+                int result = httpclient.executeMethod(httpMethod);
+                System.out.println("Response status code: " + result);
+                System.out.println("Response body: ");
+                String responseBody = httpMethod.getResponseBodyAsString();
+                System.out.println(responseBody);
+                assertEquals(204, result);
+                assertNull(responseBody);
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+                fail(ioe.getMessage());
+            } finally {
+                httpMethod.releaseConnection();
+            }
+        } catch (URIException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /*
+     * TODO: Test GenericEntity.
+     */
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/SequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/SequenceTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/SequenceTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/SequenceTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,204 @@
+/*
+ * 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.sequence;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Verifies that a sequence of basic calls to the same resource have the
+ * appropriate resource life-cycles.
+ */
+public class SequenceTest extends TestCase {
+
+    private HttpClient client = new HttpClient();
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/sequence";
+    }
+
+    /**
+     * Calls a resource (which is not a singleton) several times. Verifies that
+     * the resource instance is created each time.
+     * 
+     * @throws Exception
+     */
+    public void testHit100TimesRegularResource() throws Exception {
+        client = new HttpClient();
+
+        DeleteMethod deleteMethod = new DeleteMethod(getBaseURI() + "/sequence/static");
+        try {
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+        } finally {
+            deleteMethod.releaseConnection();
+        }
+
+        deleteMethod = new DeleteMethod(getBaseURI() + "/sequence/constructor");
+        try {
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+        } finally {
+            deleteMethod.releaseConnection();
+        }
+
+        for (int c = 0; c < 10; ++c) {
+            GetMethod getMethod = new GetMethod(getBaseURI() + "/sequence");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("0", new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+
+            getMethod = new GetMethod(getBaseURI() + "/sequence/static");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("" + c, new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+
+            PostMethod postMethod = new PostMethod(getBaseURI() + "/sequence");
+            try {
+                client.executeMethod(postMethod);
+                assertEquals(200, postMethod.getStatusCode());
+                assertEquals("1", new BufferedReader(new InputStreamReader(postMethod
+                    .getResponseBodyAsStream(), postMethod.getResponseCharSet())).readLine());
+            } finally {
+                postMethod.releaseConnection();
+            }
+
+            getMethod = new GetMethod(getBaseURI() + "/sequence/static");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("" + (c + 1), new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+
+            getMethod = new GetMethod(getBaseURI() + "/sequence/constructor");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("" + ((c + 1) * 5), new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+        }
+    }
+
+    /**
+     * Calls a singleton resource several times. Verifies that the resource
+     * instance is re-used each time.
+     * 
+     * @throws Exception
+     */
+    public void testHit100TimesSingletonResource() throws Exception {
+        client = new HttpClient();
+
+        DeleteMethod deleteMethod = new DeleteMethod(getBaseURI() + "/singletonsequence/static");
+        try {
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+        } finally {
+            deleteMethod.releaseConnection();
+        }
+
+        deleteMethod = new DeleteMethod(getBaseURI() + "/singletonsequence/");
+        try {
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+        } finally {
+            deleteMethod.releaseConnection();
+        }
+
+        for (int c = 0; c < 10; ++c) {
+            GetMethod getMethod = new GetMethod(getBaseURI() + "/singletonsequence");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("" + c, new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+
+            getMethod = new GetMethod(getBaseURI() + "/singletonsequence/static");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("" + c, new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+
+            PostMethod postMethod = new PostMethod(getBaseURI() + "/singletonsequence");
+            try {
+                client.executeMethod(postMethod);
+                assertEquals(200, postMethod.getStatusCode());
+                assertEquals("" + (c + 1), new BufferedReader(new InputStreamReader(postMethod
+                    .getResponseBodyAsStream(), postMethod.getResponseCharSet())).readLine());
+            } finally {
+                postMethod.releaseConnection();
+            }
+
+            getMethod = new GetMethod(getBaseURI() + "/singletonsequence/static");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("" + (c + 1), new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+
+            /*
+             * the constructor for this resource should never be more than 1.
+             * note the constructor hit count is never cleared.
+             */
+            getMethod = new GetMethod(getBaseURI() + "/singletonsequence/constructor");
+            try {
+                client.executeMethod(getMethod);
+                assertEquals(200, getMethod.getStatusCode());
+                assertEquals("1", new BufferedReader(new InputStreamReader(getMethod
+                    .getResponseBodyAsStream(), getMethod.getResponseCharSet())).readLine());
+            } finally {
+                getMethod.releaseConnection();
+            }
+        }
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/package-info.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/package-info.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/package-info.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/sequence/package-info.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * Tests the appropriate life-cycle behavior of resources and singleton resources when called in sequence.
+ */
+package org.apache.wink.itest.sequence;
\ No newline at end of file

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/transferencoding/TransferEncodingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/transferencoding/TransferEncodingTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/transferencoding/TransferEncodingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/transferencoding/TransferEncodingTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,73 @@
+/*
+ * 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.transferencoding;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class TransferEncodingTest extends TestCase {
+
+    private HttpClient          client;
+
+    final private static String BASE_URI = ServerEnvironmentInfo.getBaseURI() + "/transferencoding";
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
+    /**
+     * Tests sending in small bits of chunked content.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testSendSmallGzipContentEncoded() throws HttpException, IOException {
+        PostMethod postMethod = new PostMethod(BASE_URI + "/chunkedbook");
+        postMethod.setContentChunked(true);
+
+        postMethod.addRequestHeader("Accept", "text/plain");
+        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+        originalContent.write("Hello world".getBytes("UTF-8"));
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        originalContent.writeTo(baos);
+        byte[] content = baos.toByteArray();
+
+        postMethod
+            .setRequestEntity(new ByteArrayRequestEntity(content, "text/plain; charset=utf-8"));
+        try {
+            int result = client.executeMethod(postMethod);
+            assertEquals(200, result);
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("Hello world", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}