incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r787553 [22/34] - in /incubator/wink/contrib/ibm-jaxrs/tests: ./ fvt/ fvt/demo/ fvt/demo/jaxrs/ fvt/demo/jaxrs/cache/ fvt/demo/jaxrs/cache/server/ fvt/demo/jaxrs/cache/test/ fvt/demo/jaxrs/datasource/ fvt/demo/jaxrs/datasource/server/ fvt/d...
Date Tue, 23 Jun 2009 05:38:19 GMT
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/InputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/InputStreamTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/InputStreamTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/InputStreamTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,217 @@
+/*
+ * 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 jaxrs.tests.providers.standard.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Random;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+
+import framework.defaults.test.FVTTestCase;
+
+public class InputStreamTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(InputStreamTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to an InputStream
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostInputStream() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/inputstream");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        postMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "text/plain"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            InputStream is = postMethod.getResponseBodyAsStream();
+
+            byte[] receivedBArr = new byte[1000];
+            DataInputStream dis = new DataInputStream(is);
+            dis.readFully(receivedBArr);
+
+            int checkEOF = dis.read();
+            assertEquals(-1, checkEOF);
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], receivedBArr[c]);
+            }
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = postMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a byte array.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutInputStream() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/inputstream");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        putMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "bytes/array"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/inputstream");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            byte[] receivedBArr = new byte[1000];
+            DataInputStream dis = new DataInputStream(is);
+            dis.readFully(receivedBArr);
+
+            int checkEOF = dis.read();
+            assertEquals(-1, checkEOF);
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], receivedBArr[c]);
+            }
+            assertEquals("application/octet-stream", getMethod
+                    .getResponseHeader("Content-Type").getValue());
+
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests receiving an empty byte array.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWithRequestAcceptHeaderWillReturnRequestedContentType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/inputstream");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        putMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "any/type"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/inputstream");
+        getMethod.addRequestHeader("Accept", "mytype/subtype");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            byte[] receivedBArr = new byte[1000];
+            DataInputStream dis = new DataInputStream(is);
+            dis.readFully(receivedBArr);
+
+            int checkEOF = dis.read();
+            assertEquals(-1, checkEOF);
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], receivedBArr[c]);
+            }
+            assertEquals("mytype/subtype", getMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests a resource method invoked with a ByteArrayInputStream as a
+     * parameter. This should fail with a 415 since the reader has no way to
+     * necessarily wrap it to the type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testInputStreamImplementation() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/inputstream/subclasses/shouldfail");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        postMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "any/type"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/MultivaluedMapTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/MultivaluedMapTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/MultivaluedMapTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/MultivaluedMapTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,236 @@
+/*
+ * 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 jaxrs.tests.providers.standard.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class MultivaluedMapTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(MultivaluedMapTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to a MultivaluedMap with application/x-www-form-urlencoded request Content-Type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostMultivaluedMap() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/multivaluedmap");
+        postMethod.setRequestEntity(new StringRequestEntity("tuv=wxyz&abcd=",
+                "application/x-www-form-urlencoded", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            InputStream is = postMethod.getResponseBodyAsStream();
+
+            InputStreamReader isr = new InputStreamReader(is);
+            char[] buffer = new char[1];
+            int read = 0;
+            int offset = 0;
+            while ((read = isr.read(buffer, offset, buffer.length - offset)) != -1) {
+                offset += read;
+                if (offset >= buffer.length) {
+                    buffer = Arrays.copyOf(buffer, buffer.length * 2);
+                }
+            }
+            char[] carr = Arrays.copyOf(buffer, offset);
+
+            int checkEOF = is.read();
+            assertEquals(-1, checkEOF);
+            String str = new String(carr);
+
+            assertTrue(str, "abcd=&tuv=wxyz".equals(str)
+                    || "tuv=wxyz&abcd=".equals(str));
+            assertEquals("application/x-www-form-urlencoded", postMethod
+                    .getResponseHeader("Content-Type").getValue());
+            Header contentLengthHeader = postMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests posting to a MultivaluedMap with a request Content-Type that is not application/x-www-form-urlencoded.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostMultivaluedMapNotFormURLEncoded() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/multivaluedmap");
+        postMethod.setRequestEntity(new StringRequestEntity("tuv=wxyz&abcd=",
+                "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests posting to a MultivaluedMap with a request Accept type that is not application/x-www-form-urlencoded.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostMultivaluedMapAcceptNotFormURLEncoded()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/multivaluedmap");
+        postMethod.setRequestEntity(new StringRequestEntity("tuv=wxyz&abcd=",
+                "application/x-www-form-urlencoded", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a /multivaluedmap.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutReader() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/multivaluedmap");
+        putMethod.setRequestEntity(new StringRequestEntity(
+                "username=user1&password=user1password",
+                "application/x-www-form-urlencoded", "UTF-8"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/multivaluedmap");
+        getMethod.addRequestHeader("Accept",
+                "application/x-www-form-urlencoded");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            InputStreamReader isr = new InputStreamReader(is);
+            char[] buffer = new char[1];
+            int read = 0;
+            int offset = 0;
+            while ((read = isr.read(buffer, offset, buffer.length - offset)) != -1) {
+                offset += read;
+                if (offset >= buffer.length) {
+                    buffer = Arrays.copyOf(buffer, buffer.length * 2);
+                }
+            }
+            char[] carr = Arrays.copyOf(buffer, offset);
+
+            int checkEOF = is.read();
+            assertEquals(-1, checkEOF);
+            String str = new String(carr);
+
+            assertTrue(str, "username=user1&password=user1password".equals(str)
+                    || "password=user1password&username=user1".equals(str));
+            assertEquals("application/x-www-form-urlencoded", getMethod
+                    .getResponseHeader("Content-Type").getValue());
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+    //
+    //    /**
+    //     * Tests a resource method invoked with a MultivaluedMap&lt;String,
+    //     * Object&gt; as a parameter. This should fail with a 415 since the reader
+    //     * has no way to necessarily wrap it to the type.
+    //     *
+    //     * @throws HttpException
+    //     * @throws IOException
+    //     */
+    //    public void testMultivaluedMapImplementation() throws HttpException, IOException {
+    //        HttpClient client = new HttpClient();
+    //
+    //        PostMethod postMethod = new PostMethod(getBaseURI()
+    //            + "/providers/standard/multivaluedmap/subclasses/shouldfail");
+    //        byte[] barr = new byte[1000];
+    //        Random r = new Random();
+    //        r.nextBytes(barr);
+    //        postMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(barr),
+    //            "any/type"));
+    //        try {
+    //            client.executeMethod(postMethod);
+    //            assertEquals(415, postMethod.getStatusCode());
+    //        } finally {
+    //            postMethod.releaseConnection();
+    //        }
+    //
+    //        postMethod = new PostMethod(getBaseURI()
+    //            + "/providers/standard/multivaluedmap/subclasses/shouldfail");
+    //        postMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(barr),
+    //            "application/x-www-form-urlencoded"));
+    //        try {
+    //            client.executeMethod(postMethod);
+    //            assertEquals(415, postMethod.getStatusCode());
+    //            System.out.println(postMethod.getResponseBodyAsString());
+    //        } finally {
+    //            postMethod.releaseConnection();
+    //        }
+    //    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/ReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/ReaderTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/ReaderTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/ReaderTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,235 @@
+/*
+ * 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 jaxrs.tests.providers.standard.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Random;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class ReaderTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(ReaderTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to a Reader parameter.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostReader() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/reader");
+        postMethod.setRequestEntity(new StringRequestEntity("abcd",
+                "text/plain", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            InputStream is = postMethod.getResponseBodyAsStream();
+
+            InputStreamReader isr = new InputStreamReader(is);
+            char[] buffer = new char[1];
+            int read = 0;
+            int offset = 0;
+            while ((read = isr.read(buffer, offset, buffer.length - offset)) != -1) {
+                offset += read;
+                if (offset >= buffer.length) {
+                    buffer = Arrays.copyOf(buffer, buffer.length * 2);
+                }
+            }
+            char[] carr = Arrays.copyOf(buffer, offset);
+
+            int checkEOF = is.read();
+            assertEquals(-1, checkEOF);
+            String str = new String(carr);
+
+            assertEquals("abcd", str);
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = postMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a Reader.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutReader() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/reader");
+        putMethod.setRequestEntity(new StringRequestEntity("wxyz",
+                "char/array", "UTF-8"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/reader");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            InputStreamReader isr = new InputStreamReader(is);
+            char[] buffer = new char[1];
+            int read = 0;
+            int offset = 0;
+            while ((read = isr.read(buffer, offset, buffer.length - offset)) != -1) {
+                offset += read;
+                if (offset >= buffer.length) {
+                    buffer = Arrays.copyOf(buffer, buffer.length * 2);
+                }
+            }
+            char[] carr = Arrays.copyOf(buffer, offset);
+
+            int checkEOF = is.read();
+            assertEquals(-1, checkEOF);
+            String str = new String(carr);
+
+            assertEquals("wxyz", str);
+            assertEquals("application/octet-stream", getMethod
+                    .getResponseHeader("Content-Type").getValue());
+
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     *
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWithRequestAcceptHeaderWillReturnRequestedContentType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/reader");
+        putMethod.setRequestEntity(new StringRequestEntity("wxyz",
+                "char/array", "UTF-8"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/reader");
+        getMethod.addRequestHeader("Accept", "mytype/subtype");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            InputStreamReader isr = new InputStreamReader(is);
+            char[] buffer = new char[1];
+            int read = 0;
+            int offset = 0;
+            while ((read = isr.read(buffer, offset, buffer.length - offset)) != -1) {
+                offset += read;
+                if (offset >= buffer.length) {
+                    buffer = Arrays.copyOf(buffer, buffer.length * 2);
+                }
+            }
+            char[] carr = Arrays.copyOf(buffer, offset);
+
+            int checkEOF = is.read();
+            assertEquals(-1, checkEOF);
+            String str = new String(carr);
+
+            assertEquals("wxyz", str);
+            assertEquals("mytype/subtype", getMethod.getResponseHeader(
+                    "Content-Type").getValue());
+
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests a resource method invoked with a BufferedReader as a
+     * parameter. This should fail with a 415 since the reader has no way to
+     * necessarily wrap it to the type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testInputStreamImplementation() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/reader/subclasses/shouldfail");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        postMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "any/type"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/SourceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/SourceTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/SourceTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/SourceTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,244 @@
+/*
+ * 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 jaxrs.tests.providers.standard.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Random;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class SourceTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(SourceTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to a Source entity parameter with text/xml
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostSourceWithTextXMLMediaType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/source");
+        postMethod
+                .setRequestEntity(new StringRequestEntity(
+                        "<message><user>user1</user><password>user1pwd</password></message>",
+                        "text/xml", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/xml");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String str = postMethod.getResponseBodyAsString();
+            assertEquals(
+                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message><user>user1</user><password>user1pwd</password></message>",
+                    str);
+            assertEquals("text/xml", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = postMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests posting to a Source entity parameter with application/xml as the
+     * media type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostSourceWithApplicationXMLMediaType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/source");
+        postMethod
+                .setRequestEntity(new StringRequestEntity(
+                        "<message><user>user1</user><password>user1pwd</password></message>",
+                        "application/xml", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "application/xml");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String str = postMethod.getResponseBodyAsString();
+            assertEquals(
+                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message><user>user1</user><password>user1pwd</password></message>",
+                    str);
+            assertEquals("application/xml", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = postMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    // public void testPostSourceWithApplicationWildcardXMLSubtypeMediaType() {
+    // fail();
+    // }
+
+    /**
+     * Tests posting to a Source entity parameter and returning Source entity
+     * response with an unacceptable response media type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostSourceWithNonExpectedAcceptType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/source");
+        postMethod
+                .setRequestEntity(new StringRequestEntity(
+                        "<message><user>user1</user><password>user1pwd</password></message>",
+                        "application/xml", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests posting to a Source entity parameter and returning Source entity
+     * response with an unacceptable request content-type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostSourceWithNonExpectedRequestContentType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/source");
+        postMethod
+                .setRequestEntity(new StringRequestEntity(
+                        "<message><user>user1</user><password>user1pwd</password></message>",
+                        "text/plain", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "application/xml");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a source.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutSource() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/source");
+        putMethod
+                .setRequestEntity(new StringRequestEntity(
+                        "<message><user>user1</user><password>user1pwd</password></message>",
+                        "application/xml", "UTF-8"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/source");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+
+            String str = getMethod.getResponseBodyAsString();
+            assertEquals(
+                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message><user>user1</user><password>user1pwd</password></message>",
+                    str);
+            assertEquals("text/xml", getMethod
+                    .getResponseHeader("Content-Type").getValue());
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests a resource method invoked with a SAXSource as a parameter. This
+     * should fail with a 415 since the reader has no way to necessarily wrap it
+     * to the type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testSourceSubclassImplementation() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/source/subclasses/shouldfail");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        postMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "application/xml"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/StreamingOutputTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/StreamingOutputTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/StreamingOutputTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/StreamingOutputTest.java Tue Jun 23 05:37:57 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 jaxrs.tests.providers.standard.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Random;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+
+import framework.defaults.test.FVTTestCase;
+
+public class StreamingOutputTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(StreamingOutputTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to a StreamingOutput and then returning StreamingOutput.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostStreamingOutput() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/streamingoutput");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        postMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "text/plain"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            InputStream is = postMethod.getResponseBodyAsStream();
+
+            byte[] receivedBArr = new byte[1000];
+            DataInputStream dis = new DataInputStream(is);
+            dis.readFully(receivedBArr);
+
+            int checkEOF = dis.read();
+            assertEquals(-1, checkEOF);
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], receivedBArr[c]);
+            }
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = postMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a StreamingOutput.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutStreamngOutput() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/streamingoutput");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        putMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "bytes/array"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/streamingoutput");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            byte[] receivedBArr = new byte[1000];
+            DataInputStream dis = new DataInputStream(is);
+            dis.readFully(receivedBArr);
+
+            int checkEOF = dis.read();
+            assertEquals(-1, checkEOF);
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], receivedBArr[c]);
+            }
+            assertEquals("application/octet-stream", getMethod
+                    .getResponseHeader("Content-Type").getValue());
+
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests receiving a StreamingOutput with a non-standard content-type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWithRequestAcceptHeaderWillReturnRequestedContentType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/streamingoutput");
+        byte[] barr = new byte[1000];
+        Random r = new Random();
+        r.nextBytes(barr);
+        putMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(barr), "any/type"));
+        try {
+            client.executeMethod(putMethod);
+            assertEquals(204, putMethod.getStatusCode());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/streamingoutput");
+        getMethod.addRequestHeader("Accept", "mytype/subtype");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            InputStream is = getMethod.getResponseBodyAsStream();
+
+            byte[] receivedBArr = new byte[1000];
+            DataInputStream dis = new DataInputStream(is);
+            dis.readFully(receivedBArr);
+
+            int checkEOF = dis.read();
+            assertEquals(-1, checkEOF);
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], receivedBArr[c]);
+            }
+            assertEquals("mytype/subtype", getMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            Header contentLengthHeader = getMethod
+                    .getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null"
+                    : contentLengthHeader.getValue(), contentLengthHeader);
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<project name="jaxrs.tests.returntypes" default="all">
+	<import file="../../../buildCommon.xml" />
+</project>

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,43 @@
+/*
+ * 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 jaxrs.tests.returntypes.server;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Return types test application.
+ */
+public class Application extends javax.ws.rs.core.Application {
+
+    Set<Class<?>> classes = new HashSet<Class<?>>();
+
+    public Application() {
+        classes = new HashSet<Class<?>>();
+        classes.add(ReturnTypeStatusResource.class);
+        classes = Collections.unmodifiableSet(classes);
+    }
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        return classes;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/ReturnTypeStatusResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/ReturnTypeStatusResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/ReturnTypeStatusResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/server/ReturnTypeStatusResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,110 @@
+/*
+ * 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 jaxrs.tests.returntypes.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+
+@Path("returntypestatus")
+public class ReturnTypeStatusResource {
+
+    @Path("/void")
+    @GET
+    public void getVoidResponse() {
+        System.out.println("In void response method");
+    }
+
+    @Path("/null")
+    @GET
+    public Object getNull() {
+        System.out.println("In null response method");
+        return null;
+    }
+
+    @Path("/nullresponse")
+    @GET
+    public Response getNullResponse() {
+        System.out.println("In null response method");
+        return null;
+    }
+
+    @Path("/responsestatus")
+    @GET
+    public Response getResponseStatus(@QueryParam("code") String code) {
+        Status s = Status.valueOf(code);
+        ResponseBuilder respBuilder = Response.status(s);
+        respBuilder.entity("Requested status: " + s.getStatusCode() + " "
+                + s.name());
+        return respBuilder.build();
+    }
+
+    @Path("/CustomResponseStatusNotSet")
+    @GET
+    public Response getCustomResponseStatusNotSet() {
+        final MultivaluedMap<String, Object> map = Response.ok().build()
+                .getMetadata();
+        map.clear();
+        return new Response() {
+            @Override
+            public Object getEntity() {
+                return "CustomApplicationResponse";
+            }
+
+            @Override
+            public MultivaluedMap<String, Object> getMetadata() {
+                return map;
+            }
+
+            @Override
+            public int getStatus() {
+                return -1;
+            }
+        };
+    }
+
+    @Path("/CustomNullResponseStatusNotSet")
+    @GET
+    public Response getCustomNullResponseStatusNotSet() {
+        final MultivaluedMap<String, Object> map = Response.ok().build()
+                .getMetadata();
+        map.clear();
+        return new Response() {
+            @Override
+            public Object getEntity() {
+                return null;
+            }
+
+            @Override
+            public MultivaluedMap<String, Object> getMetadata() {
+                return map;
+            }
+
+            @Override
+            public int getStatus() {
+                return -1;
+            }
+        };
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/test/ReturnTypeStatusTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/test/ReturnTypeStatusTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/test/ReturnTypeStatusTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/returntypes/test/ReturnTypeStatusTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,272 @@
+/*
+ * 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 jaxrs.tests.returntypes.test;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.Response.Status;
+
+import junit.framework.Test;
+
+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 framework.defaults.test.DefaultURIInfo;
+import framework.defaults.test.FVTTestCase;
+
+/**
+ * Tests return type status codes.
+ */
+public class ReturnTypeStatusTest extends FVTTestCase {
+
+    protected HttpClient httpclient = new HttpClient();
+
+    final private static String BASE_URI = DefaultURIInfo
+            .getClassDefaultBaseURI(ReturnTypeStatusTest.class)
+            + "/returntypestatus";
+
+    public static Test suite() {
+        return FVTTestCase.getTestSuite(ReturnTypeStatusTest.class,
+                jaxrs.tests.returntypes.server.Application.class.getName());
+    }
+
+    /**
+     * 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/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<project name="jaxrs.tests.sequence" default="all">
+	<import file="../../../buildCommon.xml" />
+</project>

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,41 @@
+/*
+ * 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 jaxrs.tests.sequence.server;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> clazzes = new HashSet<Class<?>>();
+        clazzes.add(SequenceResource.class);
+        return clazzes;
+    }
+
+    @Override
+    public Set<Object> getSingletons() {
+        Set<Object> classes = new HashSet<Object>();
+        classes.add(new SequenceSingletonResource());
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,80 @@
+/*
+ * 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 jaxrs.tests.sequence.server;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+/**
+ * A resource which keeps track of a constructor, method, and overall static
+ * count for testing resources called multiple times.
+ */
+@Path("/sequence")
+public class SequenceResource {
+
+    private int hits = 0;
+
+    private static int staticHitCount = 0;
+
+    private static int constructorHitCount = 0;
+
+    public SequenceResource() {
+        hits = 0;
+        constructorHitCount += 1;
+    }
+
+    @GET
+    public String countHits() {
+        return "" + hits;
+    }
+
+    @POST
+    public String addHit() {
+        ++hits;
+        ++staticHitCount;
+        return "" + hits;
+    }
+
+    @DELETE
+    @Path("/static")
+    public void clearStaticHitCount() {
+        staticHitCount = 0;
+    }
+
+    @GET
+    @Path("/static")
+    public String countStaticHits() {
+        return "" + staticHitCount;
+    }
+
+    @DELETE
+    @Path("/constructor")
+    public void clearConstructorHitCount() {
+        constructorHitCount = 0;
+    }
+
+    @GET
+    @Path("/constructor")
+    public String countConstructorHits() {
+        return "" + constructorHitCount;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceSingletonResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceSingletonResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceSingletonResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/server/SequenceSingletonResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,80 @@
+/*
+ * 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 jaxrs.tests.sequence.server;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+/**
+ * A singleton resource which keeps track of a constructor, method, and overall
+ * static count for testing resources called multiple times.
+ */
+@Path("/singletonsequence")
+public class SequenceSingletonResource {
+
+    private int hits = 0;
+
+    private static int staticHitCount = 0;
+
+    private static int constructorHitCount = 0;
+
+    public SequenceSingletonResource() {
+        hits = 0;
+        ++constructorHitCount;
+    }
+
+    @GET
+    public String countHits() {
+        return "" + hits;
+    }
+
+    @POST
+    public String addHit() {
+        ++hits;
+        ++staticHitCount;
+        return "" + hits;
+    }
+
+    @DELETE
+    @Path("/static")
+    public void clearStaticHitCount() {
+        staticHitCount = 0;
+    }
+
+    @GET
+    @Path("/static")
+    public String countStaticHits() {
+        return "" + staticHitCount;
+    }
+
+    @DELETE
+    @Path("/constructor")
+    public void clearConstructorHitCount() {
+        constructorHitCount = 0;
+    }
+
+    @GET
+    @Path("/constructor")
+    public String countConstructorHits() {
+        return "" + constructorHitCount;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/SequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/SequenceTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/SequenceTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/SequenceTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,217 @@
+/*
+ * 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 jaxrs.tests.sequence.test;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+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 framework.defaults.test.FVTTestCase;
+
+/**
+ * Verifies that a sequence of basic calls to the same resource have the
+ * appropriate resource life-cycles.
+ */
+public class SequenceTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(SequenceTest.class,
+                "jaxrs.tests.sequence.server.Application");
+    }
+
+    private HttpClient client = new HttpClient();
+
+    /**
+     * 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();
+        }
+
+        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/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/package-info.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/package-info.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/package-info.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/sequence/test/package-info.java Tue Jun 23 05:37:57 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 jaxrs.tests.sequence.test;
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<project name="jaxrs.tests.targetting" default="all">
+	<import file="../../../buildCommon.xml" />
+</project>

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/targetting/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,40 @@
+/*
+ * 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 jaxrs.tests.targetting.server;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> clazzes = new HashSet<Class<?>>();
+        clazzes.add(ExistingResource.class);
+        clazzes.add(ResourceWithMethod.class);
+        clazzes.add(ResourceWithOnlyConsumesAndGET.class);
+        clazzes.add(ResourceWithOnlyProducesAndGET.class);
+        clazzes.add(ResourceWithConsumesAndProducesAndGET.class);
+        clazzes.add(NullResource.class);
+        clazzes.add(ApplicationOctetStreamMessageBodyReader.class);
+        return clazzes;
+    }
+
+}



Mime
View raw message