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 [20/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/messagebodyreaderexceptions/test/MessageBodyReaderExceptionThrownTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/test/MessageBodyReaderExceptionThrownTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/test/MessageBodyReaderExceptionThrownTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/test/MessageBodyReaderExceptionThrownTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,229 @@
+/*
+ * 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.messagebodyreaderexceptions.test;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.MessageBodyReader;
+
+import jaxrs.tests.providers.messagebodyreaderexceptions.server.IOExceptionMapper;
+import jaxrs.tests.providers.messagebodyreaderexceptions.server.NullPointerExceptionMapper;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class MessageBodyReaderExceptionThrownTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(MessageBodyReaderExceptionThrownTest.class,
+            "jaxrs.tests.providers.messagebodyreaderexceptions.server.Application");
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyReader#isReadable(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 testIsReadableExceptionThrownWhichIsNotMappedIsThrownOut() throws HttpException,
+        IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input",
+            "readable/throwruntime", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyReader#isReadable(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 testIsReadableExceptionThrownWhichIsMappedUsesExceptionMapper()
+        throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input", "readable/thrownull",
+            "UTF-8"));
+        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 MessageBodyReader#isReadable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is correctly processed.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testIsReadableWebApplicationExceptionThrown() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input",
+            "readable/throwwebapplicationexception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(499, postMethod.getStatusCode());
+            assertEquals("can not read type", postMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", postMethod.getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("WebApplicationException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.InputStream)}
+     * method which is not mapped to an {@link ExceptionMapper} is still thrown.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReadFromExceptionThrownWhichIsNotMappedIsThrownOut() throws HttpException,
+        IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input",
+            "readfrom/throwruntime", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an exception thrown from the
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.InputStream)}
+     * method which is mapped to an {@link ExceptionMapper} uses the mapper.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReadFromExceptionThrownWhichIsMappedUsesExceptionMapper() throws HttpException,
+        IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input", "readfrom/thrownull",
+            "UTF-8"));
+        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 MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.InputStream)}
+     * method is correctly processed.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReadFromWebApplicationExceptionThrown() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input",
+            "readfrom/throwwebapplicationexception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(498, postMethod.getStatusCode());
+            assertEquals("can not read type in readfrom", postMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", postMethod.getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("WebApplicationException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a {@link IOException} thrown from the
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.InputStream)}
+     * method can be mapped correctly.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReadFromIOExceptionThrown() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodyreader/reader/messagebodyreaderexceptions");
+        postMethod.setRequestEntity(new StringRequestEntity("ignored input",
+            "readfrom/throwioexception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(455, postMethod.getStatusCode());
+            assertEquals("Invoked" + IOExceptionMapper.class.getName(), postMethod
+                .getResponseBodyAsString());
+            assertEquals("application/octet-stream", postMethod.getResponseHeader("Content-Type").getValue());
+            assertLogContainsException("IOException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}

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

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/Application.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.messagebodywriter.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(WriterResource.class);
+        return clazzes;
+    }
+
+    @Override
+    public Set<Object> getSingletons() {
+        Set<Object> objs = new HashSet<Object>();
+        objs.add(new MessageBodyWriterIsWritableClassDeque());
+        objs.add(new MessageBodyWriterIsWritableGenericEntitySetString());
+        objs.add(new MessageBodyWriterIsWritableGenericEntitySetInteger());
+        objs.add(new MessageBodyWriterIsWritableSet());
+        objs.add(new MessageBodyWriterIsWritableGetAnnotated());
+        objs.add(new MessageBodyWriterIsWritablePostAnnotated());
+        objs.add(new MessageBodyWriterIsWritableMediaTypeHashMap());
+        objs.add(new MessageBodyWriterIsWritableThrowsExceptions());
+        objs.add(new MessageBodyWriterContentLength());
+        return objs;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/CustomAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/CustomAnnotation.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/CustomAnnotation.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/CustomAnnotation.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.providers.messagebodywriter.server;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER, ElementType.METHOD })
+public @interface CustomAnnotation {
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterContentLength.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterContentLength.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterContentLength.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterContentLength.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,173 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterContentLength implements MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        if (arg1.equals(byte[].class)) {
+            byte[] barr = (byte[]) arg0;
+            if (arg4.equals(new MediaType("length", "shorter"))) {
+                return barr.length - 10;
+            } else if (arg4.equals(new MediaType("length", "longer"))) {
+                return barr.length + 10;
+            }
+            return -1;
+        }
+
+        if (arg1.equals(Vector.class) && arg2.equals(Vector.class)) {
+            return 17;
+        }
+
+        if (arg1.equals(ArrayList.class)) {
+            if (arg2 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg2;
+                if (pt.getRawType().equals(List.class)) {
+                    if (pt.getActualTypeArguments().length == 1
+                        && pt.getActualTypeArguments()[0].equals(Integer.class)) {
+                        return 14;
+                        // return true;
+                    }
+                }
+            }
+
+            if (arg1.equals(ArrayList.class)) {
+                // return true;
+            }
+        }
+
+        if (arg1.equals(String.class)) {
+            boolean isGetFound = false;
+            for (Annotation ann : arg3) {
+                if (ann.annotationType().equals(CustomAnnotation.class)) {
+                    isGetFound = true;
+                }
+            }
+
+            if (isGetFound) {
+                return 18;
+            }
+        }
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg0.equals(byte[].class) || arg0.equals(Vector.class)) {
+            return true;
+        }
+
+        if (arg0.equals(ArrayList.class)) {
+            if (arg1 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg1;
+                if (pt.getRawType().equals(List.class)) {
+                    if (pt.getActualTypeArguments().length == 1
+                        && pt.getActualTypeArguments()[0].equals(Integer.class)) {
+                        return true;
+                    }
+                }
+            }
+
+            if (arg1.equals(ArrayList.class)) {
+                return true;
+            }
+        }
+
+        if (arg1.equals(String.class)) {
+            for (Annotation ann : arg2) {
+                if (ann.annotationType().equals(CustomAnnotation.class)) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        if (arg1.equals(byte[].class)) {
+            arg6.write((byte[]) arg0);
+        } else if (arg1.equals(Vector.class)) {
+            Writer writer = new OutputStreamWriter(arg6);
+            writer.write("vector:");
+            Vector vec = (Vector) arg0;
+            for (Object o : vec) {
+                writer.write(o.toString());
+            }
+            writer.flush();
+        } else if (arg1.equals(ArrayList.class)) {
+            if (arg2 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg2;
+                if (pt.getRawType().equals(List.class)) {
+                    if (pt.getActualTypeArguments().length == 1
+                        && pt.getActualTypeArguments()[0].equals(Integer.class)) {
+                        Writer writer = new OutputStreamWriter(arg6);
+                        writer.write("listinteger:");
+                        List list = (List) arg0;
+                        for (Object o : list) {
+                            writer.write(o.toString());
+                        }
+                        writer.flush();
+                    }
+                }
+            }
+        } else if (arg1.equals(String.class)) {
+            boolean isCustomAnnotationFound = false;
+            for (Annotation ann : arg3) {
+                if (ann.annotationType().equals(CustomAnnotation.class)) {
+                    isCustomAnnotationFound = true;
+                }
+            }
+
+            if (isCustomAnnotationFound) {
+                arg6.write("string:".getBytes());
+                arg6.write(((String) arg0).getBytes());
+            }
+        } else {
+            Writer writer = new OutputStreamWriter(arg6);
+            writer.write("getannotation:");
+            List list = (List) arg0;
+            for (Object o : list) {
+                writer.write(o.toString());
+            }
+            writer.flush();
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableClassDeque.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableClassDeque.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableClassDeque.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableClassDeque.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.providers.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Deque;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritableClassDeque implements MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (Deque.class.isAssignableFrom(arg0)) {
+            return true;
+        }
+        return false;
+    }
+
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        Deque d = (Deque) arg0;
+        writer.write("deque:");
+        for (Object o : d) {
+            writer.write(o.toString());
+        }
+        writer.flush();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetInteger.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetInteger.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetInteger.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetInteger.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,78 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritableGenericEntitySetInteger implements
+    MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg0.isAssignableFrom(HashSet.class)) {
+            if (arg1 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg1;
+                Type[] args = pt.getActualTypeArguments();
+                if (args.length == 1 && args[0].equals(Integer.class)) {
+                    if (pt.getRawType().equals(Set.class)) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        Set<Integer> s = (Set<Integer>) arg0;
+        writer.write("set<integer>:");
+        List<Integer> list = new ArrayList<Integer>(s);
+        Collections.sort(list);
+        for (Object o : list) {
+            writer.write(o.toString());
+        }
+        writer.flush();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetString.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetString.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetString.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGenericEntitySetString.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,78 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritableGenericEntitySetString implements MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg0.isAssignableFrom(HashSet.class)) {
+            if (arg1 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg1;
+                Type[] args = pt.getActualTypeArguments();
+                if (args.length == 1 && args[0].equals(String.class)) {
+                    if (pt.getRawType().equals(Set.class)) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        Set<String> s = (Set<String>) arg0;
+        writer.write("set<string>:");
+        List<String> list = new ArrayList<String>(s);
+        Collections.sort(list);
+        for (Object o : list) {
+            writer.write(o.toString());
+        }
+        writer.flush();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGetAnnotated.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGetAnnotated.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGetAnnotated.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableGetAnnotated.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,71 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritableGetAnnotated implements MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        boolean isGetAnnotated = false;
+        boolean isMyWriterAnnotated = false;
+        for (Annotation ann : arg2) {
+            if (MyWriterAnnotation.class.equals(ann.annotationType())) {
+                isMyWriterAnnotated = true;
+            } else if (GET.class.equals(ann.annotationType())) {
+                isGetAnnotated = true;
+            }
+        }
+        if (isMyWriterAnnotated && isGetAnnotated) {
+            return true;
+        }
+        return false;
+    }
+
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        writer.write("getannotation:");
+        List list = (List)arg0;
+        for (Object o : list) {
+            writer.write(o.toString());
+        }
+        writer.flush();
+    }
+}
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableMediaTypeHashMap.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableMediaTypeHashMap.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableMediaTypeHashMap.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableMediaTypeHashMap.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritableMediaTypeHashMap implements MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg3.equals(new MediaType("custom", "correct"))) {
+            return true;
+        }
+        return false;
+    }
+
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        writer.write("mediatype:");
+        Map map = (Map) arg0;
+        for (Object k : map.keySet()) {
+            writer.write(k.toString() + "=" + map.get(k));
+        }
+        writer.flush();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritablePostAnnotated.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritablePostAnnotated.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritablePostAnnotated.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritablePostAnnotated.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,70 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritablePostAnnotated  implements MessageBodyWriter<List> {
+
+    public long getSize(List arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        boolean isPostAnnotated = false;
+        boolean isMyWriterAnnotated = false;
+        for (Annotation ann : arg2) {
+            if (MyWriterAnnotation.class.equals(ann.annotationType())) {
+                isMyWriterAnnotated = true;
+            } else if (POST.class.equals(ann.annotationType())) {
+                isPostAnnotated = true;
+            }
+        }
+        if(isMyWriterAnnotated && isPostAnnotated) {
+            return true;
+        }
+        return false;
+    }
+
+    public void writeTo(List arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        writer.write("postannotation:");
+        for (Object o : arg0) {
+            writer.write(o.toString());
+        }
+        writer.flush();
+    }
+}
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableSet.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableSet.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableSet.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableSet.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.messagebodywriter.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MessageBodyWriterIsWritableSet implements MessageBodyWriter<Set> {
+
+    public long getSize(Set arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg0.isAssignableFrom(HashSet.class)) {
+            if (arg1 instanceof Class) {
+                return arg1.equals(HashSet.class);
+            }
+        }
+        return false;
+    }
+
+    @SuppressWarnings({ "unchecked", "cast" })
+    public void writeTo(Set arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        Writer writer = new OutputStreamWriter(arg6);
+        Set<?> s = (Set<?>) arg0;
+        writer.write("set:");
+        List list = new ArrayList(s);
+        Collections.sort(list);
+        for (Object o : list) {
+            writer.write(o.toString());
+        }
+        writer.flush();
+
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableThrowsExceptions.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableThrowsExceptions.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableThrowsExceptions.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MessageBodyWriterIsWritableThrowsExceptions.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,59 @@
+/*
+ * 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.messagebodywriter.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 MessageBodyWriterIsWritableThrowsExceptions implements MessageBodyWriter<Object> {
+
+    public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg3.equals(new MediaType("throw", "runtime"))) {
+            throw new RuntimeException();
+        } else if (arg3.equals(new MediaType("throw", "nullpointer"))) {
+            throw new NullPointerException();
+        } else if (arg3.equals(new MediaType("throw", "webapplicationexception"))) {
+            throw new WebApplicationException(Response.status(461).entity(
+                "throwiswritableexception").build());
+        }
+        return false;
+    }
+
+    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
+        MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException,
+        WebApplicationException {
+        /* do nothing */
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MyWriterAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MyWriterAnnotation.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MyWriterAnnotation.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/MyWriterAnnotation.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.providers.messagebodywriter.server;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER,
+    ElementType.METHOD })
+public @interface MyWriterAnnotation {
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/WriterResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/WriterResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/WriterResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/server/WriterResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.providers.messagebodywriter.server;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.GenericEntity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.transform.dom.DOMSource;
+
+@Path("jaxrs/tests/providers/messagebodywriter")
+public class WriterResource {
+
+    private static int counter = 0;
+
+    @GET
+    @Path("concretetype")
+    public String getConcretTypeBack() {
+        return "Hello there";
+    }
+
+    @GET
+    @Path("contentlength")
+    @CustomAnnotation
+    public Response getContentLength(@QueryParam("mt") String mt, @QueryParam("class") String clazz) {
+        if (clazz == null) {
+            byte[] barr = new byte[100];
+            for (int c = 0; c < barr.length; ++c) {
+                barr[c] = (byte) c;
+            }
+            return Response.ok(barr).type(mt).build();
+        } else if ("Vector".equals(clazz)) {
+            Vector v = new Vector(2);
+            v.add("Hello");
+            v.add("There");
+            return Response.ok(v).type(mt).build();
+        } else if ("ListInteger".equals(clazz)) {
+            List<Integer> v = new ArrayList<Integer>(2);
+            v.add(1);
+            v.add(2);
+            return Response.ok(new GenericEntity<List<Integer>>(v) {
+            }).build();
+        } else if ("String".equals(clazz)) {
+            return Response.ok("hello there").build();
+        }
+        return null;
+    }
+
+    @Path("classtype")
+    @GET
+    public Object getWriterClassType(@QueryParam("type") String type) {
+        if ("deque".equals(type)) {
+            ArrayDeque<String> d = new ArrayDeque<String>();
+            d.add("str:foo");
+            d.add("str:bar");
+            return d;
+        } else if ("hashmap".equals(type)) {
+            return new HashMap<String, String>();
+        } else if ("string".equals(type)) {
+            return "str:foobar";
+        } else if ("stringcontenttype".equals(type)) {
+            return Response.ok("str:foobarcontenttype").type(MediaType.APPLICATION_XML_TYPE)
+                .build();
+        } else if ("sourcecontenttype".equals(type)) {
+            return Response.ok(new DOMSource()).type(MediaType.APPLICATION_JSON).build();
+        } else if ("source".equals(type)) {
+            return Response.ok(new DOMSource()).type(MediaType.TEXT_XML).build();
+        }
+        return null;
+    }
+
+    @Path("notannotated")
+    @GET
+    public Object getWriterNotAnnotatedMethod() {
+        List<String> l = new ArrayList<String>();
+        l.add("foo");
+        l.add("bar");
+        return l;
+    }
+
+    @Path("annotated")
+    @GET
+    @MyWriterAnnotation
+    public Object getWriterAnnotatedMethod() {
+        List<String> l = new ArrayList<String>();
+        l.add("foo");
+        l.add("bar");
+        return l;
+    }
+
+    @Path("annotated")
+    @POST
+    @MyWriterAnnotation
+    public Object postWriterAnnotatedMethod() {
+        List<String> l = new ArrayList<String>();
+        l.add("foo");
+        l.add("bar");
+        return l;
+    }
+
+    @Path("genericentity")
+    @POST
+    public Response getWriterResponse(@QueryParam("query") String q) {
+        if ("setstring".equals(q)) {
+            HashSet<String> s = new HashSet<String>();
+            s.add("hello");
+            s.add("world");
+            return Response.ok(new GenericEntity<Set<String>>(s) {
+            }).build();
+        } else if ("setinteger".equals(q)) {
+            HashSet<Integer> s = new HashSet<Integer>();
+            s.add(Integer.valueOf(1));
+            s.add(Integer.valueOf(2));
+            return Response.ok(new GenericEntity<Set<Integer>>(s) {
+            }).build();
+        } else if ("setshort".equals(q)) {
+            HashSet<Short> s = new HashSet<Short>();
+            s.add(Short.valueOf((short) 1));
+            s.add(Short.valueOf((short) 2));
+            return Response.ok(new GenericEntity<Set<Short>>(s) {
+            }).build();
+        }
+        return null;
+    }
+
+    @Path("nogenericentity")
+    @POST
+    public Response getNoWriterResponse(@QueryParam("query") String q) {
+        if ("setstring".equals(q)) {
+            HashSet<String> s = new HashSet<String>();
+            s.add("hello");
+            s.add("world");
+            return Response.ok(s).build();
+        } else if ("setinteger".equals(q)) {
+            HashSet<Integer> s = new HashSet<Integer>();
+            s.add(Integer.valueOf(1));
+            s.add(Integer.valueOf(2));
+            return Response.ok(s).build();
+        } else if ("setshort".equals(q)) {
+            HashSet<Short> s = new HashSet<Short>();
+            s.add(Short.valueOf((short) 1));
+            s.add(Short.valueOf((short) 2));
+            return Response.ok(s).build();
+        }
+        return null;
+    }
+
+    @Path("mediatype")
+    @POST
+    public Response getMediaType(@QueryParam("mt") String mt) {
+        HashMap<String, String> hm = new HashMap<String, String>();
+        hm.put("foo", "bar");
+        return Response.ok(hm).type(mt).build();
+    }
+
+    @Path("throwsexception")
+    @POST
+    public Response throwsException(@QueryParam("mt") String mt) {
+        return Response.ok("something").type(mt).build();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/test/MessageBodyWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/test/MessageBodyWriterTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/test/MessageBodyWriterTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriter/test/MessageBodyWriterTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,635 @@
+/*
+ * 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.messagebodywriter.test;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+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.cxf.helpers.IOUtils;
+
+import framework.defaults.test.FVTTestCase;
+
+public class MessageBodyWriterTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(MessageBodyWriterTest.class,
+            "jaxrs.tests.providers.messagebodywriter.server.Application");
+    }
+
+    /**
+     * Tests that if a {@link Response} object sets its media type, it is passed
+     * correctly to the {@link MessageBodyWriter}.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReturnContentTypeSetOnResponse() throws HttpException, IOException {
+        /*
+         * and maybe the content type isn't supported by the writer i.e.
+         * text/abcd and String
+         */
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/classtype?type=sourcecontenttype");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(500, getMethod.getStatusCode());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/classtype?type=source");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", getMethod
+                .getResponseBodyAsString());
+            assertEquals("text/xml", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/classtype?type=stringcontenttype");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("str:foobarcontenttype", getMethod.getResponseBodyAsString());
+            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+            assertEquals("21", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/classtype?type=string");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("str:foobar", getMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+            assertEquals("10", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+//
+//    public void testMediaTypeIntersection() {
+//        fail();
+//    }
+//
+//    public void testMediaTypeCanBePassedThroughWithoutAddedOrRemovedParameters() {
+//        fail();
+//    }
+//
+//    public void testProducesOnClassInsteadOfMethod() {
+//        fail();
+//    }
+
+    /**
+     * Tests that
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * if the Content-Length given is less than what is actually written, that
+     * the full content is still sent.
+     */
+    public void testContentLengthLessThanWritten() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/contentlength?mt=length/shorter");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            byte[] barr = IOUtils.readBytesFromStream(getMethod.getResponseBodyAsStream());
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], (byte) c);
+            }
+            assertEquals("length/shorter", getMethod.getResponseHeader("Content-Type").getValue());
+            assertEquals("90", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * if the Content-Length given is less than what is actually written, that
+     * the full content is still sent.
+     */
+    public void testContentLengthClassCorrect() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/contentlength?class=Vector");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("vector:HelloThere", getMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+            assertEquals("17", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * uses the correct generic type.
+     */
+    public void testContentLengthGenericEntityCorrect() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/contentlength?class=ListInteger");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("listinteger:12", getMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+            assertEquals("14", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * uses the correct generic type.
+     */
+    public void testContentLengthAnnotationsCorrect() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/contentlength?class=String");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("string:hello there", getMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+            assertEquals("18", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * if the Content-Length given is greater than what is actually written,
+     * that the full content is still sent.
+     */
+    public void testContentLengthGreaterThanWritten() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/contentlength?mt=length/longer");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            byte[] barr = IOUtils.readBytesFromStream(getMethod.getResponseBodyAsStream());
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], (byte) c);
+            }
+            assertEquals("length/longer", getMethod.getResponseHeader("Content-Type").getValue());
+            assertEquals("110", getMethod.getResponseHeader("Content-Length").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that
+     * {@link MessageBodyWriter#getSize(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * if the Content-Length given is -1 than the Content-Length is not sent.
+     */
+    public void testLessThanNegativeOneContentLength() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/contentlength");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            byte[] barr = IOUtils.readBytesFromStream(getMethod.getResponseBodyAsStream());
+            for (int c = 0; c < barr.length; ++c) {
+                assertEquals(barr[c], (byte) c);
+            }
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+            assertNull(getMethod.getResponseHeader("Content-Length"));
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * */
+    public void testGiveAcceptTypeWildcardGetConcreteTypeBack() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/concretetype");
+        getMethod.addRequestHeader("Accept", "*/*");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello there", getMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/concretetype");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello there", getMethod.getResponseBodyAsString());
+            assertEquals("application/octet-stream", getMethod.getResponseHeader("Content-Type")
+                .getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/concretetype");
+        getMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello there", getMethod.getResponseBodyAsString());
+            assertEquals("text/plain", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/concretetype");
+        getMethod.addRequestHeader("Accept", "text/xml");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello there", getMethod.getResponseBodyAsString());
+            assertEquals("text/xml", getMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+//
+//    public void testIsWritableReturnRealTypeInMethod() {
+//        fail();
+//    }
+//
+//    public void testIsWritableReturnGenericEntityTypeInMethod() {
+//        fail();
+//    }
+//
+//    public void testIsWritableReturnGenericTypeInResponse() {
+//        fail();
+//    }
+//
+//    public void testIsWritableReturnRealTypeInResponse() {
+//        fail();
+//    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method receives the correct class type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableUnexpectedClassType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/classtype?type=hashmap");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(500, getMethod.getStatusCode());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method receives the correct class type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableExpectedClassType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/classtype?type=deque");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("deque:str:foostr:bar", getMethod.getResponseBodyAsString());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method returns true when the expected argument type is specified on the
+     * generic type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableGenericEntityTypeCorrect() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/genericentity?query=setstring");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("set<string>:helloworld", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/genericentity?query=setinteger");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("set<integer>:12", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/nogenericentity?query=setstring");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("set:helloworld", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/nogenericentity?query=setinteger");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("set:12", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method returns false when an unexpected argument type is specified on the
+     * generic type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableGenericEntityTypeIncorrect() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/genericentity?query=setshort");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/nogenericentity?query=setshort");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("set:12", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is passed a single annotation.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableNotAnnotated() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/notannotated");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(500, getMethod.getStatusCode());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is passed a single annotation.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableAnnotated() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/annotated");
+        try {
+            client.executeMethod(getMethod);
+
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("getannotation:foobar", getMethod.getResponseBodyAsString());
+        } finally {
+            getMethod.releaseConnection();
+        }
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/annotated");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("postannotation:foobar", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is passed an incompatiable media type and does not return true.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableIncorrectMediaType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/mediatype?mt=custom/incorrect");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is passed the expected media type and reads the data.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableCorrectMediaType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/mediatype?mt=custom/correct");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("mediatype:foo=bar", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * When a {@link RuntimeException} is propagated back from
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * , verify that the exception is handled appropriately.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testWriterIsWritableThrowsRuntimeException() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/throwsexception?mt=throw/runtime");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+            + "/jaxrs/tests/providers/messagebodywriter/throwsexception?mt=throw/nullpointer");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * When a {@link WebApplicationException} is propagated back from
+     * {@link MessageBodyWriter#isWriteable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * , verify that the exception is handled appropriately.
+     *
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testWriterIsWritableThrowsWebApplicationException() throws HttpException,
+        IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+            getBaseURI()
+                + "/jaxrs/tests/providers/messagebodywriter/throwsexception?mt=throw/webapplicationexception");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(461, postMethod.getStatusCode());
+            assertEquals("throwiswritableexception", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+//
+//    public void testThrowingExceptionAfterContentFlushed() {
+//        fail();
+//    }
+}

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

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodywriterexceptions/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.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(ExceptionResource.class);
+        clazzes.add(IOExceptionMapper.class);
+        clazzes.add(MyMessageBodyWriterForStrings.class);
+        clazzes.add(NullPointerExceptionMapper.class);
+        return clazzes;
+    }
+
+}



Mime
View raw message