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 [21/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/messagebodywriterexceptions/server/ExceptionResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/ExceptionResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/ExceptionResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/ExceptionResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,38 @@
+/*
+ * 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.messagebodywriterexceptions.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions")
+public class ExceptionResource {
+
+    @POST
+    public String echo(String input) {
+        return "echo:" + input;
+    }
+    
+    @GET
+    public Object something() {
+        return new Object();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/IOExceptionMapper.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/IOExceptionMapper.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/IOExceptionMapper.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/IOExceptionMapper.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,38 @@
+/*
+ * 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.messagebodywriterexceptions.server;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class IOExceptionMapper implements ExceptionMapper<IOException> {
+
+    public Response toResponse(IOException arg0) {
+        return Response.status(455).entity(
+                "Invoked" + this.getClass().getName()).type(
+                        MediaType.TEXT_PLAIN).build();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/MyMessageBodyWriterForStrings.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/MyMessageBodyWriterForStrings.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/MyMessageBodyWriterForStrings.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/MyMessageBodyWriterForStrings.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,109 @@
+/*
+ * 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.messagebodywriterexceptions.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MyMessageBodyWriterForStrings implements MessageBodyWriter<String> {
+
+    public long getSize(String arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        if (arg4.isCompatible(new MediaType("getsize", "throwruntime"))) {
+            throw new RuntimeException();
+        } else if (arg4.isCompatible(new MediaType("getsize", "thrownull"))) {
+            throw new NullPointerException();
+        } else if (arg4.isCompatible(new MediaType("getsize",
+                "throwwebapplicationexception"))) {
+            throw new WebApplicationException(Response.status(499).entity(
+                    "can not write type").type("text/plain").build());
+        }
+
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg3.isCompatible(new MediaType("writable", "throwruntime"))) {
+            throw new RuntimeException();
+        } else if (arg3.isCompatible(new MediaType("writable", "thrownull"))) {
+            throw new NullPointerException();
+        } else if (arg3.isCompatible(new MediaType("writable",
+                "throwwebapplicationexception"))) {
+            throw new WebApplicationException(Response.status(499).entity(
+                    "can not write type").type("text/plain").build());
+        }
+
+        if (arg3.getType().equals("writeto")
+                || arg3.getType().equals("getsize")
+                || arg3.getType().equals("writetoafterwritten")) {
+            return true;
+        }
+
+        return false;
+    }
+
+    public void writeTo(String arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, Object> arg5, OutputStream arg6)
+            throws IOException, WebApplicationException {
+        if (arg4.isCompatible(new MediaType("writeto", "thrownull"))) {
+            throw new NullPointerException();
+        } else if (arg4.isCompatible(new MediaType("writeto",
+                "throwwebapplicationexception"))) {
+            throw new WebApplicationException(Response.status(498).entity(
+                    "can not write type in writeto").type("text/plain").build());
+        } else if (arg4.isCompatible(new MediaType("writeto",
+                "throwioexception"))) {
+            throw new IOException();
+        } else if (arg4.isCompatible(new MediaType("writeto", "throwruntime"))) {
+            throw new RuntimeException();
+        }
+
+        arg6.write("written".getBytes());
+        arg6.flush();
+
+        if (arg4
+                .isCompatible(new MediaType("writetoafterwritten", "thrownull"))) {
+            throw new NullPointerException();
+        } else if (arg4.isCompatible(new MediaType("writetoafterwritten",
+                "throwwebapplicationexception"))) {
+            throw new WebApplicationException(Response.status(498).entity(
+                    "can not write type in writeto").type("text/plain").build());
+        } else if (arg4.isCompatible(new MediaType("writetoafterwritten",
+                "throwioexception"))) {
+            throw new IOException();
+        } else if (arg4.isCompatible(new MediaType("writetoafterwritten",
+                "throwruntime"))) {
+            throw new RuntimeException();
+        }
+
+        arg6.write("writtensomemore".getBytes());
+        arg6.flush();
+
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/NullPointerExceptionMapper.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/NullPointerExceptionMapper.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/NullPointerExceptionMapper.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/NullPointerExceptionMapper.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.messagebodywriterexceptions.server;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class NullPointerExceptionMapper implements ExceptionMapper<NullPointerException> {
+
+    public Response toResponse(NullPointerException arg0) {
+        return Response.status(495).entity(
+                "Invoked" + this.getClass().getName()).type(
+                MediaType.TEXT_PLAIN).build();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/test/MessageBodyWriterExceptionThrownTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/test/MessageBodyWriterExceptionThrownTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/test/MessageBodyWriterExceptionThrownTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/test/MessageBodyWriterExceptionThrownTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,465 @@
+/*
+ * 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.messagebodywriterexceptions.test;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import jaxrs.tests.providers.messagebodywriterexceptions.server.IOExceptionMapper;
+import jaxrs.tests.providers.messagebodywriterexceptions.server.NullPointerExceptionMapper;
+
+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 framework.defaults.test.FVTTestCase;
+
+public class MessageBodyWriterExceptionThrownTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase
+                .getTestSuite(MessageBodyWriterExceptionThrownTest.class,
+                        "jaxrs.tests.providers.messagebodywriterexceptions.server.Application");
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method which is not mapped to an {@link ExceptionMapper} is still thrown.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testIsWritableExceptionThrownWhichIsNotMappedIsThrownOut()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "writable/throwruntime");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method which is mapped to an {@link ExceptionMapper} uses the mapper.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testIsWritableExceptionThrownWhichIsMappedUsesExceptionMapper()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "writable/thrownull");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(495, postMethod.getStatusCode());
+            assertEquals(
+                    "Invoked" + NullPointerExceptionMapper.class.getName(),
+                    postMethod.getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("NullPointerException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link WebApplicationException} thrown from the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is correctly processed.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testIsWritableWebApplicationExceptionThrown()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept",
+                "writable/throwwebapplicationexception");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(499, postMethod.getStatusCode());
+            assertEquals("can not write type", postMethod
+                    .getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("WebApplicationException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method which is not mapped to an {@link ExceptionMapper} is still thrown.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testGetSizeExceptionThrownWhichIsNotMappedIsThrownOut()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "getsize/throwruntime");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method which is mapped to an {@link ExceptionMapper} uses the mapper.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testGetSizeExceptionThrownWhichIsMappedUsesExceptionMapper()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "getsize/thrownull");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(495, postMethod.getStatusCode());
+            assertEquals(
+                    "Invoked" + NullPointerExceptionMapper.class.getName(),
+                    postMethod.getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("NullPointerException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link WebApplicationException} thrown from the
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is correctly processed.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testGetSizeWebApplicationExceptionThrown()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept",
+                "getsize/throwwebapplicationexception");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(499, postMethod.getStatusCode());
+            assertEquals("can not write type", postMethod
+                    .getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("WebApplicationException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method which is not mapped to an {@link ExceptionMapper} is still thrown.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToExceptionThrownWhichIsNotMappedIsThrownOut()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "writeto/throwruntime");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method which is mapped to an {@link ExceptionMapper} uses the mapper.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToExceptionThrownWhichIsMappedUsesExceptionMapper()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "writeto/thrownull");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(495, postMethod.getStatusCode());
+            assertEquals(
+                    "Invoked" + NullPointerExceptionMapper.class.getName(),
+                    postMethod.getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("NullPointerException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link WebApplicationException} thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method is correctly processed.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToWebApplicationExceptionThrown()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept",
+                "writeto/throwwebapplicationexception");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(498, postMethod.getStatusCode());
+            assertEquals("can not write type in writeto", postMethod
+                    .getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("WebApplicationException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link IOException} thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method can be mapped correctly.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToIOExceptionThrown() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "writeto/throwioexception");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(455, postMethod.getStatusCode());
+            assertEquals("Invoked" + IOExceptionMapper.class.getName(),
+                    postMethod.getResponseBodyAsString());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertLogContainsException("IOException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method thrown after the stream is committed is handled.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToExceptionThrownWhichIsNotMappedIsThrownOutAfterStreamCommitted()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept",
+                "writetoafterwritten/throwruntime");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("written", postMethod.getResponseBodyAsString());
+            assertEquals("writetoafterwritten/throwruntime", postMethod
+                    .getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method which is mapped to an {@link ExceptionMapper} after the stream is committed is handled.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToExceptionThrownWhichIsMappedUsesExceptionMapperAfterStreamCommitted()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept", "writetoafterwritten/thrownull");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("written", postMethod.getResponseBodyAsString());
+            assertEquals("writetoafterwritten/thrownull", postMethod
+                    .getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("NullPointerException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link WebApplicationException} thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method is correctly processed.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToWebApplicationExceptionThrownAfterStreamCommitted()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept",
+                "writetoafterwritten/throwwebapplicationexception");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("written", postMethod.getResponseBodyAsString());
+            assertEquals("writetoafterwritten/throwwebapplicationexception",
+                    postMethod.getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("WebApplicationException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link IOException} thrown from the
+     * {@link MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)}
+     * method thrown after the stream is committed is handled.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriteToIOExceptionThrownAfterStreamCommitted()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        postMethod.setRequestHeader("Accept",
+                "writetoafterwritten/throwioexception");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("written", postMethod.getResponseBodyAsString());
+            assertEquals("writetoafterwritten/throwioexception", postMethod
+                    .getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("IOException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a 500 error is returned when a {@link MessageBodyWriter} cannot be found.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void test500IfWriterNotFound() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodywriter/writer/messagebodywriterexceptions");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(500, getMethod.getStatusCode());
+            assertEquals("", getMethod.getResponseBodyAsString());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/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.providers.standard" default="all">
+	<import file="../../../../buildCommon.xml" />
+</project>

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.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(FileResource.class);
+        return clazzes;
+    }
+
+    @Override
+    public Set<Object> getSingletons() {
+        Set<Object> objs = new HashSet<Object>();
+        objs.add(new BytesArrayResource());
+        objs.add(new InputStreamResource());
+        objs.add(new ReaderResource());
+        objs.add(new StreamingOutputResource());
+        objs.add(new MultiValuedMapResource());
+        objs.add(new SourceResource());
+        objs.add(new DataSourceResource());
+        return objs;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/BytesArrayResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/BytesArrayResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/BytesArrayResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/BytesArrayResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,48 @@
+/*
+ * 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.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("providers/standard/bytesarray")
+public class BytesArrayResource {
+
+    private byte[] barr = null;
+
+    @GET
+    public Response getByteArray() {
+        return Response.ok(barr).build();
+    }
+
+    @POST
+    public byte[] postByteArray(byte[] bytearray) {
+        return bytearray;
+    }
+
+    @PUT
+    public void putByteArray(byte[] bytearray) {
+        barr = bytearray;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/DataSourceResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/DataSourceResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/DataSourceResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/DataSourceResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,55 @@
+/*
+ * 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.server;
+
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("providers/standard/datasource")
+public class DataSourceResource {
+
+    private DataSource ds = null;
+
+    @GET
+    public Response getDataSource() {
+        return Response.ok(ds).build();
+    }
+
+    @POST
+    public DataSource postDataSource(DataSource ds) {
+        return ds;
+    }
+
+    @PUT
+    public void putDataSource(DataSource ds) {
+        this.ds = ds;
+    }
+
+    @POST
+    @Path("subclass/should/fail")
+    public DataSource postDataSource(FileDataSource ds) {
+        return ds;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/FileResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/FileResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/FileResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/FileResource.java Tue Jun 23 05:37:57 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 jaxrs.tests.providers.standard.server;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+@Path("providers/standard/file")
+public class FileResource {
+
+    @Context
+    private ServletContext context;
+
+    private static File f;
+
+    private String path = "tests" + java.io.File.separator + "fvt"
+            + java.io.File.separator + "jaxrs" + File.separator + "tests"
+            + java.io.File.separator + "providers" + File.separator
+            + "standard" + File.separator + "server" + File.separator
+            + "something.txt";
+
+    @GET
+    @Path("existingfile")
+    public Response getFileFromExisting() {
+        InputStream stream = context.getResourceAsStream("/WEB-INF/classes/"
+                + path);
+        File f = null;
+        if (stream != null) {
+            f = new File("/WEB-INF/classes/" + path);
+        }
+        f = new File(path);
+        return Response.ok(f).build();
+    }
+
+    @POST
+    public File postFile(File f) {
+        return f;
+    }
+
+    @GET
+    public Response getFile() {
+        return Response.ok(FileResource.f).build();
+    }
+
+    @PUT
+    public void putFile(File f) throws IOException {
+        FileResource.f = f;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/InputStreamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/InputStreamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/InputStreamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/InputStreamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,67 @@
+/*
+ * 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.server;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("providers/standard/inputstream")
+public class InputStreamResource {
+
+    private byte[] barr = null;
+
+    @GET
+    public Response getInputStream() {
+        return Response.ok(new ByteArrayInputStream(barr)).build();
+    }
+
+    @POST
+    public InputStream postInputStream(InputStream is) {
+        return is;
+    }
+
+    @POST
+    @Path("/subclasses/shouldfail")
+    public ByteArrayInputStream postInputStream(ByteArrayInputStream is) {
+        return is;
+    }
+
+    @PUT
+    public void putInputStream(InputStream is) throws IOException {
+        byte[] buffer = new byte[(is.available() <= 0) ? 1 : is.available()];
+        int read = 0;
+        int offset = 0;
+        while ((read = is.read(buffer, offset, buffer.length - offset)) != -1) {
+            offset += read;
+            if (offset >= buffer.length) {
+                buffer = Arrays.copyOf(buffer, buffer.length * 2);
+            }
+        }
+        barr = Arrays.copyOf(buffer, offset);
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/MultiValuedMapResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/MultiValuedMapResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/MultiValuedMapResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/MultiValuedMapResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,57 @@
+/*
+ * 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.server;
+
+import java.io.IOException;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+@Path("providers/standard/multivaluedmap")
+public class MultiValuedMapResource {
+
+    private MultivaluedMap<String, String> formData = null;
+
+    @GET
+    public Response getMultivaluedMap() {
+        return Response.ok(formData).build();
+    }
+
+    @POST
+    public MultivaluedMap<String, String> postMultivaluedMap(MultivaluedMap<String, String> map) {
+        return map;
+    }
+
+    @POST
+    @Path("/subclasses/shouldfail")
+    public MultivaluedMap<String, Object> postMultivaluedMapWithNotRightTypes(MultivaluedMap<String, Object> map) {
+        return map;
+    }
+
+    @PUT
+    public void putMultivaluedMap(MultivaluedMap<String, String> map)
+            throws IOException {
+        formData = map;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/ReaderResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/ReaderResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/ReaderResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/ReaderResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,69 @@
+/*
+ * 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.server;
+
+import java.io.BufferedReader;
+import java.io.CharArrayReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Arrays;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("providers/standard/reader")
+public class ReaderResource {
+
+    private char[] carr = null;
+
+    @GET
+    public Response getReader() {
+        return Response.ok(new BufferedReader(new CharArrayReader(carr)))
+                .build();
+    }
+
+    @POST
+    public Reader postReader(Reader reader) {
+        return reader;
+    }
+
+    @POST
+    @Path("/subclasses/shouldfail")
+    public BufferedReader postReader(BufferedReader br) {
+        return br;
+    }
+
+    @PUT
+    public void putReader(Reader is) throws IOException {
+        char[] buffer = new char[1];
+        int read = 0;
+        int offset = 0;
+        while ((read = is.read(buffer, offset, buffer.length - offset)) != -1) {
+            offset += read;
+            if (offset >= buffer.length) {
+                buffer = Arrays.copyOf(buffer, buffer.length * 2);
+            }
+        }
+        carr = Arrays.copyOf(buffer, offset);
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/SourceResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/SourceResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/SourceResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/SourceResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,57 @@
+/*
+ * 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.server;
+
+import java.io.IOException;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+
+@Path("providers/standard/source")
+public class SourceResource {
+
+    private Source source = null;
+
+    @GET
+    public Response getSource() {
+        return Response.ok(source).build();
+    }
+
+    @POST
+    public Source postSource(Source src) {
+        return src;
+    }
+
+    @POST
+    @Path("/subclasses/shouldfail")
+    public SAXSource postReader(SAXSource saxSource) {
+        return saxSource;
+    }
+
+    @PUT
+    public void putSource(Source source) throws IOException {
+        this.source = source;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/StreamingOutputResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/StreamingOutputResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/StreamingOutputResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/StreamingOutputResource.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.providers.standard.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.StreamingOutput;
+
+@Path("providers/standard/streamingoutput")
+public class StreamingOutputResource {
+
+    private byte[] barr = null;
+
+    @GET
+    public Response getStreamingOutputStream() {
+        return Response.ok(new StreamingOutput() {
+
+            public void write(OutputStream arg0) throws IOException,
+                    WebApplicationException {
+                arg0.write(barr);
+            }
+
+        }).build();
+    }
+
+    @POST
+    public StreamingOutput postInputStream(final InputStream is) {
+        return new StreamingOutput() {
+
+            public void write(OutputStream arg0) throws IOException,
+                    WebApplicationException {
+                int read = 0;
+                while ((read = is.read()) != -1) {
+                    arg0.write(read);
+                }
+            }
+
+        };
+    }
+
+    @PUT
+    public void putInputStream(InputStream is) throws IOException {
+        byte[] buffer = new byte[(is.available() <= 0) ? 1 : is.available()];
+        int read = 0;
+        int offset = 0;
+        while ((read = is.read(buffer, offset, buffer.length - offset)) != -1) {
+            offset += read;
+            if (offset >= buffer.length) {
+                buffer = Arrays.copyOf(buffer, buffer.length * 2);
+            }
+        }
+        barr = Arrays.copyOf(buffer, offset);
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/something.txt
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/something.txt?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/something.txt (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/server/something.txt Tue Jun 23 05:37:57 2009
@@ -0,0 +1 @@
+Greetings from the file system.
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/BytesArrayTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/BytesArrayTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/BytesArrayTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/BytesArrayTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,185 @@
+/*
+ * 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.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 BytesArrayTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(BytesArrayTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting a byte array.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostByteArray() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/bytesarray");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    postMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a byte array.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutByteArray() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/bytesarray");
+        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/bytesarray");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    getMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } 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/bytesarray");
+        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/bytesarray");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    getMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/DataSourceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/DataSourceTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/DataSourceTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/DataSourceTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,213 @@
+/*
+ * 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.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 DataSourceTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(DataSourceTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to a DataSource entity parameter.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostDataSource() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/datasource");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    postMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests putting and then getting a DataSource entity.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPutDataSource() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/datasource");
+        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/datasource");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    getMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests receiving a DataSource with any media type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWithRequestAcceptHeaderWillReturnRequestedContentType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI()
+                + "/providers/standard/datasource");
+        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/datasource");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    getMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests posting to a DataSource subclass. This should result in a 415
+     * error.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostDataSourceSubclass() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/datasource/subclass/should/fail");
+        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(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+}
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/FileTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/FileTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/FileTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/standard/test/FileTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,164 @@
+/*
+ * 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.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 FileTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(FileTest.class,
+                "jaxrs.tests.providers.standard.server.Application");
+    }
+
+    /**
+     * Tests posting to a File entity parameter.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testPostFile() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/providers/standard/file");
+        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());
+            assertEquals(1000, Integer.valueOf(
+                    postMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        /* TODO : need to test that any temporary files created are deleted */
+    }
+
+    /**
+     * Tests putting and then getting a byte array.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testGetFile() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+                + "/providers/standard/file/existingfile");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            String str = getMethod.getResponseBodyAsString();
+            assertEquals("Greetings from the file system.", str);
+            assertEquals("application/octet-stream", getMethod
+                    .getResponseHeader("Content-Type").getValue());
+            assertEquals(31, Integer.valueOf(
+                    getMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } 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/file");
+        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/file");
+        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());
+            assertEquals(barr.length, Integer.valueOf(
+                    getMethod.getResponseHeader("Content-Length").getValue())
+                    .intValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+}



Mime
View raw message