You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/07/16 22:03:08 UTC

svn commit: r794818 [2/2] - in /incubator/wink/trunk/wink-integration-test: wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ wink-server-integration-test/ wink-server-integration-test/wink-jaxrs-test-context/ wink-se...

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderMediaTypeSet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderMediaTypeSet.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderMediaTypeSet.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderMediaTypeSet.java Thu Jul 16 20:03:06 2009
@@ -29,17 +29,20 @@
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 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;
+import javax.ws.rs.ext.Providers;
 
 @Provider
 @Consumes("custom/type")
 public class MessageBodyReaderMediaTypeSet implements MessageBodyReader<Set> {
 
+    @Context
+    private Providers providers;
+
     public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
         if (MediaType.valueOf("custom/type").isCompatible(arg3)) {
             return true;
@@ -51,7 +54,12 @@
             throws IOException, WebApplicationException {
         String str = null;
         try {
-            str = IOUtils.toString(arg5);
+            MessageBodyReader<String> strReader =
+                providers.getMessageBodyReader(String.class,
+                                               String.class,
+                                               arg2,
+                                               MediaType.TEXT_PLAIN_TYPE);
+            str = strReader.readFrom(String.class, String.class, arg2, arg3, arg4, arg5);
         } catch (IOException e) {
             throw new WebApplicationException(e);
         }

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderThrowsExceptions.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderThrowsExceptions.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderThrowsExceptions.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/readers/MessageBodyReaderThrowsExceptions.java Thu Jul 16 20:03:06 2009
@@ -27,26 +27,38 @@
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 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;
+import javax.ws.rs.ext.Providers;
 
 @Provider
 @Consumes("custom/exception")
 public class MessageBodyReaderThrowsExceptions implements MessageBodyReader<Object> {
 
+    @Context
+    private Providers providers;
+
     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 {
+    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);
+            MessageBodyReader<String> strReader =
+                providers.getMessageBodyReader(String.class,
+                                               String.class,
+                                               arg2,
+                                               MediaType.TEXT_PLAIN_TYPE);
+            str = strReader.readFrom(String.class, String.class, arg2, arg3, arg4, arg5);
         } catch (IOException e) {
             throw new WebApplicationException(e);
         }

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/Application.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/Application.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/Application.java Thu Jul 16 20:03:06 2009
@@ -41,6 +41,7 @@
         objs.add(new MultiValuedMapResource());
         objs.add(new SourceResource());
         objs.add(new DataSourceResource());
+        objs.add(new DSResource());
         return objs;
     }
 

Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/DSResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/DSResource.java?rev=794818&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/DSResource.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/DSResource.java Thu Jul 16 20:03:06 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.jaxrs.test.providers.standard;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+
+@Path(value = "/dstest")
+public class DSResource {
+
+    @POST
+    public Response post(DataSource dataSource) {
+        Response resp = null;
+        try {
+            InputStream inputStream = dataSource.getInputStream();
+            byte[] inputBytes = new byte[inputStream.available()];
+            int next = inputStream.read();
+            int i = 0;
+            while (next != -1) {
+                if (i == inputBytes.length) {
+                    inputBytes = ArrayUtils.copyOf(inputBytes, 2 * i);
+                }
+                inputBytes[i] = (byte) next;
+                next = inputStream.read();
+                i++;
+            }
+            TestDataSource entity = new TestDataSource(inputBytes, dataSource
+                    .getName(), dataSource.getContentType());
+            ResponseBuilder rb = Response.ok();
+            rb.entity(entity);
+            resp = rb.build();
+        } catch (Exception e) {
+            ResponseBuilder rb = Response.serverError();
+            resp = rb.build();
+        }
+        return resp;
+    }
+
+    public class TestDataSource implements DataSource {
+
+        private byte[] inputBytes;
+
+        private String name;
+
+        private String contentType;
+
+        public TestDataSource(byte[] inputBytes, String name, String contentType) {
+            this.inputBytes = inputBytes;
+            this.name = name;
+            this.contentType = contentType;
+        }
+
+        public String getContentType() {
+            return contentType;
+        }
+
+        public InputStream getInputStream() throws IOException {
+            return new ByteArrayInputStream(inputBytes);
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public OutputStream getOutputStream() throws IOException {
+            return null;
+        }
+
+    }
+
+}

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java Thu Jul 16 20:03:06 2009
@@ -25,6 +25,7 @@
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 import javax.xml.transform.Source;
 
@@ -34,6 +35,7 @@
     private Source source = null;
 
     @GET
+    @Produces("text/xml")
     public Response getSource() {
         return Response.ok(source).build();
     }

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/subresource/CommentData.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/subresource/CommentData.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/subresource/CommentData.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/subresource/CommentData.java Thu Jul 16 20:03:06 2009
@@ -74,7 +74,7 @@
             commentError
                     .setErrorMessage("Please include a comment ID, a message, and your name.");
             Response resp = Response.status(Response.Status.BAD_REQUEST)
-                    .entity(commentError).build();
+                    .entity(commentError).type("application/xml").build();
             throw new WebApplicationException(resp);
         }
 

Copied: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/geronimo-web.xml (from r794817, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-context/pom.xml)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/geronimo-web.xml?p2=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/geronimo-web.xml&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-context/pom.xml&r1=794817&r2=794818&rev=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-context/pom.xml (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/geronimo-web.xml Thu Jul 16 20:03:06 2009
@@ -18,20 +18,18 @@
     under the License.
 -->
 
-<project>
-    <parent>
-        <artifactId>wink-server-integration-test</artifactId>
-        <groupId>org.apache.wink</groupId>
-        <version>0.1-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.apache.wink</groupId>
-    <artifactId>wink-jaxrs-test-context</artifactId>
-    <packaging>war</packaging>
-    <name>wink-jaxrs-test-context Maven Webapp</name>
-    <version>0.1-SNAPSHOT</version>
-    <url>http://maven.apache.org</url>
-    <build>
-        <finalName>wink-jaxrs-test-context</finalName>
-    </build>
-</project>
\ No newline at end of file
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" 
+         xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2" 
+         xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"> 
+ 
+    <sys:environment> 
+        <sys:moduleId> 
+            <sys:groupId>${groupId}</sys:groupId> 
+            <sys:artifactId>${artifactId}</sys:artifactId> 
+            <sys:version>${version}</sys:version> 
+            <sys:type>war</sys:type> 
+        </sys:moduleId> 
+    </sys:environment>  
+ 
+    <context-root>${artifactId}</context-root> 
+</web-app> 

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/web.xml?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/webapp/WEB-INF/web.xml Thu Jul 16 20:03:06 2009
@@ -138,7 +138,19 @@
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
-
+    <servlet>
+        <servlet-name>SimpleContestResolver</servlet-name>
+        <servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.jaxrs.test.providers.contextresolver.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_simplecontextresolver</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
     <servlet-mapping>
         <servlet-name>MessageBodyReaders</servlet-name>
         <url-pattern>/readers/*</url-pattern>
@@ -175,4 +187,9 @@
         <servlet-name>SubresourceExceptions</servlet-name>
         <url-pattern>/subresourceexceptions/*</url-pattern>
     </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>SimpleContestResolver</servlet-name>
+        <url-pattern>/simplecontextresolver/*</url-pattern>
+    </servlet-mapping>
+    
 </web-app>

Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/ContextTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/ContextTest.java?rev=794818&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/ContextTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/ContextTest.java Thu Jul 16 20:03:06 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.jaxrs.test.providers.contextresolver;
+
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.jaxrs.test.providers.contextresolver.jaxb.ObjectFactory;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class ContextTest extends TestCase {
+
+    final private static String USER_URI = getBaseURI() + "/simplecontextresolver/user";
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI();
+    }
+
+    public void testUserContextProvider() throws Exception {
+        HttpClient httpClient = new HttpClient();
+
+        User user = new User();
+        user.setUserName("joedoe@example.com");
+        JAXBElement<User> element =
+            new JAXBElement<User>(new QName("http://jaxb.context.tests", "user"), User.class, user);
+        JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
+        StringWriter sw = new StringWriter();
+        Marshaller m = context.createMarshaller();
+        m.marshal(element, sw);
+        PostMethod postMethod = new PostMethod(USER_URI);
+        try {
+            postMethod.setRequestEntity(new ByteArrayRequestEntity(sw.toString().getBytes(),
+                                                                   "text/xml"));
+            httpClient.executeMethod(postMethod);
+            assertEquals(204, postMethod.getStatusCode());
+        } finally {
+            postMethod.releaseConnection();
+        }
+
+        GetMethod getMethod = new GetMethod(USER_URI + "/joedoe@example.com");
+        try {
+            httpClient.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            Unmarshaller u = context.createUnmarshaller();
+            element =
+                u.unmarshal(new StreamSource(getMethod.getResponseBodyAsStream()), User.class);
+            assertNotNull(element);
+            user = element.getValue();
+            assertNotNull(user);
+            assertEquals("joedoe@example.com", user.getUserName());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+}

Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/DepartmentTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/DepartmentTest.java?rev=794818&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/DepartmentTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/contextresolver/DepartmentTest.java Thu Jul 16 20:03:06 2009
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.jaxrs.test.providers.contextresolver;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class DepartmentTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/simplecontextresolver/departments";
+    }
+
+    /**
+     * This will drive several different requests that interact with the
+     * Departments resource class.
+     */
+    public void testDepartmentsResourceJAXB() throws Exception {
+        PostMethod postMethod = null;
+        GetMethod getAllMethod = null;
+        GetMethod getOneMethod = null;
+        HeadMethod headMethod = null;
+        DeleteMethod deleteMethod = null;
+        try {
+
+            // make sure everything is clear before testing
+            DepartmentDatabase.clearEntries();
+
+            // create a new Department
+            Department newDepartment = new Department();
+            newDepartment.setDepartmentId("1");
+            newDepartment.setDepartmentName("Marketing");
+            JAXBContext context =
+                JAXBContext.newInstance(new Class<?>[] {Department.class,
+                    DepartmentListWrapper.class});
+            Marshaller marshaller = context.createMarshaller();
+            StringWriter sw = new StringWriter();
+            marshaller.marshal(newDepartment, sw);
+            HttpClient client = new HttpClient();
+            postMethod = new PostMethod(getBaseURI());
+            RequestEntity reqEntity =
+                new ByteArrayRequestEntity(sw.toString().getBytes(), "text/xml");
+            postMethod.setRequestEntity(reqEntity);
+            client.executeMethod(postMethod);
+
+            newDepartment = new Department();
+            newDepartment.setDepartmentId("2");
+            newDepartment.setDepartmentName("Sales");
+            sw = new StringWriter();
+            marshaller.marshal(newDepartment, sw);
+            client = new HttpClient();
+            postMethod = new PostMethod(getBaseURI());
+            reqEntity = new ByteArrayRequestEntity(sw.toString().getBytes(), "text/xml");
+            postMethod.setRequestEntity(reqEntity);
+            client.executeMethod(postMethod);
+
+            // now let's get the list of Departments that we just created
+            // (should be 2)
+            client = new HttpClient();
+            getAllMethod = new GetMethod(getBaseURI());
+            client.executeMethod(getAllMethod);
+            byte[] bytes = getAllMethod.getResponseBody();
+            assertNotNull(bytes);
+            InputStream bais = new ByteArrayInputStream(bytes);
+            Unmarshaller unmarshaller = context.createUnmarshaller();
+            Object obj = unmarshaller.unmarshal(bais);
+            assertTrue(obj instanceof DepartmentListWrapper);
+            DepartmentListWrapper wrapper = (DepartmentListWrapper)obj;
+            List<Department> dptList = wrapper.getDepartmentList();
+            assertNotNull(dptList);
+            assertEquals(2, dptList.size());
+
+            // now get a specific Department that was created
+            client = new HttpClient();
+            getOneMethod = new GetMethod(getBaseURI() + "/1");
+            client.executeMethod(getOneMethod);
+            bytes = getOneMethod.getResponseBody();
+            assertNotNull(bytes);
+            bais = new ByteArrayInputStream(bytes);
+            obj = unmarshaller.unmarshal(bais);
+            assertTrue(obj instanceof Department);
+            Department dept = (Department)obj;
+            assertEquals("1", dept.getDepartmentId());
+            assertEquals("Marketing", dept.getDepartmentName());
+
+            // let's send a Head request for both an existent and non-existent
+            // resource
+            // we are testing to see if header values being set in the resource
+            // implementation
+            // are sent back appropriately
+            client = new HttpClient();
+            headMethod = new HeadMethod(getBaseURI() + "/3");
+            client.executeMethod(headMethod);
+            assertNotNull(headMethod.getResponseHeaders());
+            Header header = headMethod.getResponseHeader("unresolved-id");
+            assertNotNull(header);
+            assertEquals("3", header.getValue());
+            headMethod.releaseConnection();
+
+            // now the resource that should exist
+            headMethod = new HeadMethod(getBaseURI() + "/1");
+            client.executeMethod(headMethod);
+            assertNotNull(headMethod.getResponseHeaders());
+            header = headMethod.getResponseHeader("resolved-id");
+            assertNotNull(header);
+            assertEquals("1", header.getValue());
+
+            deleteMethod = new DeleteMethod(getBaseURI() + "/1");
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+
+            deleteMethod = new DeleteMethod(getBaseURI() + "/2");
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            if (postMethod != null) {
+                postMethod.releaseConnection();
+            }
+            if (getAllMethod != null) {
+                getAllMethod.releaseConnection();
+            }
+            if (getOneMethod != null) {
+                getOneMethod.releaseConnection();
+            }
+            if (headMethod != null) {
+                headMethod.releaseConnection();
+            }
+            if (deleteMethod != null) {
+                deleteMethod.releaseConnection();
+            }
+        }
+    }
+}

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSBytesArrayTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSBytesArrayTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSBytesArrayTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSBytesArrayTest.java Thu Jul 16 20:03:06 2009
@@ -117,8 +117,10 @@
             for (int c = 0; c < barr.length; ++c) {
                 assertEquals(barr[c], receivedBArr[c]);
             }
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type")
-                .getValue());
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertEquals(barr.length, Integer.valueOf(getMethod.getResponseHeader("Content-Length")
                 .getValue()).intValue());
         } finally {

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSDataSourceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSDataSourceTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSDataSourceTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSDataSourceTest.java Thu Jul 16 20:03:06 2009
@@ -25,14 +25,20 @@
 import java.io.InputStream;
 import java.util.Random;
 
+import javax.activation.DataSource;
+import javax.ws.rs.core.MediaType;
+
 import junit.framework.TestCase;
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.wink.common.internal.providers.entity.DataSourceProvider;
 import org.apache.wink.test.integration.ServerEnvironmentInfo;
 
 public class JAXRSDataSourceTest extends TestCase {
@@ -118,8 +124,11 @@
             for (int c = 0; c < barr.length; ++c) {
                 assertEquals(barr[c], receivedBArr[c]);
             }
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type")
-                .getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertNull((getMethod.getResponseHeader("Content-Length") == null) ? "" : getMethod
                 .getResponseHeader("Content-Length").getValue(), getMethod
                 .getResponseHeader("Content-Length"));
@@ -203,4 +212,39 @@
         }
     }
 
