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/08/07 05:10:46 UTC

svn commit: r801869 [18/21] - in /incubator/wink/trunk: wink-integration-test/ wink-integration-test/wink-server-integration-test-support/ wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ wink-i...

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/transferencoding/TransferEncodingApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/transferencoding/TransferEncodingApplication.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/transferencoding/TransferEncodingApplication.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/transferencoding/TransferEncodingApplication.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.transferencoding;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class TransferEncodingApplication extends Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(ChunkedMirror.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/Application.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/Application.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/Application.java Fri Aug  7 03:10:22 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 org.apache.wink.itest.version;
+
+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(TaxForm.class);
+        return clazzes;
+    }
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/TaxForm.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/TaxForm.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/TaxForm.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/java/org/apache/wink/itest/version/TaxForm.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,108 @@
+/*
+ * 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.itest.version;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+@Path(value = "/taxform")
+public class TaxForm {
+
+    @Context
+    private HttpHeaders    httpHeaders;
+
+    @Context
+    private ServletContext context;
+
+    @GET
+    public InputStream getWithAcceptHeader(@QueryParam(value = "form") String form)
+        throws FileNotFoundException {
+        List<MediaType> mediaTypes = httpHeaders.getAcceptableMediaTypes();
+        if (mediaTypes == null || mediaTypes.isEmpty()) {
+            throw new IllegalArgumentException("Accept values not found");
+        }
+        MediaType mediaType = mediaTypes.get(0);
+        String subtype = mediaType.getSubtype();
+        String version = subtype.substring(subtype.indexOf("+") + 1);
+        String formPath = form + "_" + version;
+        String path =
+            "tests" + java.io.File.separator
+                + "test-resources"
+                + java.io.File.separator
+                + formPath
+                + ".xml";
+        InputStream stream = context.getResourceAsStream("/WEB-INF/classes/" + path);
+        if (stream != null) {
+            return stream;
+        }
+        return new FileInputStream(new File(path));
+    }
+
+    @GET
+    @Path(value = "/{form}")
+    public InputStream getWithQueryString(@PathParam(value = "form") String form,
+                                          @QueryParam(value = "version") String version)
+        throws FileNotFoundException {
+        String formPath = form + "_" + version;
+        String path =
+            "tests" + java.io.File.separator
+                + "test-resources"
+                + java.io.File.separator
+                + formPath
+                + ".xml";
+        InputStream stream = context.getResourceAsStream("/WEB-INF/classes/" + path);
+        if (stream != null) {
+            return stream;
+        }
+        return new FileInputStream(new File(path));
+    }
+
+    @GET
+    @Path(value = "/{form}/{version}")
+    public InputStream getWithPathInfo(@PathParam(value = "form") String form,
+                                       @PathParam(value = "version") String version)
+        throws FileNotFoundException {
+        String formPath = form + "_" + version;
+        String path =
+            "tests" + java.io.File.separator
+                + "test-resources"
+                + java.io.File.separator
+                + formPath
+                + ".xml";
+        InputStream stream = context.getResourceAsStream("/WEB-INF/classes/" + path);
+        if (stream != null) {
+            return stream;
+        }
+        return new FileInputStream(new File(path));
+    }
+
+}

Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/geronimo-web.xml (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/webapp/WEB-INF/geronimo-web.xml)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/geronimo-web.xml?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/geronimo-web.xml&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/webapp/WEB-INF/geronimo-web.xml&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
    (empty)

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/web.xml?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/web.xml (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/WEB-INF/web.xml Fri Aug  7 03:10:22 2009
@@ -0,0 +1,264 @@
+<?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.
+-->
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+    <display-name>Archetype Created Web Application</display-name>
+    <servlet>
+        <servlet-name>CustomHTTPMethodAnnotations</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.methodannotations.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_customannotations</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>Lifecycles</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.lifecycles.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_lifecycles</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>ReturnTypes</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.returntype.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_returntypes</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>Exceptional</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.exceptions.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_exceptions</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>Sequence</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.sequence.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_sequence</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>LargeEntity</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.largeentity.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_largeentity</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>Headers</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.headers.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_headers</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>NoFindMethods</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.nofindmethods.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_nofindmethods</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>Cache</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.cache.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_cache</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>ContentNegotiation</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.contentnegotiation.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_negotiation</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>AddressBook</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.addressbook.AddressApplication</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_addressbook</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>VersionTests</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.version.Application</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_version</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>ContentEncoding</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.contentencoding.ContentEncodingApplication</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_contentencoding</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>TransferEncoding</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.transferencoding.TransferEncodingApplication</param-value>
+        </init-param>
+        <init-param>
+            <param-name>requestProcessorAttribute</param-name>
+            <param-value>requestProcessorAttribute_transferencoding</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>CustomHTTPMethodAnnotations</servlet-name>
+        <url-pattern>/customannotations/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>Lifecycles</servlet-name>
+        <url-pattern>/lifecycles/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>ReturnTypes</servlet-name>
+        <url-pattern>/returntypes/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>Exceptional</servlet-name>
+        <url-pattern>/exceptional/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>Sequence</servlet-name>
+        <url-pattern>/sequence/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>LargeEntity</servlet-name>
+        <url-pattern>/largeentity/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>Headers</servlet-name>
+        <url-pattern>/headers/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>NoFindMethods</servlet-name>
+        <url-pattern>/nofindmethods/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>Cache</servlet-name>
+        <url-pattern>/cache/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>ContentNegotiation</servlet-name>
+        <url-pattern>/contentNegotiation/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>AddressBook</servlet-name>
+        <url-pattern>/addressBook/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>VersionTests</servlet-name>
+        <url-pattern>/version/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>ContentEncoding</servlet-name>
+        <url-pattern>/contentencoding/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>TransferEncoding</servlet-name>
+        <url-pattern>/transferencoding/*</url-pattern>
+    </servlet-mapping>
+</web-app>

Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/index.jsp (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/webapp/index.jsp)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/index.jsp?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/main/webapp/index.jsp&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/webapp/index.jsp&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
    (empty)

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/addressbook/StringTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/addressbook/StringTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/addressbook/StringTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/addressbook/StringTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,220 @@
+/*
+ * 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.itest.addressbook;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+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.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.wink.itest.addressbook.Address;
+import org.apache.wink.itest.addressbook.AddressBook;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * These tests drive calls to a REST resource that is deployed on our test
+ * framework server. The resources being tested by this class exchange data via
+ * String objects.
+ */
+public class StringTest extends TestCase {
+
+    final private static String BASE_URI =
+                                             ServerEnvironmentInfo.getBaseURI() + "/addressBook/"
+                                                 + "/unittests/addresses";
+
+    @Override
+    public void setUp() {
+        /*
+         * clear the database entries
+         */
+        HttpClient client = new HttpClient();
+        HttpMethod method = null;
+        try {
+            method = new PostMethod(BASE_URI + "/clear");
+            client.executeMethod(method);
+            assertEquals(204, method.getStatusCode());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
+            }
+        }
+    }
+
+    /**
+     * This will drive a GET request with no input parameters
+     */
+    public void testGetNoParams() {
+
+        HttpMethod method = null;
+        try {
+            HttpClient client = new HttpClient();
+            method = new GetMethod(BASE_URI);
+            client.executeMethod(method);
+            String responseBody = method.getResponseBodyAsString();
+            Address addr = AddressBook.defaultAddress;
+            assertTrue(responseBody.contains(addr.getEntryName()));
+            assertTrue(responseBody.contains(addr.getStreetAddress()));
+            assertTrue(responseBody.contains(addr.getZipCode()));
+            assertTrue(responseBody.contains(addr.getCity()));
+            assertTrue(responseBody.contains(addr.getCountry()));
+            assertTrue(responseBody.contains(addr.getState()));
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
+            }
+        }
+    }
+
+    /**
+     * This will drive a POST request with parameters from the query string
+     */
+    public void testPostWithQueryParams() {
+        HttpMethod method = null;
+        HttpMethod getMethod = null;
+        try {
+
+            // make sure everything is clear before testing
+            HttpClient client = new HttpClient();
+            method = new PostMethod(BASE_URI);
+            method
+                .setQueryString("entryName=newAddress&streetAddress=1234+Any+Street&city=" + "AnyTown&zipCode=90210&state=TX&country=US");
+            client.executeMethod(method);
+
+            // now let's see if the address we just created is available
+            getMethod = new GetMethod(BASE_URI + "/newAddress");
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            String responseBody = getMethod.getResponseBodyAsString();
+            assertNotNull(responseBody);
+            assertTrue(responseBody, responseBody.contains("newAddress"));
+            assertTrue(responseBody, responseBody.contains("1234 Any Street"));
+            assertTrue(responseBody, responseBody.contains("AnyTown"));
+            assertTrue(responseBody, responseBody.contains("90210"));
+            assertTrue(responseBody, responseBody.contains("TX"));
+            assertTrue(responseBody, responseBody.contains("US"));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
+            }
+            if (getMethod != null) {
+                getMethod.releaseConnection();
+            }
+        }
+    }
+
+    /**
+     * This will drive a POST, GET, UPDATE, and DELETE on the
+     * AddressBookResource
+     */
+    public void testAddressBookResource() {
+        PostMethod method = null;
+        GetMethod getMethod = null;
+        PutMethod put = null;
+        DeleteMethod deleteMethod = null;
+        try {
+
+            // make sure everything is clear before testing
+            HttpClient client = new HttpClient();
+            method = new PostMethod(BASE_URI + "/fromBody");
+            String input = "tempAddress&1234 Any Street&AnyTown&90210&TX&US";
+            RequestEntity entity = new ByteArrayRequestEntity(input.getBytes(), "text/xml");
+            method.setRequestEntity(entity);
+            client.executeMethod(method);
+
+            // now let's see if the address we just created is available
+            getMethod = new GetMethod(BASE_URI + "/tempAddress");
+            client.executeMethod(getMethod);
+            String responseBody = getMethod.getResponseBodyAsString();
+            getMethod.releaseConnection();
+            assertNotNull(responseBody);
+            assertTrue(responseBody, responseBody.contains("tempAddress"));
+            assertTrue(responseBody, responseBody.contains("1234 Any Street"));
+            assertTrue(responseBody, responseBody.contains("AnyTown"));
+            assertTrue(responseBody, responseBody.contains("90210"));
+            assertTrue(responseBody, responseBody.contains("TX"));
+            assertTrue(responseBody, responseBody.contains("US"));
+
+            // let's update the state
+            String query =
+                "entryName=tempAddress&streetAddress=1234+Any+Street&city=" + "AnyTown&zipCode=90210&state=AL&country=US";
+            client = new HttpClient();
+            put = new PutMethod(BASE_URI);
+            put.setQueryString(query);
+            client.executeMethod(put);
+
+            // make sure the state has been updated
+            client = new HttpClient();
+            client.executeMethod(getMethod);
+            responseBody = getMethod.getResponseBodyAsString();
+            assertNotNull(responseBody);
+            assertTrue(responseBody.contains("tempAddress"));
+            assertFalse(responseBody.contains("TX"));
+            assertTrue(responseBody.contains("AL"));
+
+            // now let's delete the address
+            client = new HttpClient();
+            deleteMethod = new DeleteMethod(BASE_URI + "/tempAddress");
+            client.executeMethod(deleteMethod);
+            assertEquals(204, deleteMethod.getStatusCode());
+
+            // now try to get the address
+            client = new HttpClient();
+            client.executeMethod(getMethod);
+            assertEquals(404, getMethod.getStatusCode());
+            responseBody = getMethod.getResponseBodyAsString();
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, getMethod
+                .getResponseBodyAsString());
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
+            }
+            if (getMethod != null) {
+                getMethod.releaseConnection();
+            }
+            if (put != null) {
+                put.releaseConnection();
+            }
+            if (deleteMethod != null) {
+                deleteMethod.releaseConnection();
+            }
+        }
+    }
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/ClientTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/ClientTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/ClientTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/ClientTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,169 @@
+/*
+ * 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.itest.cachetest;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import javax.ws.rs.core.Response;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.itest.cache.NewsStory;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class ClientTest extends TestCase {
+
+    final private static String     NEWS_BASE_URI =
+                                                      ServerEnvironmentInfo.getBaseURI() + "/cache/news";
+
+    private static final DateFormat formatter     =
+                                                      new SimpleDateFormat(
+                                                                           "EEE, dd MMM yyyy HH:mm:ss zzz",
+                                                                           Locale.ENGLISH);
+    static {
+        formatter.setLenient(false);
+        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
+    }
+
+    @Override
+    public void setUp() {
+        /*
+         * clear the database entries
+         */
+        HttpClient client = new HttpClient();
+        HttpMethod method = null;
+        try {
+            System.out.println(NEWS_BASE_URI + "/clear");
+            method = new PostMethod(NEWS_BASE_URI + "/clear");
+            client.executeMethod(method);
+            assertEquals(204, method.getStatusCode());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
+            }
+        }
+    }
+
+    /**
+     * This test will demonstrate various usages of the ETag and 'If-Match'
+     * headers. It will show how different scenarios result in different HTTP
+     * status codes and different response entities.
+     */
+    public void testNewsResourceWithETag() throws Exception {
+        // always start with a fresh set of resources for testing purposes
+        // first create the resource
+        NewsStory story = new NewsStory();
+        story.setContent("This is a breaking news story");
+        story.setTitle("Local Hero Saves Kid");
+        NewsHttpClient client = new NewsHttpClient(NEWS_BASE_URI, null);
+        Response response = client.addNewsStory(story);
+        assertNotNull(response);
+        String location = (String)response.getMetadata().getFirst("Location");
+        String etag = (String)response.getMetadata().getFirst("ETag");
+
+        // now send a request with an 'If-Match' with a matching value,
+        // we should get back a 304
+        Map<String, String> reqHdrs = new HashMap<String, String>();
+        reqHdrs.put("If-Match", etag);
+        client = new NewsHttpClient(NEWS_BASE_URI, reqHdrs);
+        location = location.startsWith("/") ? location.substring(1) : location;
+        response = client.getNewsStory("Local%20Hero%20Saves%20Kid");
+        assertNotNull(response);
+        assertEquals("Expected 200 not returned", response.getStatus(), 200);
+
+        // update the content of the story
+        client = new NewsHttpClient(NEWS_BASE_URI, null);
+        String newContent = "A local man rescued a kid from a burning building";
+        story.setContent(newContent);
+        response = client.updateNewsStory(story);
+        String updatedETag = (String)response.getMetadata().getFirst("ETag");
+        assertNotNull(updatedETag);
+
+        // now try to get with the old ETag value, we should get a 412
+        // back indicating our precondition failed
+        client = new NewsHttpClient(NEWS_BASE_URI, reqHdrs);
+        location = location.startsWith("/") ? location.substring(1) : location;
+        response = client.getNewsStory("Local%20Hero%20Saves%20Kid");
+        assertNotNull(response);
+        assertNull(response.getEntity());
+        assertEquals("Expected 412 not returned", response.getStatus(), 412);
+
+        // now ensure that using the ETag we got back on the PUT results
+        // in a 304 status
+        reqHdrs.put("If-Match", updatedETag);
+        client = new NewsHttpClient(NEWS_BASE_URI, reqHdrs);
+        location = location.startsWith("/") ? location.substring(1) : location;
+        response = client.getNewsStory("Local%20Hero%20Saves%20Kid");
+        assertNotNull(response);
+        assertEquals("Expected 200 not returned", response.getStatus(), 200);
+    }
+
+    /**
+     * This test will demonstrate various usages of the Last-Modified header. It
+     * will show how different scenarios result in different HTTP status codes
+     * and different response entities.
+     */
+    public void testNewsResourceWithLastModified() throws Exception {
+
+        // first create the resource
+        NewsStory story = new NewsStory();
+        story.setContent("This is a breaking news story");
+        story.setTitle("Local Hero Saves Kid");
+        NewsHttpClient client = new NewsHttpClient(NEWS_BASE_URI, null);
+        Response response = client.addNewsStory(story);
+        assertNotNull(response);
+        String lastModified = (String)response.getMetadata().getFirst("Last-Modified");
+
+        Date date = formatter.parse(lastModified);
+
+        Map<String, String> reqHdrs = new HashMap<String, String>();
+        reqHdrs.put("If-Modified-Since", lastModified);
+        client = new NewsHttpClient(NEWS_BASE_URI, reqHdrs);
+        response = client.getNewsStory("Local%20Hero%20Saves%20Kid");
+        assertNotNull(response);
+        assertEquals("Expected 304 not returned", 304, response.getStatus());
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.YEAR, 2006);
+
+        lastModified = formatter.format(calendar.getTime());
+        reqHdrs.put("If-Modified-Since", lastModified);
+        client = new NewsHttpClient(NEWS_BASE_URI, reqHdrs);
+        response = client.getNewsStory("Local%20Hero%20Saves%20Kid");
+        assertNotNull(response);
+        story = (NewsStory)response.getEntity();
+        assertNotNull(story);
+    }
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsHttpClient.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsHttpClient.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsHttpClient.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsHttpClient.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,165 @@
+/*
+ * 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.itest.cachetest;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.wink.itest.cache.NewsStory;
+
+public class NewsHttpClient implements NewsResource {
+
+    private String   baseURI;
+
+    private Header[] requestHeaders;
+
+    public NewsHttpClient(String baseURI, Map<String, String> reqHdrs) {
+        this.baseURI = baseURI;
+        requestHeaders = createRequestHeaders(reqHdrs);
+    }
+
+    public Response addNewsStory(NewsStory story) throws Exception {
+        PostMethod post = new PostMethod(this.baseURI);
+        try {
+            HttpClient client = new HttpClient();
+            setRequestHeaders(post);
+            JAXBContext context = JAXBContext.newInstance(NewsStory.class);
+            StringWriter sw = new StringWriter();
+            context.createMarshaller().marshal(story, sw);
+            RequestEntity entity = new ByteArrayRequestEntity(sw.toString().getBytes(), "text/xml");
+            post.setRequestEntity(entity);
+            int status = client.executeMethod(post);
+            Map<String, List<Object>> headers = getResponseHeaders(post.getResponseHeaders());
+            Response resp = Response.status(status).build();
+            resp.getMetadata().putAll(headers);
+            return resp;
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (post != null) {
+                post.releaseConnection();
+            }
+        }
+    }
+
+    public Response updateNewsStory(NewsStory story) throws Exception {
+        PutMethod put = new PutMethod(this.baseURI);
+        try {
+            HttpClient client = new HttpClient();
+            setRequestHeaders(put);
+            JAXBContext context = JAXBContext.newInstance(NewsStory.class);
+            StringWriter sw = new StringWriter();
+            context.createMarshaller().marshal(story, sw);
+            RequestEntity entity = new ByteArrayRequestEntity(sw.toString().getBytes(), "text/xml");
+            put.setRequestEntity(entity);
+            int status = client.executeMethod(put);
+            Map<String, List<Object>> headers = getResponseHeaders(put.getResponseHeaders());
+            Response resp = Response.status(status).build();
+            resp.getMetadata().putAll(headers);
+            return resp;
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (put != null) {
+                put.releaseConnection();
+            }
+        }
+    }
+
+    public Response getNewsStory(String title) throws Exception {
+        GetMethod get = new GetMethod(this.baseURI + "/" + title);
+        try {
+            HttpClient client = new HttpClient();
+            setRequestHeaders(get);
+            int status = client.executeMethod(get);
+            InputStream is = get.getResponseBodyAsStream();
+            NewsStory newsStory = null;
+            long cl = get.getResponseContentLength();
+            if (is != null && cl != 0) {
+                JAXBContext context = JAXBContext.newInstance(NewsStory.class);
+                newsStory = (NewsStory)context.createUnmarshaller().unmarshal(is);
+            }
+            Map<String, List<Object>> headers = getResponseHeaders(get.getResponseHeaders());
+            Response resp = Response.status(status).entity(newsStory).build();
+            resp.getMetadata().putAll(headers);
+            return resp;
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (get != null) {
+                get.releaseConnection();
+            }
+        }
+    }
+
+    Map<String, List<Object>> getResponseHeaders(Header[] headers) {
+        Map<String, List<Object>> respHeaders = new HashMap<String, List<Object>>();
+        if (headers != null) {
+            for (Header header : headers) {
+                String headerName = header.getName();
+                List<Object> values = new ArrayList<Object>();
+                values.add(header.getValue());
+                respHeaders.put(headerName, values);
+            }
+        }
+        return respHeaders;
+    }
+
+    Header[] createRequestHeaders(Map<String, String> reqHdrs) {
+        Header[] headers = null;
+        if (reqHdrs != null) {
+            headers = new Header[reqHdrs.size()];
+            int i = 0;
+            Set<Entry<String, String>> entries = reqHdrs.entrySet();
+            for (Entry<String, String> entry : entries) {
+                Header header = new Header(entry.getKey(), entry.getValue());
+                headers[i] = header;
+                i++;
+            }
+        }
+        return headers;
+    }
+
+    void setRequestHeaders(HttpMethod method) {
+        if (requestHeaders != null) {
+            for (Header header : requestHeaders) {
+                method.addRequestHeader(header);
+            }
+        }
+    }
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsResource.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsResource.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/cachetest/NewsResource.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.itest.cachetest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import org.apache.wink.itest.cache.NewsStory;
+
+@Path("/news")
+public interface NewsResource {
+
+    @GET
+    @Produces(value = "text/xml")
+    @Path(value = "/{title}")
+    public Response getNewsStory(@PathParam(value = "title") String title) throws Exception;
+
+    @POST
+    public Response addNewsStory(NewsStory story) throws Exception;
+
+    @PUT
+    public Response updateNewsStory(NewsStory story) throws Exception;
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentencoding/ContentEncodingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentencoding/ContentEncodingTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentencoding/ContentEncodingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentencoding/ContentEncodingTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,167 @@
+/*
+ * 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.itest.contentencoding;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.ChunkedOutputStream;
+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.PostMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class ContentEncodingTest extends TestCase {
+
+    private HttpClient          client;
+
+    final private static String BASE_URI = ServerEnvironmentInfo.getBaseURI() + "/contentencoding";
+
+    @Override
+    public void setUp() {
+        client = new HttpClient();
+    }
+
+    /**
+     * Tests sending in small bits of gzip encoded content.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testSendSmallGzipContentEncoded() throws HttpException, IOException {
+        PostMethod postMethod = new PostMethod(BASE_URI + "/bigbook");
+
+        postMethod.addRequestHeader("Accept", "text/plain");
+        postMethod.setRequestHeader("Content-Encoding", "gzip");
+        postMethod.setRequestHeader("Transfer-Encoding", "chunked");
+        // postMethod.setRequestHeader("Content-)
+        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+        originalContent.write("Hello world".getBytes("UTF-8"));
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ChunkedOutputStream chunkedOut = new ChunkedOutputStream(baos);
+        GZIPOutputStream gzipOut = new GZIPOutputStream(chunkedOut);
+
+        originalContent.writeTo(gzipOut);
+
+        gzipOut.finish();
+        chunkedOut.finish();
+        byte[] content = baos.toByteArray();
+
+        postMethod
+            .setRequestEntity(new ByteArrayRequestEntity(content, "text/plain; charset=utf-8"));
+        try {
+            int result = client.executeMethod(postMethod);
+            assertEquals(200, result);
+            String response = postMethod.getResponseBodyAsString();
+            assertEquals("Hello world" + "helloworld", response);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests sending in small bits of gzip encoded content.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testSendLargeGzipContentEncoded() throws HttpException, IOException {
+        PostMethod postMethod = new PostMethod(BASE_URI + "/bigbook/mirror");
+        postMethod.setContentChunked(true);
+        postMethod.addRequestHeader("Accept", "text/plain");
+        postMethod.setRequestHeader("Content-Encoding", "gzip");
+        // postMethod.setRequestHeader("Content-)
+        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+        for (int c = 0; c < 5000000; ++c) {
+            originalContent.write(c);
+        }
+
+        /*
+         * gzip the contents
+         */
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        GZIPOutputStream gzipOut = new GZIPOutputStream(baos);
+        originalContent.writeTo(gzipOut);
+        gzipOut.finish();
+        byte[] content = baos.toByteArray();
+
+        postMethod
+            .setRequestEntity(new ByteArrayRequestEntity(content, "text/plain; charset=utf-8"));
+        try {
+            int result = client.executeMethod(postMethod);
+            assertEquals(200, result);
+            InputStream responseStream = postMethod.getResponseBodyAsStream();
+            for (int c = 0; c < 5000000; ++c) {
+                assertEquals(c % 256, responseStream.read());
+            }
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests sending in small bits of gzip encoded content.
+     * 
+     * @throws HttpException
+     * @throws IOException
+     */
+    public void testSendLargeGzipContentEncodedAndReceiveContentEncoded() throws HttpException,
+        IOException {
+        PostMethod postMethod = new PostMethod(BASE_URI + "/bigbook/mirror");
+        postMethod.setContentChunked(true);
+        postMethod.setRequestHeader("Accept", "text/plain");
+        postMethod.setRequestHeader("Accept-Encoding", "gzip");
+        postMethod.setRequestHeader("Content-Encoding", "gzip");
+        ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
+        for (int c = 0; c < 5000000; ++c) {
+            originalContent.write(c);
+        }
+
+        /*
+         * gzip the contents
+         */
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        GZIPOutputStream gzipOut = new GZIPOutputStream(baos);
+        originalContent.writeTo(gzipOut);
+        gzipOut.finish();
+        byte[] content = baos.toByteArray();
+
+        postMethod
+            .setRequestEntity(new ByteArrayRequestEntity(content, "text/plain; charset=utf-8"));
+        try {
+            int result = client.executeMethod(postMethod);
+            assertEquals(200, result);
+            InputStream responseStream = new GZIPInputStream(postMethod.getResponseBodyAsStream());
+            for (int c = 0; c < 5000000; ++c) {
+                assertEquals(c % 256, responseStream.read());
+            }
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/contentnegotiation/ContentNegotiationClientTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,131 @@
+/**
+ * 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.itest.contentnegotiation;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+/**
+ * These tests drive calls to a REST resource that is deployed on our test
+ * framework server. The resources being tested by this class exchange data via
+ * String objects.
+ */
+public class ContentNegotiationClientTest extends TestCase {
+
+    HttpClient                  httpclient = new HttpClient();
+
+    final private static String BASE_URI   =
+                                               ServerEnvironmentInfo.getBaseURI() + "/contentNegotiation/customerservice";
+
+    public void testGetReturningXML() {
+        // Sent HTTP GET request to query customer info, expect XML
+        System.out.println("Sent HTTP GET request to query customer info, expect XML");
+        GetMethod get = new GetMethod(BASE_URI + "/customers/123");
+        get.addRequestHeader("Accept", "application/xml");
+
+        try {
+            int result = httpclient.executeMethod(get);
+            System.out.println("Response status code: " + result);
+            System.out.println("Response body: ");
+            String responseBody = get.getResponseBodyAsString();
+            System.out.println(responseBody);
+            assertTrue(result == 200);
+            assertTrue(responseBody.contains("<Customer><id>123</id><name>John</name></Customer>"));
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+            fail(ioe.getMessage());
+        } finally {
+            get.releaseConnection();
+        }
+
+    }
+
+    public void testGetReturningJSON() throws IOException, JSONException {
+        // Sent HTTP GET request to query customer info, expect JSON.
+        System.out.println("\n");
+        System.out.println("Sent HTTP GET request to query customer info, expect JSON");
+        GetMethod get = new GetMethod(BASE_URI + "/customers/123");
+        get.addRequestHeader("Accept", "application/json");
+        httpclient = new HttpClient();
+
+        try {
+            int result = httpclient.executeMethod(get);
+            System.out.println("Response status code: " + result);
+            System.out.println("Response body: ");
+            String responseBody = get.getResponseBodyAsString();
+            System.out.println(responseBody);
+            assertEquals(200, result);
+            JSONTokener tokenizer = new JSONTokener(responseBody);
+            JSONObject jObj = new JSONObject(tokenizer);
+            assertEquals("John", jObj.get("name"));
+            assertEquals(123L, jObj.getLong("id"));
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+            fail(ioe.getMessage());
+        } finally {
+            get.releaseConnection();
+        }
+    }
+
+    public void testGetForCustomerInfoReturningJSON() throws JSONException {
+
+        // Sent HTTP GET request to query customer info, expect JSON.
+        System.out.println("\n");
+        System.out.println("Sent HTTP GET request to query customer info, expect JSON");
+        // The default behavior without setting Accept header explicitly is
+        // depending on your client.
+        // In the case of HTTP Client, the Accept header will be absent. The CXF
+        // server will treat this
+        // as "*/*", JSON format is returned
+        GetMethod get = new GetMethod(BASE_URI + "/customers/123");
+        httpclient = new HttpClient();
+
+        try {
+            int result = httpclient.executeMethod(get);
+            System.out.println("Response status code: " + result);
+            System.out.println("Response body: ");
+            String responseBody = get.getResponseBodyAsString();
+            System.out.println(responseBody);
+            assertEquals(200, result);
+            JSONTokener tokenizer = new JSONTokener(responseBody);
+            JSONObject jObj = new JSONObject(tokenizer);
+
+            assertEquals("John", jObj.get("name"));
+            assertEquals(123L, jObj.getLong("id"));
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+            fail(ioe.getMessage());
+        } finally {
+            get.releaseConnection();
+        }
+
+        System.out.println("\n");
+        System.out.println("Client Invoking is succeeded!");
+
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ExceptionsWhileTargettingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ExceptionsWhileTargettingTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ExceptionsWhileTargettingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/ExceptionsWhileTargettingTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,214 @@
+/*
+ * 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.itest.exceptions;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class ExceptionsWhileTargettingTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
+    }
+
+    /**
+     * Tests that a 404 error is thrown when no resource can be found for a
+     * path.
+     * 
+     * @throws Exception
+     */
+    public void test404WhenNoResourceExists() throws Exception {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/doesnotexist");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(404, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, getMethod
+                .getResponseBodyAsString());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a 405 error is thrown when no subresource can be found for a
+     * path.
+     * 
+     * @throws Exception
+     */
+    public void test405WhenNoMethodExistsOnExistingResource() throws Exception {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/existingresource/");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(405, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(405, getMethod
+                .getResponseBodyAsString());
+
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a 404 error is thrown when no subresource can be found for a
+     * path.
+     * 
+     * @throws Exception
+     */
+    public void test404WhenNoSubResourceExists() throws Exception {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/existingresource/noexistsub");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(404, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, getMethod
+                .getResponseBodyAsString());
+
+            getMethod.setURI(new URI(getBaseURI() + "/targeting/resourcewithmethod", true));
+            client.executeMethod(getMethod);
+            assertEquals(200, getMethod.getStatusCode());
+            assertEquals("Hello", getMethod.getResponseBodyAsString());
+
+            getMethod.setURI(new URI(getBaseURI() + "/targeting/resourcewithmethod/noexistsub",
+                                     true));
+            client.executeMethod(getMethod);
+            assertEquals(404, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, getMethod
+                .getResponseBodyAsString());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a 405 error is thrown when other http methods exist on a
+     * resource but not the one looking for.
+     * 
+     * @throws Exception
+     */
+    public void test405WhenResourceMethodDoesNotExistButOthersDo() throws Exception {
+        HttpClient client = new HttpClient();
+
+        GetMethod getMethod = new GetMethod(getBaseURI() + "/existingresource/noexistsub");
+        try {
+            client.executeMethod(getMethod);
+            assertEquals(404, getMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(404, getMethod
+                .getResponseBodyAsString());
+
+        } finally {
+            getMethod.releaseConnection();
+        }
+
+        PostMethod postMethod = new PostMethod(getBaseURI() + "/targeting/resourcewithmethod");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(405, postMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(405, postMethod
+                .getResponseBodyAsString());
+        } finally {
+            getMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a 415 error is thrown when request entity data sent is not
+     * acceptable by the resource.
+     * 
+     * @throws Exception
+     */
+    public void test415WhenResourceMethodDoesNotAcceptRequestEntity() throws Exception {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI() + "/targeting/resourcewithmethod");
+        try {
+            putMethod.setRequestEntity(new StringRequestEntity("some content", "text/plain",
+                                                               "UTF-8"));
+            client.executeMethod(putMethod);
+            assertEquals(200, putMethod.getStatusCode());
+            assertEquals("some content", putMethod.getResponseBodyAsString());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        putMethod = new PutMethod(getBaseURI() + "/targeting/resourcewithmethod");
+        try {
+            putMethod.setRequestEntity(new StringRequestEntity("some content",
+                                                               "customplain/something", "UTF-8"));
+            client.executeMethod(putMethod);
+            assertEquals(415, putMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, putMethod
+                .getResponseBodyAsString());
+
+        } finally {
+            putMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a 406 error is produced if server side cannot produce any
+     * acceptable content type.
+     * 
+     * @throws Exception
+     */
+    public void test406WhenResourceMethodDoesNotProduceResponseEntityType() throws Exception {
+        HttpClient client = new HttpClient();
+
+        PutMethod putMethod = new PutMethod(getBaseURI() + "/targeting/resourcewithmethod");
+
+        try {
+            putMethod.addRequestHeader("Accept", "text/plain");
+            putMethod.setRequestEntity(new StringRequestEntity("some content", "text/plain",
+                                                               "UTF-8"));
+            client.executeMethod(putMethod);
+
+            assertEquals(200, putMethod.getStatusCode());
+            assertEquals("some content", putMethod.getResponseBodyAsString());
+        } finally {
+            putMethod.releaseConnection();
+        }
+
+        putMethod = new PutMethod(getBaseURI() + "/targeting/resourcewithmethod");
+        try {
+            putMethod.addRequestHeader("Accept", "text/customplain");
+            putMethod.setRequestEntity(new StringRequestEntity("some content", "text/plain",
+                                                               "UTF-8"));
+            client.executeMethod(putMethod);
+
+            assertEquals(406, putMethod.getStatusCode());
+            ServerContainerAssertions.assertExceptionBodyFromServer(406, putMethod
+                .getResponseBodyAsString());
+        } finally {
+            putMethod.releaseConnection();
+        }
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/NullValuesDuringTargettingTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/NullValuesDuringTargettingTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/NullValuesDuringTargettingTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-targeting/src/test/java/org/apache/wink/itest/exceptions/NullValuesDuringTargettingTest.java Fri Aug  7 03:10:22 2009
@@ -0,0 +1,345 @@
+/*
+ * 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.itest.exceptions;
+
+import java.io.IOException;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.test.integration.ServerContainerAssertions;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class NullValuesDuringTargettingTest extends TestCase {
+
+    public static String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI() + "/exceptional";
+    }
+
+    /**
+     * Tests that a request to a method with no content type, no request entity,
+     * but with a {@link Consumes} method results in a 415 error.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithNoRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withconsumes");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+            String responseBody = postMethod.getResponseBodyAsString();
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, responseBody);
+            if (responseBody == null || "".equals(responseBody)) {
+                assertNull(postMethod.getResponseHeader("Content-Type"));
+            }
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no content type, a request entity,
+     * but with a {@link Consumes} method results in a 415 error.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withconsumes");
+        postMethod.setRequestEntity(new ByteArrayRequestEntity(new byte[] {0, 1, 2}));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(415, postMethod.getStatusCode());
+            String responseBody = postMethod.getResponseBodyAsString();
+            ServerContainerAssertions.assertExceptionBodyFromServer(415, responseBody);
+            if (responseBody == null || "".equals(responseBody)) {
+                assertNull(postMethod.getResponseHeader("Content-Type"));
+            }
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no content type, a request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withoutconsumes");
+        postMethod.setRequestEntity(new ByteArrayRequestEntity("calledWithString".getBytes()));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("userReadercalledWithString", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with a content type, a request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withoutconsumes");
+        postMethod
+            .setRequestEntity(new ByteArrayRequestEntity("myString".getBytes(), "custom/type"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("myString", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with a content type, no request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithNoRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withoutconsumes");
+        postMethod.setRequestHeader("Content-Type", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no content type, no request entity,
+     * but without a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoContentTypeWithNoRequestEntityIncomingRequestWithNoConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withoutconsumes");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("userReader", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with a content type, no request entity,
+     * but with a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithNoRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withconsumes");
+        postMethod.setRequestHeader("Content-Type", "text/plain");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with a content type, a request entity,
+     * but with a {@link Consumes} method results in 200 successful method
+     * invocation.
+     * 
+     * @throws IOException
+     */
+    public void testContentTypeWithRequestEntityIncomingRequestWithConsumesMethod()
+        throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withconsumes");
+        postMethod
+            .setRequestEntity(new ByteArrayRequestEntity("mystring".getBytes(), "text/plain"));
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("mystring", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with an Accept header with a
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testAcceptHeaderIncomingRequestWithProducesMethod() throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withproduces");
+        postMethod.setRequestHeader("Accept", "custom/type; q=0.8");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("calledWithProduces", postMethod.getResponseBodyAsString());
+            assertEquals("custom/type;q=0.8", postMethod.getResponseHeader("Content-Type")
+                .getValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with an Accept header with no
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testAcceptHeaderIncomingRequestWithNoProducesMethod() throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withoutproduces");
+        postMethod.setRequestHeader("Accept", "custom/type2; q=0.8");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("calledWithoutProduces", postMethod.getResponseBodyAsString());
+            assertEquals("custom/type2;q=0.8", postMethod.getResponseHeader("Content-Type")
+                .getValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no Accept header with a
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoAcceptHeaderIncomingRequestWithProducesMethod() throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withproduces");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("calledWithProduces", postMethod.getResponseBodyAsString());
+            assertEquals("custom/type", postMethod.getResponseHeader("Content-Type").getValue());
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+
+    /**
+     * Tests that a request to a method with no Accept header with no
+     * {@link Produces} method results in 200 successful method invocation.
+     * 
+     * @throws IOException
+     */
+    public void testNoAcceptHeaderIncomingRequestWithNoProducesMethod() throws IOException {
+        HttpClient client = new HttpClient();
+
+        PostMethod postMethod =
+            new PostMethod(getBaseURI() + "/targeting/nullresource/withoutproduces");
+        try {
+            client.executeMethod(postMethod);
+            assertEquals(200, postMethod.getStatusCode());
+            assertEquals("calledWithoutProduces", postMethod.getResponseBodyAsString());
+            String contentType =
+                (postMethod.getResponseHeader("Content-Type") == null) ? null : postMethod
+                    .getResponseHeader("Content-Type").getValue();
+            assertNotNull(contentType, contentType);
+        } finally {
+            postMethod.releaseConnection();
+        }
+    }
+}