incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r787553 [31/34] - in /incubator/wink/contrib/ibm-jaxrs/tests: ./ fvt/ fvt/demo/ fvt/demo/jaxrs/ fvt/demo/jaxrs/cache/ fvt/demo/jaxrs/cache/server/ fvt/demo/jaxrs/cache/test/ fvt/demo/jaxrs/datasource/ fvt/demo/jaxrs/datasource/server/ fvt/d...
Date Tue, 23 Jun 2009 05:38:19 GMT
Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/head/HeadTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/head/HeadTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/head/HeadTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/head/HeadTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,88 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.head;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.HttpMethod;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+public class HeadTest extends ServletTestFramework {
+
+    public void testGetPlainWithHead() throws Exception {
+        RESTServlet servlet = createServlet(HeadApplication.class.getName());
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/method", HttpMethod.HEAD);
+        Map<String, List<String>> headers = new HashMap<String, List<String>>();
+        List<String> acceptValues = new ArrayList<String>();
+        acceptValues.add("text/xml");
+        headers.put("Accept", acceptValues);
+        request.setAttribute(ServletRequest.HTTP_HEADERS, headers);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doHead(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("", responseContent);
+            String hdrValue = response.getHeader("Invoked");
+            assertEquals("MethodResource.getPlain", hdrValue);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetHtmlWithHead() throws Exception {
+        RESTServlet servlet = createServlet(HeadApplication.class.getName());
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/method", HttpMethod.HEAD);
+        Map<String, List<String>> headers = new HashMap<String, List<String>>();
+        List<String> acceptValues = new ArrayList<String>();
+        acceptValues.add("text/html");
+        headers.put("Accept", acceptValues);
+        request.setAttribute(ServletRequest.HTTP_HEADERS, headers);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doHead(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("", responseContent);
+            String hdrValue = response.getHeader("Invoked");
+            assertEquals("MethodResource.getHtml", hdrValue);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.options;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(DocumentsResource.class);
+        classes.add(FormsResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Document.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Document.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Document.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/Document.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,44 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.options;
+
+public class Document {
+
+    private String name;
+
+    private String version;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentListWrapper.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentListWrapper.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentListWrapper.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentListWrapper.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,51 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.options;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "documents", namespace = "http://com.ibm.rest.options")
+public class DocumentListWrapper {
+
+    @XmlElement(name = "document")
+    private Map<String, Document> documents = new HashMap<String, Document>();
+
+    public void addDocument(Document document) {
+        documents.put(document.getName(), document);
+    }
+
+    public void setDocuments(Map<String, Document> documents) {
+        this.documents = documents;
+    }
+
+    public Collection<Document> getDocuments() {
+        return documents.values();
+    }
+
+    public Document getDocument(String docName) {
+        return documents.get(docName);
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentsResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentsResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentsResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/DocumentsResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.options;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+@Path(value = "/documents")
+public class DocumentsResource {
+
+    private static DocumentListWrapper wrapper = new DocumentListWrapper();
+
+    @GET
+    @Consumes(value = "text/html")
+    @Produces(value = "application/xml")
+    public DocumentListWrapper getDocuments() {
+        return wrapper;
+    }
+
+    @GET
+    @Path(value = "/{docName}")
+    @Consumes(value = "text/html")
+    @Produces(value = { "application/xml", "application/json" })
+    public JAXBElement<Document> getDocument(@PathParam(value = "docName") String docName) {
+        Document document = wrapper.getDocument(docName);
+        return new JAXBElement<Document>(new QName(
+                "http://com.ibm.rest.options", "document"), Document.class,
+                document);
+    }
+
+    @Path(value = "/{docName}/version/{versionNum}")
+    public VersionResource getVersion(@PathParam(value = "docName") String docName, @PathParam(value = "versionNum") String versionNum) {
+        Document document = wrapper.getDocument(docName);
+        return new VersionResource(document, versionNum);
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/FormsResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/FormsResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/FormsResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/FormsResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.options;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path(value = "/forms")
+public class FormsResource {
+
+    @GET
+    public String getFormIds() {
+        return null;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/OptionsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/OptionsTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/OptionsTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/OptionsTest.java Tue Jun 23 05:37:57 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 com.ibm.ws.jaxrs.sample.options;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+import com.ibm.wsspi.jaxrs.options.Resource;
+import com.ibm.wsspi.jaxrs.options.ResourceLocator;
+import com.ibm.wsspi.jaxrs.options.ResourceMethod;
+import com.ibm.wsspi.jaxrs.options.Resources;
+import com.ibm.wsspi.jaxrs.options.SubResource;
+
+public class OptionsTest extends ServletTestFramework {
+
+    /*
+     * Test ability to issue an options request to a root resource
+     */
+    public void testOptionsRoot() throws Exception {
+        RESTServlet servlet = createServlet(Application.class.getName());
+
+        try {
+            ServletRequest request = ServletTestFramework.createServletRequest(
+                    "/documents", null, "OPTIONS");
+            StringWriter sw = new StringWriter();
+            ServletResponse response = ServletTestFramework
+                    .createServletResponse(sw);
+            request.setAttribute(ServletRequest.CONTENT_TYPE, "text/html");
+            Map<String, List<String>> headers = new HashMap<String, List<String>>();
+            List<String> accept = new ArrayList<String>();
+            accept.add("application/xml");
+            headers.put(HttpHeaders.ACCEPT, accept);
+            request.setAttribute(ServletRequest.HTTP_HEADERS, headers);
+            servlet.doOptions(request, response);
+            JAXBContext context = JAXBContext
+                    .newInstance("com.ibm.wsspi.jaxrs.options");
+            Unmarshaller u = context.createUnmarshaller();
+            Resources resources = (Resources) u
+                    .unmarshal(new ByteArrayInputStream(sw.toString()
+                            .getBytes()));
+            assertNotNull(resources);
+            List<Resource> resourceList = resources.getResources();
+            assertNotNull(resourceList);
+            assertEquals(1, resourceList.size());
+            Resource resource = resourceList.get(0);
+            List<ResourceMethod> resourceMethods = resource
+                    .getResourceMethods();
+            List<ResourceLocator> resourceLocators = resource
+                    .getResourceLocators();
+            assertNotNull(resourceMethods);
+            assertEquals(2, resourceMethods.size());
+            assertNotNull(resourceLocators);
+            assertEquals(1, resourceLocators.size());
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    /*
+     * Test ability to issue an options request to a subresource
+     */
+    public void testOptionsSubResource() throws Exception {
+        RESTServlet servlet = createServlet(Application.class.getName());
+
+        try {
+            ServletRequest request = ServletTestFramework.createServletRequest(
+                    "/documents/doc1/version/1.1", null, "OPTIONS");
+            StringWriter sw = new StringWriter();
+            ServletResponse response = ServletTestFramework
+                    .createServletResponse(sw);
+            request.setAttribute(ServletRequest.CONTENT_TYPE, "text/html");
+            Map<String, List<String>> headers = new HashMap<String, List<String>>();
+            List<String> accept = new ArrayList<String>();
+            accept.add("application/xml");
+            headers.put(HttpHeaders.ACCEPT, accept);
+            request.setAttribute(ServletRequest.HTTP_HEADERS, headers);
+            servlet.doOptions(request, response);
+            JAXBContext context = JAXBContext
+                    .newInstance("com.ibm.wsspi.jaxrs.options");
+            Unmarshaller u = context.createUnmarshaller();
+            Resources resources = (Resources) u
+                    .unmarshal(new ByteArrayInputStream(sw.toString()
+                            .getBytes()));
+            assertNotNull(resources);
+            List<SubResource> subResourceList = resources.getSubResources();
+            assertNotNull(subResourceList);
+            assertEquals(1, subResourceList.size());
+            SubResource subResource = subResourceList.get(0);
+            List<ResourceMethod> resourceMethods = subResource
+                    .getResourceMethods();
+            assertNotNull(resourceMethods);
+            assertEquals(1, resourceMethods.size());
+            ResourceMethod resourceMethod = resourceMethods.get(0);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    /*
+     * Test ability to issue an options request to the context root of a web app
+     */
+    public void testOptionsContextRoot() throws Exception {
+        RESTServlet servlet = createServlet(Application.class.getName());
+        try {
+            ServletRequest request = ServletTestFramework.createServletRequest(
+                    "/", null, "OPTIONS");
+            StringWriter sw = new StringWriter();
+            ServletResponse response = ServletTestFramework
+                    .createServletResponse(sw);
+            request.setAttribute(ServletRequest.CONTENT_TYPE, "text/html");
+            Map<String, List<String>> headers = new HashMap<String, List<String>>();
+            List<String> accept = new ArrayList<String>();
+            accept.add("application/xml");
+            headers.put(HttpHeaders.ACCEPT, accept);
+            request.setAttribute(ServletRequest.HTTP_HEADERS, headers);
+            servlet.doOptions(request, response);
+            JAXBContext context = JAXBContext
+                    .newInstance("com.ibm.wsspi.jaxrs.options");
+            Unmarshaller u = context.createUnmarshaller();
+            Resources resources = (Resources) u
+                    .unmarshal(new ByteArrayInputStream(sw.toString()
+                            .getBytes()));
+            assertNotNull(resources);
+            List<Resource> resourceList = resources.getResources();
+            assertNotNull(resourceList);
+            assertEquals(2, resourceList.size());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/VersionResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/VersionResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/VersionResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/options/VersionResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,39 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.options;
+
+import javax.ws.rs.GET;
+
+public class VersionResource {
+
+    private Document document;
+
+    private String versionNum;
+
+    public VersionResource(Document document, String versionNum) {
+
+    }
+
+    @GET
+    public String getVersionNum() {
+        return versionNum;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,53 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.path;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+@Path(value = "/mixed")
+public class MixedResource {
+
+    @GET
+    @Path(value = "{id: .+}")
+    public String nolimites(@PathParam("id") String id) {
+        return "nolimites";
+    }
+
+    @GET
+    @Path(value = "xyz/{id}")
+    public String onelimited(@PathParam("id") String id) {
+        return "onelimited";
+    }
+
+    @GET
+    @Path(value = "xyz/{id: .+}")
+    public String onenolimite(@PathParam("id") String id) {
+        return "onenolimite";
+    }
+
+    @GET
+    @Path(value = "{id}")
+    public String limited(@PathParam("id") String id) {
+        return "limited";
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResourceApp.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResourceApp.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResourceApp.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedResourceApp.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.path;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class MixedResourceApp extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(MixedResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/MixedTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.path;
+
+import javax.ws.rs.HttpMethod;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+public class MixedTests extends ServletTestFramework {
+
+    public void testGet() throws Exception {
+        RESTServlet servlet = createServlet(MixedResourceApp.class.getName());
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/mixed/blah", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("nolimites", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetMorePath() throws Exception {
+        RESTServlet servlet = createServlet(MixedResourceApp.class.getName());
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/mixed/xyz/007", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("onenolimite", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathApplication.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathApplication.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.path;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class PathApplication extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(PathResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,63 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.path;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.Response;
+
+@Path("path/{resource}")
+public class PathResource {
+
+    @GET
+    @Produces(value = "text/xml")
+    public Response get(@PathParam(value = "path") String path, @PathParam(value = "resource") String resource, @MatrixParam(value = "version") String version) {
+        String entity = "path=" + path + "&resource=" + resource + "&version="
+                + version;
+        Response resp = Response.ok(entity).build();
+        return resp;
+    }
+
+    @GET
+    @Produces(value = "text/xml")
+    @Path(value = "/seg")
+    public Response getWithSeg(@PathParam(value = "path") PathSegment path, @PathParam(value = "resource") String resource, @MatrixParam(value = "version") String version) {
+        String entity = "path=" + path.getPath() + "&resource=" + resource
+                + "&version=" + version;
+        Response resp = Response.ok(entity).build();
+        return resp;
+    }
+
+    @GET
+    @Produces(value = "text/xml")
+    @Path(value = "/seg/{mps}")
+    public Response getWithSegMPs(@PathParam(value = "path") PathSegment path, @PathParam(value = "resource") String resource, @PathParam(value = "mps") PathSegment mps) {
+        String version = mps.getMatrixParameters().getFirst("version");
+        String entity = "path=" + path.getPath() + "&resource=" + resource
+                + "&version=" + version;
+        Response resp = Response.ok(entity).build();
+        return resp;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/PathTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,132 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.path;
+
+import javax.ws.rs.HttpMethod;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+public class PathTests extends ServletTestFramework {
+
+    public void testGetAppendedMP() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.sample.path.PathApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/path/dictionary;version=1.1", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals(
+                    "path=path&resource=dictionary;version=1.1&version=1.1",
+                    responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetPathEmbeddedMP() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.sample.path.PathApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/path;version=1.1/dictionary", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("path=path&resource=dictionary&version=1.1",
+                    responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetPathNoMP() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.sample.path.PathApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/path/dictionary", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("path=path&resource=dictionary&version=null",
+                    responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetPathSegNoMP() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.sample.path.PathApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/path/dictionary/seg", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("path=path&resource=dictionary&version=null",
+                    responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetPathSegMP() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.sample.path.PathApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/path/dictionary/seg/mps;version=1.1", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("path=path&resource=dictionary&version=1.1",
+                    responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExApplication.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExApplication.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.path;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class RegExApplication extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(RegExResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.path;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+@Path("/{base:\\w+\\.?\\w+}/{tail}")
+public class RegExResource {
+
+    @GET
+    @Path(value = "/gethere")
+    public Response get(@PathParam(value = "base") String base, @PathParam(value = "tail") String tail) {
+        Response resp = Response.ok("You made it!").build();
+        resp.getMetadata().putSingle("base", base);
+        resp.getMetadata().putSingle("tail", tail);
+        return resp;
+    }
+
+    @GET
+    @Path(value = "/gethere/{last:\\w+\\-?\\w+}")
+    public Response getMoreComplicated(@PathParam(value = "base") String base, @PathParam(value = "tail") String tail, @PathParam(value = "last") String last) {
+        Response resp = Response.ok("You got here the hard way!").build();
+        resp.getMetadata().putSingle("base", base);
+        resp.getMetadata().putSingle("tail", tail);
+        resp.getMetadata().putSingle("last", last);
+        return resp;
+    }
+
+    @GET
+    @Path(value = "/gethere/{part}/{parttwo}/{last}")
+    public Response getSimple(@PathParam(value = "base") String base, @PathParam(value = "tail") String tail, @PathParam(value = "part") String part, @PathParam(value = "parttwo") String parttwo, @PathParam(value = "last") String last) {
+        Response resp = Response.ok("You got here the easy way!").build();
+        resp.getMetadata().putSingle("base", base);
+        resp.getMetadata().putSingle("tail", tail);
+        resp.getMetadata().putSingle("part", part);
+        resp.getMetadata().putSingle("parttwo", parttwo);
+        resp.getMetadata().putSingle("last", last);
+        return resp;
+    }
+
+    @GET
+    @Path(value = "/gethere/{part:\\w+\\-?\\w+}/distinguisher/{last:\\w+\\-?\\w+}")
+    public Response getMostComplicated(@PathParam(value = "base") String base, @PathParam(value = "tail") String tail, @PathParam(value = "part") String part, @PathParam(value = "last") String last) {
+        Response resp = Response.ok("You got here the hardest way!").build();
+        resp.getMetadata().putSingle("base", base);
+        resp.getMetadata().putSingle("tail", tail);
+        resp.getMetadata().putSingle("part", part);
+        resp.getMetadata().putSingle("last", last);
+        return resp;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/path/RegExTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,120 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.path;
+
+import javax.ws.rs.HttpMethod;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+public class RegExTests extends ServletTestFramework {
+
+    public void testGetRegExSimple() throws Exception {
+        RESTServlet servlet = createServlet(RegExApplication.class.getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/sample.xml/version1/gethere", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals("You made it!", responseContent);
+            assertEquals(response.getHeader("base"), "sample.xml");
+            assertEquals(response.getHeader("tail"), "version1");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetRegExOperation() throws Exception {
+        RESTServlet servlet = createServlet(RegExApplication.class.getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/sample.xml/version1/gethere/yee-haw", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals(response.getHeader("base"), "sample.xml");
+            assertEquals(response.getHeader("tail"), "version1");
+            assertEquals(response.getHeader("last"), "yee-haw");
+            assertEquals("You got here the hard way!", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetSubstitutionOperation() throws Exception {
+        RESTServlet servlet = createServlet(RegExApplication.class.getName());
+        ServletRequest request = ServletTestFramework
+                .createServletRequest(
+                        "/sample.xml/version1/gethere/getherehard/getheresimple/whoo-hoo",
+                        HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals(response.getHeader("base"), "sample.xml");
+            assertEquals(response.getHeader("tail"), "version1");
+            assertEquals(response.getHeader("part"), "getherehard");
+            assertEquals(response.getHeader("parttwo"), "getheresimple");
+            assertEquals(response.getHeader("last"), "whoo-hoo");
+            assertEquals("You got here the easy way!", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetMoreComplex() throws Exception {
+        RESTServlet servlet = createServlet(RegExApplication.class.getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/sample.xml/version1/gethere/yee-haw/distinguisher/whoo-hoo",
+                HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertEquals(response.getHeader("base"), "sample.xml");
+            assertEquals(response.getHeader("tail"), "version1");
+            assertEquals(response.getHeader("part"), "yee-haw");
+            assertEquals(response.getHeader("last"), "whoo-hoo");
+            assertEquals("You got here the hardest way!", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamApplication.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamApplication.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.queryparam;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class QueryParamApplication extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(QueryParamResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,90 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.queryparam;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+@Path(value = "/query")
+public class QueryParamResource {
+
+    @GET
+    public Response get(@QueryParam(value = "id") String id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id", id);
+        return resp;
+    }
+
+    @PUT
+    public Response put(@QueryParam(value = "id") String id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id", id);
+        return resp;
+    }
+
+    @POST
+    public Response post(@QueryParam(value = "id") String id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id", id);
+        return resp;
+    }
+
+    @DELETE
+    public Response delete(@QueryParam(value = "id") String id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id", id);
+        return resp;
+    }
+
+    @GET
+    @Path(value = "/int")
+    public Response getInt(@QueryParam(value = "id") int id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id", id);
+        return resp;
+    }
+
+    @GET
+    @Path(value = "/list")
+    public Response getSet(@QueryParam(value = "id") Set<String> id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id",
+                (id != null && !id.isEmpty() ? id.iterator().next() : "empty"));
+        return resp;
+    }
+
+    @GET
+    @Path(value = "/set")
+    public Response getList(@QueryParam(value = "id") List<String> id) {
+        Response resp = Response.ok().build();
+        resp.getMetadata().putSingle("id",
+                (id != null && !id.isEmpty() ? id.get(0) : "empty"));
+        return resp;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/queryparam/QueryTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,191 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.queryparam;
+
+import javax.ws.rs.HttpMethod;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+public class QueryTests extends ServletTestFramework {
+
+    public void testGet() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query", "id=007", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "007");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testPut() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query", "id=007", HttpMethod.PUT);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doPut(request, response);
+            assertEquals(response.getHeader("id"), "007");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testPost() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query", "id=007", HttpMethod.POST);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doPost(request, response);
+            assertEquals(response.getHeader("id"), "007");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testDelete() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query", "id=007", HttpMethod.DELETE);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doDelete(request, response);
+            assertEquals(response.getHeader("id"), "007");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetInt() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query/int", "id=007", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "7");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetIntDefault() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query/int", null, HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "0");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetSet() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query/set", "id=007", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "007");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetSetDefault() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query/set", null, HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "empty");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetList() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query/list", "id=007", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "007");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testGetListDefault() throws Exception {
+        RESTServlet servlet = createServlet(QueryParamApplication.class
+                .getName());
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/query/list", null, HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+            assertEquals(response.getHeader("id"), "empty");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderApplication.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderApplication.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.responsebuilder;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class ResponseBuilderApplication extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(ResponseBuilderResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/sample/responsebuilder/ResponseBuilderResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,152 @@
+/*
+ * 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 com.ibm.ws.jaxrs.sample.responsebuilder;
+
+import java.net.URI;
+import java.util.Calendar;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.EntityTag;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+
+@Path(value = "/responsebuilder")
+public class ResponseBuilderResource {
+
+    @GET
+    @Path(value = "/cachecontrol")
+    public Response getCacheControl() {
+        ResponseBuilder rb = Response.ok();
+        CacheControl cc = new CacheControl();
+        cc.setMaxAge(50);
+        cc.setNoCache(false);
+        cc.setNoStore(false);
+        cc.setMustRevalidate(true);
+        cc.setNoTransform(false);
+        cc.setPrivate(true);
+        cc.setProxyRevalidate(false);
+        cc.setSMaxAge(65);
+        rb.cacheControl(cc);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/newcookie")
+    public Response getNewCookie() {
+        ResponseBuilder rb = Response.ok();
+        NewCookie cookie = new NewCookie("sessionid", "123",
+                "/responsebuilder/newcookie", "localhost",
+                "this is a newCookie", 50, true);
+        rb.cookie(cookie);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/newcookies")
+    public Response getNewCookies() {
+        ResponseBuilder rb = Response.ok();
+        NewCookie[] cookies = new NewCookie[2];
+        cookies[0] = new NewCookie("sessionid", "123",
+                "/responsebuilder/newcookie", "localhost",
+                "this is a newCookie", 50, true);
+        cookies[1] = new NewCookie("pages", "full");
+        rb.cookie(cookies);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/expires")
+    public Response getExpires() {
+        ResponseBuilder rb = Response.ok();
+        Calendar calendar = Calendar.getInstance();
+        calendar.clear();
+        calendar.set(2008, 11, 31);
+        rb.expires(calendar.getTime());
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/language")
+    public Response getLanguage() {
+        ResponseBuilder rb = Response.ok();
+        rb.language("en-gb");
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/lastmodified")
+    public Response getLastModified() {
+        ResponseBuilder rb = Response.ok();
+        Calendar calendar = Calendar.getInstance();
+        calendar.clear();
+        calendar.set(2008, 11, 31);
+        rb.lastModified(calendar.getTime());
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/location")
+    public Response getLocation() throws Exception {
+        ResponseBuilder rb = Response.ok();
+        URI uri = new URI("/responsebuilder/location");
+        rb.location(uri);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/contentlocation")
+    public Response getContentLocation() throws Exception {
+        ResponseBuilder rb = Response.ok();
+        URI uri = new URI("/responsebuilder/contentlocation");
+        rb.contentLocation(uri);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/etag")
+    public Response getETag() throws Exception {
+        ResponseBuilder rb = Response.ok();
+        EntityTag tag = new EntityTag("myTag");
+        rb.tag(tag);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/contenttype")
+    public Response getContentType() throws Exception {
+        ResponseBuilder rb = Response.ok();
+        MediaType mediaType = new MediaType("text", "xml");
+        rb.type(mediaType);
+        return rb.build();
+    }
+
+    @GET
+    @Path(value = "/userheader")
+    public Response getUserHeader() throws Exception {
+        ResponseBuilder rb = Response.ok();
+        rb.header("Resource", this.getClass().getName());
+        return rb.build();
+    }
+
+}



Mime
View raw message