+
+    /**
+     * Verify that we can send a DataSource and receive a DataSource. The 'POST'
+     * method on the resource we are calling is a simple echo.
+     *
+     */
+    public void testPOSTDataSource() throws Exception {
+        PostMethod postMethod = null;
+        try {
+            postMethod = new PostMethod(getBaseURI() + "/dstest");
+            String input = "This is some test input";
+            RequestEntity requestEntity = new ByteArrayRequestEntity(input
+                    .getBytes(), "application/datasource");
+            postMethod.setRequestEntity(requestEntity);
+            HttpClient client = new HttpClient();
+            client.executeMethod(postMethod);
+
+            // just use our provider to read the response
+            DataSourceProvider provider = new DataSourceProvider();
+            DataSource returnedData = provider.readFrom(DataSource.class, null,
+                    null, new MediaType("application", "datasource"), null,
+                    postMethod.getResponseBodyAsStream());
+            assertNotNull(returnedData);
+            assertNotNull(returnedData.getInputStream());
+            byte[] responseBytes = new byte[input.getBytes().length];
+            returnedData.getInputStream().read(responseBytes);
+            assertNotNull(responseBytes);
+            String response = new String(responseBytes);
+            assertEquals("This is some test input", response);
+        } finally {
+            if (postMethod != null) {
+                postMethod.releaseConnection();
+            }
+        }
+    }
 }

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSInputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSInputStreamTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSInputStreamTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSInputStreamTest.java Thu Jul 16 20:03:06 2009
@@ -124,9 +124,11 @@
             for (int c = 0; c < barr.length; ++c) {
                 assertEquals(barr[c], receivedBArr[c]);
             }
