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 [19/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/messagebodyreader/server/MessageBodyReaderGenericType.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericType.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericType.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderGenericType.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,127 @@
+/*
+ * 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.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+@Consumes("custom/generic")
+public class MessageBodyReaderGenericType implements MessageBodyReader<Object> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (List.class.isAssignableFrom(arg0)) {
+            if (arg1 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg1;
+                Type rawType = pt.getRawType();
+                if ((rawType instanceof Class)
+                        && (List.class.isAssignableFrom((Class) rawType))) {
+                    Type[] genericTypeArguments = pt.getActualTypeArguments();
+                    if (genericTypeArguments.length == 1) {
+                        Class argType = (Class) genericTypeArguments[0];
+                        if (Integer.class.isAssignableFrom(argType)
+                                || String.class.isAssignableFrom(argType)) {
+                            return true;
+                        }
+                    }
+                }
+            } else if (arg1 instanceof Class) {
+                return true;
+            }
+        }
+
+        if (arg1 instanceof Class) {
+            if (Integer.class.isAssignableFrom((Class) arg1)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+            throws IOException, WebApplicationException {
+        if (List.class.isAssignableFrom(arg0)) {
+            if (arg1 instanceof ParameterizedType) {
+                ParameterizedType pt = (ParameterizedType) arg1;
+                Type rawType = pt.getRawType();
+                if ((rawType instanceof Class)
+                        && (List.class.isAssignableFrom((Class) rawType))) {
+                    Type[] genericTypeArguments = pt.getActualTypeArguments();
+                    if (genericTypeArguments.length == 1) {
+                        Class argType = (Class) genericTypeArguments[0];
+                        if (Integer.class.isAssignableFrom(argType)) {
+                            String str = IOUtils.toString(arg5);
+                            String[] splitlines = str.split("\r\n");
+                            List<Integer> ret = new ArrayList<Integer>();
+                            for (String s : splitlines) {
+                                ret.add(Integer.valueOf(s));
+                            }
+                            return ret;
+                        } else if (String.class.isAssignableFrom(argType)) {
+                            String str = IOUtils.toString(arg5);
+                            String[] splitlines = str.split("\r\n");
+                            List<String> ret = new ArrayList<String>();
+                            for (String s : splitlines) {
+                                ret.add("str:" + s);
+                            }
+                            return ret;
+                        }
+                    }
+                }
+            } else if (arg1 instanceof Class) {
+                String str = IOUtils.toString(arg5);
+                String[] splitlines = str.split("\r\n");
+                List<Object> ret = new ArrayList<Object>();
+                for (String s : splitlines) {
+                    ret.add("obj:" + s);
+                }
+                return ret;
+            }
+        }
+
+        if (arg1 instanceof Class) {
+            if (Integer.class.isAssignableFrom((Class) arg1)) {
+                String str = IOUtils.toString(arg5);
+                String[] splitlines = str.split("\r\n");
+                int sum = 0;
+                for (String s : splitlines) {
+                    sum += Integer.valueOf(s).intValue();
+                }
+                return Integer.valueOf(sum);
+            }
+        }
+        return null;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsRuntimeException.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsRuntimeException.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsRuntimeException.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsRuntimeException.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.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Consumes("custom/runtimeexception")
+public class MessageBodyReaderIsReadableThrowsRuntimeException implements MessageBodyReader<Object> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        throw new NullPointerException();
+    }
+
+    public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+            throws IOException, WebApplicationException {
+        return null;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsWebAppException.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsWebAppException.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsWebAppException.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderIsReadableThrowsWebAppException.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.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Consumes("custom/webapplicationexception")
+public class MessageBodyReaderIsReadableThrowsWebAppException implements MessageBodyReader<Object> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        throw new WebApplicationException(478);
+    }
+
+    public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+            throws IOException, WebApplicationException {
+        return null;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderMediaTypeSet.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderMediaTypeSet.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderMediaTypeSet.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderMediaTypeSet.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.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+@Consumes("custom/type")
+public class MessageBodyReaderMediaTypeSet implements MessageBodyReader<Set> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (MediaType.valueOf("custom/type").isCompatible(arg3)) {
+            return true;
+        }
+        return false;
+    }
+
+    public Set readFrom(Class<Set> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+            throws IOException, WebApplicationException {
+        String str = null;
+        try {
+            str = IOUtils.toString(arg5);
+        } catch (IOException e) {
+            throw new WebApplicationException(e);
+        }
+        return new HashSet<String>(Arrays.asList(str.split("\r\n")));
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderReadFromDifferent.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderReadFromDifferent.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderReadFromDifferent.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderReadFromDifferent.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.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Consumes( { "custom/long", "custom/int", "custom/byte", "custom/short" })
+public class MessageBodyReaderReadFromDifferent implements MessageBodyReader<Number> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (Integer.class.isAssignableFrom(arg0)
+                || Long.class.isAssignableFrom(arg0)
+                || Byte.class.isAssignableFrom(arg0)
+                || Short.class.isAssignableFrom(arg0)) {
+            return true;
+        }
+        return false;
+    }
+
+    public Number readFrom(Class<Number> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+            throws IOException, WebApplicationException {
+        if (arg0.isAssignableFrom(Long.class)) {
+            return Long.valueOf(Long.MAX_VALUE);
+        }
+        if (arg0.isAssignableFrom(Integer.class)) {
+            return Integer.valueOf(Integer.MAX_VALUE);
+        }
+
+        for (Annotation ann : arg2) {
+            if (CustomAnnotation.class.equals(ann.annotationType())) {
+                return Short.valueOf(Short.MAX_VALUE);
+            }
+        }
+
+        if (arg3.isCompatible(MediaType.valueOf("custom/byte"))) {
+            return Byte.valueOf(Byte.MAX_VALUE);
+        }
+
+        return null;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderThrowsExceptions.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderThrowsExceptions.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderThrowsExceptions.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MessageBodyReaderThrowsExceptions.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,77 @@
+/*
+ * 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.messagebodyreader.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+@Consumes("custom/exception")
+public class MessageBodyReaderThrowsExceptions implements MessageBodyReader<Object> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        return true;
+    }
+
+    public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+            throws IOException, WebApplicationException {
+        String str = null;
+        try {
+            str = IOUtils.toString(arg5);
+        } catch (IOException e) {
+            throw new WebApplicationException(e);
+        }
+
+        if ("ioexception".equals(str)) {
+            throw new IOException("Error");
+        } else if ("webapplicationexception".equals(str)) {
+            throw new WebApplicationException(477);
+        } else if (str.startsWith("closeinput")) {
+            arg5.close();
+        } else if ("thrownull".equals(str)) {
+            throw new NullPointerException();
+        }
+        StringBuilder sb = new StringBuilder(str);
+        /*
+         * leave this with weird capitalization. header keys should not be case
+         * sensitive.
+         */
+        List<String> headerValues = arg4.get("myCuStomHeaderToAppend");
+        if (headerValues != null) {
+            for (String value : headerValues) {
+                sb.append(value);
+            }
+        }
+        return sb.toString();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MyReaderAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MyReaderAnnotation.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MyReaderAnnotation.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/MyReaderAnnotation.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.messagebodyreader.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 })
+public @interface MyReaderAnnotation {
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/ReaderResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/ReaderResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/ReaderResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/server/ReaderResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,222 @@
+/*
+ * 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.messagebodyreader.server;
+
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+@Path("jaxrs/tests/providers/messagebodyreader/reader")
+public class ReaderResource {
+
+    private static int counter = 0;
+
+    @Path("requestcontenttype")
+    @POST
+    @Consumes(MediaType.WILDCARD)
+    public String postReaderNoGenericEntityWildcard(byte[] barr) {
+        return "hello world";
+    }
+
+    @Path("requestcontenttype")
+    @POST
+    @Consumes(MediaType.APPLICATION_OCTET_STREAM)
+    public String postReaderNoGenericEntityOctetStream(byte[] barr) {
+        return "invoked octet-stream method";
+    }
+
+    @Path("unexpectedclasstype")
+    @POST
+    public String postReaderNoGenericEntity(HashMap<String, String> entity) {
+        return "hello";
+    }
+
+    @Path("classtype")
+    @POST
+    public String postReaderNoGenericEntity(Deque<String> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : entity) {
+            sb.append("echo:" + s);
+        }
+        return sb.toString();
+    }
+
+    @Path("nogenericentity")
+    @POST
+    public String postReaderNoGenericEntity(String str) {
+        return "echo:" + str;
+    }
+
+    @Path("genericentityempty")
+    @POST
+    public String postReaderGenericEntityEmpty(Queue entity) {
+        StringBuilder sb = new StringBuilder();
+        for (Object s : entity) {
+            sb.append(s.toString() + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("genericentityqueuestring")
+    @POST
+    public String postReaderGenericEntityListString(Queue<String> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : entity) {
+            sb.append(s + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("genericentityqueueobject")
+    @POST
+    public String postReaderGenericEntityListObject(Queue<Object> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (Object o : entity) {
+            sb.append(o + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("notannotatedentity")
+    @POST
+    public String postResponseReaderNotAnnotated(List<String> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : entity) {
+            sb.append(s + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("annotatedentity")
+    @POST
+    public String postResponseReaderAnnotated(@MyReaderAnnotation List<String> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : entity) {
+            sb.append(s + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("multipleannotatedentity")
+    @POST
+    public String postResponseReaderAnnotatedMultipleTimes(@CustomAnnotation @MyReaderAnnotation List<String> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : entity) {
+            sb.append(s + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("mediatype")
+    @POST
+    public String postReaderMediaType(Set<String> entity) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : entity) {
+            sb.append(s + " there");
+        }
+        return sb.toString();
+    }
+
+    @Path("readfrom")
+    @POST
+    public String postReaderReadFrom(String str) {
+        if ("clear".equals(str)) {
+            counter = -1;
+        }
+        ++counter;
+        return counter + "postReaderReadFrom:" + str;
+    }
+
+    @Path("readdifferentlyinteger")
+    @POST
+    public String postReaderReadFromClass(Integer value) {
+        return "" + value;
+    }
+
+    @Path("readdifferentlylong")
+    @POST
+    public String postReaderReadFromClass(Long value) {
+        return "" + value;
+    }
+
+    @Path("readdifferentlyshort")
+    @POST
+    public String postReaderReadFromAnnotation(@CustomAnnotation Short value) {
+        return "" + value;
+    }
+
+    @Path("readdifferentlyshortnoannotation")
+    @POST
+    public String postReaderReadFromNoAnnotation(Short value) {
+        return "" + value;
+    }
+
+    @Path("readdifferentlybytemediatype")
+    @POST
+    public String postReaderReadFromMediaType(Byte value) {
+        return "" + value;
+    }
+
+    @Path("readdifferentlygenericlist")
+    @POST
+    public String postReaderReadFromGenericType(List value) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("listnonspecified:");
+        for (Object o : value) {
+            sb.append(o.toString());
+        }
+        return sb.toString();
+    }
+
+    @Path("readdifferentlygenericliststring")
+    @POST
+    public String postReaderReadFromGenericTypeListString(List<String> value) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("liststring:");
+        for (String s : value) {
+            sb.append(s);
+        }
+        return sb.toString();
+    }
+
+    @Path("readdifferentlygenericlistinteger")
+    @POST
+    public String postReaderReadFromGenericTypeListInteger(List<Integer> value) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("listinteger:");
+        for (Integer i : value) {
+            sb.append(i.toString());
+        }
+        return sb.toString();
+    }
+
+    @Path("readdifferentlygenericinteger")
+    @POST
+    public String postReaderReadFromGenericTypeInteger(Integer value) {
+        return "integer:" + value;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/test/MessageBodyReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/test/MessageBodyReaderTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/test/MessageBodyReaderTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreader/test/MessageBodyReaderTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,1137 @@
+/*
+ * 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.messagebodyreader.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.MessageBodyReader;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class MessageBodyReaderTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(MessageBodyReaderTest.class,
+                "jaxrs.tests.providers.messagebodyreader.server.Application");
+    }
+
+    /**
+     * Tests that an improperly formatted request content type is handled.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderImproperlyFormattedContentType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/requestcontenttype");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(500, postMethod.getStatusCode());
+            assertLogContainsException("java.lang.IllegalArgumentException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an empty request content type is handled.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderNoContentType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/requestcontenttype");
+        byte[] requestContent = { 0, 0, 0 };
+        postMethod.setRequestEntity(new InputStreamRequestEntity(
+                new ByteArrayInputStream(requestContent)));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            /*
+             * should only invoke hello world
+             */
+            assertEquals("hello world", postMethod.getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableUnexpectedClassType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/unexpectedclasstype");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableExpectedClassType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/classtype");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("echo:Helloecho:World", postMethod
+                    .getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method works when there is no generic entity type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderIsReadableNoGenericEntityType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/nogenericentity");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("echo:Hello\r\nWorld\r\n", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method works when there is no argument type specified on the generic
+     * type.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderIsReadableGenericEntityEmptyType()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/genericentityempty");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableGenericEntityTypeCorrect()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/genericentityqueuestring");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("Hello thereWorld there", postMethod
+                    .getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableGenericEntityTypeIncorrect()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/genericentityqueueobject");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method still works without an annotated entity parameter.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderIsReadableEntityParameterNotAnnotated()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/notannotatedentity");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableEntityParameterAnnotated()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/annotatedentity");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertEquals("Hello thereWorld there", postMethod
+                    .getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)}
+     * method is passed multiple annotations.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderIsReadableEntityParameterAnnotatedMultiple()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/multipleannotatedentity");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        postMethod.addRequestHeader("Accept", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("text/plain", postMethod.getResponseHeader(
+                    "Content-Type").getValue());
+            assertEquals("Hello thereWorld there", postMethod
+                    .getResponseBodyAsString());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableIncorrectMediaType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/mediatype");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "text/plain", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(415, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that the
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableCorrectMediaType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/mediatype");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "Hello\r\nWorld\r\n", "custom/type", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertTrue(response, response.contains("Hello there"));
+            assertTrue(response, response.contains("World there"));
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * When a {@link RuntimeException} is propagated back from
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableThrowsRuntimeException()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("Hello World",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:Hello World", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("thrownull",
+                "custom/runtimeexception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertLogContainsException(response,
+                    "javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("hello world",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:hello world", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * When a {@link WebApplicationException} is propagated back from
+     * {@link MessageBodyReader#isReadable(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 testReaderIsReadableThrowsWebApplicationException()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("Hello World",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:Hello World", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("thrownull",
+                "custom/webapplicationexception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(478, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("hello world",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:hello world", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, InputStream)}
+     * can return a different object based on the class argument.
+     *
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testReaderReadFromClassType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlylong");
+        postMethod.setRequestEntity(new StringRequestEntity("empty",
+                "custom/long", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("" + Long.MAX_VALUE, response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlyinteger");
+        postMethod.setRequestEntity(new StringRequestEntity("empty",
+                "custom/int", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("" + Integer.MAX_VALUE, response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, InputStream)}
+     * can return a different object based on the generic type argument.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderReadFromGenericType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlygenericlist");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10",
+                "custom/generic", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals(
+                    "listnonspecified:obj:1obj:2obj:3obj:4obj:5obj:6obj:7obj:8obj:9obj:10",
+                    response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlygenericliststring");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10",
+                "custom/generic", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals(
+                    "liststring:str:1str:2str:3str:4str:5str:6str:7str:8str:9str:10",
+                    response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlygenericlistinteger");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10",
+                "custom/generic", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("listinteger:12345678910", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlygenericinteger");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10",
+                "custom/generic", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("integer:55", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, InputStream)}
+     * can return a different object based on the annotations argument.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderReadFromAnnotationType() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlyshort");
+        postMethod.setRequestEntity(new StringRequestEntity("empty",
+                "custom/short", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("" + Short.MAX_VALUE, response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlyshortnoannotation");
+        postMethod.setRequestEntity(new StringRequestEntity("empty",
+                "custom/short", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("null", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, InputStream)}
+     * can return a different object based on the media type argument.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderReadFromMediaType() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlybytemediatype");
+        postMethod.setRequestEntity(new StringRequestEntity("empty",
+                "custom/int", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("null", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(
+                getBaseURI()
+                        + "/jaxrs/tests/providers/messagebodyreader/reader/readdifferentlybytemediatype");
+        postMethod.setRequestEntity(new StringRequestEntity("empty",
+                "custom/byte", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("" + Byte.MAX_VALUE, response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a
+     * {@link MessageBodyReader#readFrom(Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, InputStream)}
+     * can use the HttpHeaders.
+     *
+     * @throws IOException
+     */
+    public void testReaderReadFromGetHeader() throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("Hello World!",
+                "custom/exception", "UTF-8"));
+        postMethod.addRequestHeader("myCustomHeaderToappend", "abcdefgh");
+        postMethod.addRequestHeader("MYCUSTOMHEADERTOAPPEND", "wxyz");
+        postMethod.addRequestHeader("mycustomheadertoappend", "12345");
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:Hello World!abcdefghwxyz12345",
+                    response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that calling {@link InputStream#close()} in 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 will not cause errors.
+     *
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testReaderReadFromCloseInputStream() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("closeinput",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:closeinput", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that throwing a {@link RuntimeException} in 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 will propagate the exception appropriately.
+     *
+     * @throws IOException
+     * @throws HttpException
+     */
+    public void testReaderReadFromThrowsRuntimeException()
+            throws HttpException, IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("Hello World",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:Hello World", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("thrownull",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertLogContainsException(response,
+                    "javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("hello world",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:hello world", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that an IOException triggered by a
+     * {@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)}
+     * will propagate appropriately.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderReadFromThrowsIOException() throws HttpException,
+            IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("Hello World",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:Hello World", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("ioexception",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(500, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertLogContainsException(response,
+                    "javax.servlet.ServletException");
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("hello world",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:hello world", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a WebApplicationException triggered by a
+     * {@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)}
+     * will propagate appropriately.
+     *
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testReaderReadFromThrowsWebApplicationException()
+            throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("Hello World",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:Hello World", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("clear",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("0postReaderReadFrom:clear", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity(
+                "webapplicationexception", "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(477, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        postMethod = new PostMethod(getBaseURI()
+                + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
+        postMethod.setRequestEntity(new StringRequestEntity("hello world",
+                "custom/exception", "UTF-8"));
+        try {
+            client.executeMethod(postMethod);
+
+            assertEquals(200, postMethod.getStatusCode());
+
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("1postReaderReadFrom:hello world", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}

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

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/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.messagebodyreaderexceptions.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(MyMessageBodyReader.class);
+        clazzes.add(NullPointerExceptionMapper.class);
+        return clazzes;
+    }
+
+}

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

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/IOExceptionMapper.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/IOExceptionMapper.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/IOExceptionMapper.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/IOExceptionMapper.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.server;
+
+import java.io.IOException;
+
+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()).build();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/MyMessageBodyReader.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/MyMessageBodyReader.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/MyMessageBodyReader.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/providers/messagebodyreaderexceptions/server/MyMessageBodyReader.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,66 @@
+/*
+ * 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.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+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.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class MyMessageBodyReader implements MessageBodyReader<Object> {
+
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+        if (arg3.isCompatible(new MediaType("readable", "throwruntime"))) {
+            throw new RuntimeException();
+        } else if (arg3.isCompatible(new MediaType("readable", "thrownull"))) {
+            throw new NullPointerException();
+        } else if (arg3.isCompatible(new MediaType("readable", "throwwebapplicationexception"))) {
+            throw new WebApplicationException(Response.status(499).entity("can not read type")
+                .build());
+        }
+
+        return arg0.equals(String.class);
+    }
+
+    public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3,
+        MultivaluedMap<String, String> arg4, InputStream arg5) throws IOException,
+        WebApplicationException {
+        if (arg3.isCompatible(new MediaType("readfrom", "thrownull"))) {
+            throw new NullPointerException();
+        } else if (arg3.isCompatible(new MediaType("readfrom", "throwwebapplicationexception"))) {
+            throw new WebApplicationException(Response.status(498).entity("can not read type in readfrom")
+                .build());
+        } else if (arg3.isCompatible(new MediaType("readfrom", "throwioexception"))) {
+            throw new IOException();
+        } else if (arg3.isCompatible(new MediaType("readfrom", "throwruntime"))) {
+            throw new RuntimeException();
+        }
+        return "read";
+    }
+
+}

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



Mime
View raw message