-            assertEquals("application/xml", getMethod
-                    .getResponseHeader("Content-Type").getValue());
 
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             Header contentLengthHeader = getMethod
                     .getResponseHeader("Content-Length");
             assertNull(contentLengthHeader == null ? "null"

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSReaderTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSReaderTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSReaderTest.java Thu Jul 16 20:03:06 2009
@@ -45,17 +45,15 @@
 
     /**
      * Tests posting to a Reader parameter.
-     *
+     * 
      * @throws HttpException
      * @throws IOException
      */
     public void testPostReader() throws HttpException, IOException {
         HttpClient client = new HttpClient();
 
-        PostMethod postMethod = new PostMethod(getBaseURI()
-                + "/providers/standard/reader");
-        postMethod.setRequestEntity(new StringRequestEntity("abcd",
-                "text/plain", "UTF-8"));
+        PostMethod postMethod = new PostMethod(getBaseURI() + "/providers/standard/reader");
+        postMethod.setRequestEntity(new StringRequestEntity("abcd", "text/plain", "UTF-8"));
         postMethod.addRequestHeader("Accept", "text/plain");
         try {
             client.executeMethod(postMethod);
@@ -80,12 +78,10 @@
             String str = new String(carr);
 
             assertEquals("abcd", str);
-            assertEquals("text/plain", postMethod.getResponseHeader(
-                    "Content-Type").getValue());
-            Header contentLengthHeader = postMethod
-                    .getResponseHeader("Content-Length");
-            assertNull(contentLengthHeader == null ? "null"
-                    : contentLengthHeader.getValue(), contentLengthHeader);
+            assertEquals("text/plain", postMethod.getResponseHeader("Content-Type").getValue());
+            Header contentLengthHeader = postMethod.getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null" : contentLengthHeader.getValue(),
+                       contentLengthHeader);
         } finally {
             postMethod.releaseConnection();
         }
@@ -93,17 +89,15 @@
 
     /**
      * Tests putting and then getting a Reader.
-     *
+     * 
      * @throws HttpException
      * @throws IOException
      */
     public void testPutReader() throws HttpException, IOException {
         HttpClient client = new HttpClient();
 
-        PutMethod putMethod = new PutMethod(getBaseURI()
-                + "/providers/standard/reader");
-        putMethod.setRequestEntity(new StringRequestEntity("wxyz",
-                "char/array", "UTF-8"));
+        PutMethod putMethod = new PutMethod(getBaseURI() + "/providers/standard/reader");
+        putMethod.setRequestEntity(new StringRequestEntity("wxyz", "char/array", "UTF-8"));
         try {
             client.executeMethod(putMethod);
             assertEquals(204, putMethod.getStatusCode());
@@ -111,8 +105,7 @@
             putMethod.releaseConnection();
         }
 
-        GetMethod getMethod = new GetMethod(getBaseURI()
-                + "/providers/standard/reader");
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/providers/standard/reader");
         try {
             client.executeMethod(getMethod);
             assertEquals(200, getMethod.getStatusCode());
@@ -135,32 +128,30 @@
             String str = new String(carr);
 
             assertEquals("wxyz", str);
-            assertEquals("application/xml", getMethod
-                    .getResponseHeader("Content-Type").getValue());
 
-            Header contentLengthHeader = getMethod
-                    .getResponseHeader("Content-Length");
-            assertNull(contentLengthHeader == null ? "null"
-                    : contentLengthHeader.getValue(), contentLengthHeader);
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+
+            Header contentLengthHeader = getMethod.getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null" : contentLengthHeader.getValue(),
+                       contentLengthHeader);
         } finally {
             getMethod.releaseConnection();
         }
     }
 
     /**
-     *
-     *
      * @throws HttpException
      * @throws IOException
      */
-    public void testWithRequestAcceptHeaderWillReturnRequestedContentType()
-            throws HttpException, IOException {
+    public void testWithRequestAcceptHeaderWillReturnRequestedContentType() throws HttpException,
+        IOException {
         HttpClient client = new HttpClient();
 
-        PutMethod putMethod = new PutMethod(getBaseURI()
-                + "/providers/standard/reader");
-        putMethod.setRequestEntity(new StringRequestEntity("wxyz",
-                "char/array", "UTF-8"));
+        PutMethod putMethod = new PutMethod(getBaseURI() + "/providers/standard/reader");
+        putMethod.setRequestEntity(new StringRequestEntity("wxyz", "char/array", "UTF-8"));
         try {
             client.executeMethod(putMethod);
             assertEquals(204, putMethod.getStatusCode());
@@ -168,8 +159,7 @@
             putMethod.releaseConnection();
         }
 
-        GetMethod getMethod = new GetMethod(getBaseURI()
-                + "/providers/standard/reader");
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/providers/standard/reader");
         getMethod.addRequestHeader("Accept", "mytype/subtype");
         try {
             client.executeMethod(getMethod);
@@ -193,37 +183,34 @@
             String str = new String(carr);
 
             assertEquals("wxyz", str);
-            assertEquals("mytype/subtype", getMethod.getResponseHeader(
-                    "Content-Type").getValue());
+            assertEquals("mytype/subtype", getMethod.getResponseHeader("Content-Type").getValue());
 
-            Header contentLengthHeader = getMethod
-                    .getResponseHeader("Content-Length");
-            assertNull(contentLengthHeader == null ? "null"
-                    : contentLengthHeader.getValue(), contentLengthHeader);
+            Header contentLengthHeader = getMethod.getResponseHeader("Content-Length");
+            assertNull(contentLengthHeader == null ? "null" : contentLengthHeader.getValue(),
+                       contentLengthHeader);
         } finally {
             getMethod.releaseConnection();
         }
     }
 
     /**
-     * Tests a resource method invoked with a BufferedReader as a
-     * parameter. This should fail with a 415 since the reader has no way to
-     * necessarily wrap it to the type.
-     *
+     * Tests a resource method invoked with a BufferedReader as a parameter.
+     * This should fail with a 415 since the reader has no way to necessarily
+     * wrap it to the type.
+     * 
      * @throws HttpException
      * @throws IOException
      */
-    public void testInputStreamImplementation() throws HttpException,
-            IOException {
+    public void testInputStreamImplementation() throws HttpException, IOException {
         HttpClient client = new HttpClient();
 
-        PostMethod postMethod = new PostMethod(getBaseURI()
-                + "/providers/standard/reader/subclasses/shouldfail");
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/providers/standard/reader/subclasses/shouldfail");
         byte[] barr = new byte[1000];
         Random r = new Random();
         r.nextBytes(barr);
-        postMethod.setRequestEntity(new InputStreamRequestEntity(
-                new ByteArrayInputStream(barr), "any/type"));
+        postMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(barr),
+                                                                 "any/type"));
         try {
             client.executeMethod(postMethod);
             assertEquals(415, postMethod.getStatusCode());

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java Thu Jul 16 20:03:06 2009
@@ -204,8 +204,11 @@
             assertEquals(
                     "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message><user>user1</user><password>user1pwd</password></message>",
                     str);
-            assertEquals("application/xml", getMethod
-                    .getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             Header contentLengthHeader = getMethod
                     .getResponseHeader("Content-Length");
             assertNull(contentLengthHeader == null ? "null"

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSStreamingOutputTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSStreamingOutputTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSStreamingOutputTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSStreamingOutputTest.java Thu Jul 16 20:03:06 2009
@@ -124,9 +124,11 @@
             for (int c = 0; c < barr.length; ++c) {
                 assertEquals(barr[c], receivedBArr[c]);
             }
-            assertEquals("application/xml", getMethod
-                    .getResponseHeader("Content-Type").getValue());
 
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             Header contentLengthHeader = getMethod
                     .getResponseHeader("Content-Length");
             assertNull(contentLengthHeader == null ? "null"

Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writers/JAXRSMessageBodyWritersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writers/JAXRSMessageBodyWritersTest.java?rev=794818&r1=794817&r2=794818&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writers/JAXRSMessageBodyWritersTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writers/JAXRSMessageBodyWritersTest.java Thu Jul 16 20:03:06 2009
@@ -19,6 +19,7 @@
 package org.apache.wink.jaxrs.test.providers.writers;
 
 import java.io.IOException;
+import java.io.InputStream;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
@@ -30,7 +31,6 @@
 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 org.apache.wink.test.integration.ServerEnvironmentInfo;
 
 public class JAXRSMessageBodyWritersTest extends TestCase {
@@ -86,7 +86,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("str:foobarcontenttype", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertEquals("21", getMethod.getResponseHeader("Content-Length").getValue());
         } finally {
             getMethod.releaseConnection();
@@ -100,7 +104,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("str:foobar", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertEquals("10", getMethod.getResponseHeader("Content-Length").getValue());
         } finally {
             getMethod.releaseConnection();
@@ -137,9 +145,10 @@
             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);
+            InputStream is = getMethod.getResponseBodyAsStream();
+            int read = is.read();
+            for (int c = 0; read != -1; ++c, read = is.read()) {
+                assertEquals(c % 256, read);
             }
             assertEquals("length/shorter", getMethod.getResponseHeader("Content-Type").getValue());
             assertEquals("99990", getMethod.getResponseHeader("Content-Length").getValue());
@@ -165,7 +174,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("vector:HelloThere", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertEquals("17", getMethod.getResponseHeader("Content-Length").getValue());
         } finally {
             getMethod.releaseConnection();
@@ -188,7 +201,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("listinteger:12", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertEquals("14", getMethod.getResponseHeader("Content-Length").getValue());
         } finally {
             getMethod.releaseConnection();
@@ -211,8 +228,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("string:hello there", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type")
-                .getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertEquals("18", getMethod.getResponseHeader("Content-Length").getValue());
         } finally {
             getMethod.releaseConnection();
@@ -235,9 +255,11 @@
             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);
+
+            InputStream is = getMethod.getResponseBodyAsStream();
+            int read = is.read();
+            for (int c = 0; read != -1; ++c, read = is.read()) {
+                assertEquals(c % 256, read);
             }
             assertEquals("length/longer", getMethod.getResponseHeader("Content-Type").getValue());
             assertEquals("100010", getMethod.getResponseHeader("Content-Length").getValue());
@@ -260,11 +282,16 @@
             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);
+            InputStream is = getMethod.getResponseBodyAsStream();
+            int read = is.read();
+            for (int c = 0; read != -1; ++c, read = is.read()) {
+                assertEquals(c % 256, read);
             }
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
             assertNull((getMethod.getResponseHeader("Content-Length") == null) ? "" : getMethod
                 .getResponseHeader("Content-Length").getValue(), getMethod
                 .getResponseHeader("Content-Length"));
@@ -286,7 +313,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("Hello there", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
         } finally {
             getMethod.releaseConnection();
         }
@@ -298,7 +329,11 @@
 
             assertEquals(200, getMethod.getStatusCode());
             assertEquals("Hello there", getMethod.getResponseBodyAsString());
-            assertEquals("application/xml", getMethod.getResponseHeader("Content-Type").getValue());
+
+            String contentType =
+                (getMethod.getResponseHeader("Content-Type") == null) ? null : getMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
         } finally {
             getMethod.releaseConnection();
         }
@@ -643,7 +678,7 @@
 
             assertEquals("throwiswritableexception", postMethod.getResponseBodyAsString());
             assertEquals(461, postMethod.getStatusCode());
-            
+
         } finally {
             postMethod.releaseConnection();
         }