Return-Path: Delivered-To: apmail-incubator-wink-commits-archive@minotaur.apache.org Received: (qmail 56387 invoked from network); 23 Jun 2009 10:14:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Jun 2009 10:14:21 -0000 Received: (qmail 70790 invoked by uid 500); 23 Jun 2009 10:14:32 -0000 Delivered-To: apmail-incubator-wink-commits-archive@incubator.apache.org Received: (qmail 70688 invoked by uid 500); 23 Jun 2009 10:14:31 -0000 Mailing-List: contact wink-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: wink-dev@incubator.apache.org Delivered-To: mailing list wink-commits@incubator.apache.org Delivered-To: moderator for wink-commits@incubator.apache.org Received: (qmail 92898 invoked by uid 99); 23 Jun 2009 05:39:12 -0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r787553 [5/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/de... Date: Tue, 23 Jun 2009 05:38:19 -0000 To: wink-commits@incubator.apache.org From: ngallardo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090623053842.EBFE723888FC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/annotations/CustomOptions.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/annotations/CustomOptions.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/annotations/CustomOptions.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/annotations/CustomOptions.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package demo.jaxrs.options.server.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.ws.rs.HttpMethod; + +/** + * Custom HTTPMethod OPTIONS annotation. + */ +@HttpMethod("OPTIONS") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface CustomOptions { + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/Customer.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/Customer.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/Customer.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/Customer.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,30 @@ +/* + * 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 demo.jaxrs.options.server.customer; + +import javax.ws.rs.PUT; + +public interface Customer { + + public String getInfo(); + + @PUT + public String putInfo(); +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/ExternalCustomer.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/ExternalCustomer.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/ExternalCustomer.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/ExternalCustomer.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package demo.jaxrs.options.server.customer; + +public class ExternalCustomer implements Customer { + + public String getInfo() { + return "getExternalCustomer"; + } + + public String putInfo() { + return "putExternalCustomer"; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/InternalCustomer.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/InternalCustomer.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/InternalCustomer.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/InternalCustomer.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package demo.jaxrs.options.server.customer; + +public class InternalCustomer implements Customer { + + public String getInfo() { + return "getInternalCustomer"; + } + + public String putInfo() { + return "putInternalCustomer"; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/UnknownCustomer.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/UnknownCustomer.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/UnknownCustomer.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/server/customer/UnknownCustomer.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 demo.jaxrs.options.server.customer; + +import javax.ws.rs.PUT; + +public class UnknownCustomer implements Customer { + + public String getInfo() { + return "getUnknownCustomer"; + } + + @PUT + public String putInfo() { + return "putUnknownCustomer"; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsRootMethodsTest.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsRootMethodsTest.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsRootMethodsTest.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsRootMethodsTest.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,342 @@ +/* + * 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 demo.jaxrs.options.test; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.bind.JAXBContext; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.DeleteMethod; +import org.apache.commons.httpclient.methods.OptionsMethod; + +import demo.jaxrs.options.test.xml.Consumes; +import demo.jaxrs.options.test.xml.Produces; +import demo.jaxrs.options.test.xml.Representation; +import demo.jaxrs.options.test.xml.Resource; +import demo.jaxrs.options.test.xml.ResourceMethod; +import demo.jaxrs.options.test.xml.Resources; +import framework.defaults.test.FVTTestCase; + +/** + * Tests for OPTIONS request on a root resource. + */ +public class OptionsRootMethodsTest extends FVTTestCase { + + public static junit.framework.Test suite() { + return FVTTestCase.getTestSuite(OptionsRootMethodsTest.class, + "demo.jaxrs.options.server.Application"); + } + + private HttpClient client = new HttpClient(); + + /** + * Test a simple OPTIONS request on a single root resource with a single GET + * method that consumes and produces anything. + * + * @throws Exception + */ + public void testSimpleGETRequest() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/simple"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/simple", rootResource.getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertNull(rootResource.getResourceLocators()); + assertEquals(1, rootResource.getResourceMethods().size()); + + /* + * get method + */ + ResourceMethod getResourceMethod = rootResource + .getResourceMethods().get(0); + assertEquals("GET", getResourceMethod.getHttpMethod()); + + Consumes consumes = getResourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0).getMediaType()); + + Produces produces = getResourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0).getMediaType()); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Test a simple OPTIONS request on a single root resource that has + * {@link javax.ws.rs.Consumes} and {@link javax.ws.rs.Produces} with a + * single POST method that consumes and produces anything. Verifies that the + * POST method inherits the metadata. + * + * @throws Exception + */ + public void testRootResourceOptionsRequest() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/root"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/root", rootResource.getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertNull(rootResource.getResourceLocators()); + assertEquals(1, rootResource.getResourceMethods().size()); + + /* + * post method + */ + ResourceMethod getResourceMethod = rootResource + .getResourceMethods().get(0); + assertEquals("POST", getResourceMethod.getHttpMethod()); + + Consumes consumes = getResourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("application/json", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = getResourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(2, producesRepresentations.size()); + Set expectedRepresentations = new HashSet(); + expectedRepresentations.add("text/xml"); + expectedRepresentations.add("text/plain"); + + Set actualRepresentations = new HashSet(); + for (Representation r : producesRepresentations) { + actualRepresentations.add(r.getMediaType()); + } + assertEquals(expectedRepresentations, actualRepresentations); + + // System.out.println(Arrays.asList(optionsMethod.getResponseHeaders())); + Set actualAllowedMethods = new HashSet(Arrays + .asList(optionsMethod.getResponseHeader("Allow").getValue() + .split(", "))); + Set expectedAllowedMethods = new HashSet(Arrays + .asList(new String[] { "POST", "OPTIONS", "HEAD" })); + assertEquals(expectedAllowedMethods, actualAllowedMethods); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests a custom options response. This is to verify that a custom options + * request will still be allowed. + * + * @throws Exception + */ + public void testCustomOptionsResponse() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/custom"); + optionsMethod.setRequestHeader("Accept", "text/plain"); + try { + client.executeMethod(optionsMethod); + assertEquals(299, optionsMethod.getStatusCode()); + BufferedReader br = new BufferedReader(new InputStreamReader( + optionsMethod.getResponseBodyAsStream())); + String response = br.readLine(); + assertEquals("Custom options response", response); + } finally { + optionsMethod.releaseConnection(); + } + + optionsMethod.setRequestHeader("Accept", "text/xml"); + try { + client.executeMethod(optionsMethod); + assertEquals(406, optionsMethod.getStatusCode()); + } finally { + optionsMethod.releaseConnection(); + } + + DeleteMethod deleteMethod = new DeleteMethod(getBaseURI() + + "/options/custom"); + try { + client.executeMethod(deleteMethod); + assertEquals(405, deleteMethod.getStatusCode()); + + // System.out.println(Arrays.asList(deleteMethod.getResponseHeaders())); + Set expectedAllowedMethods = new HashSet(Arrays + .asList(new String[] { "GET", "OPTIONS", "HEAD" })); + String[] actualMethods = deleteMethod.getResponseHeader("Allow") + .getValue().split(", "); + Set actualAllowedMethods = new HashSet(); + for (String s : actualMethods) { + actualAllowedMethods.add(s.trim()); + } + assertTrue(expectedAllowedMethods.equals(actualAllowedMethods)); + } finally { + deleteMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request with a root resource with different root methods + * of consumes/produces to make sure that all methods are listed. Multiple + * GET and POST methods, each with different {@link javax.ws.rs.Consumes} + * and {@link javax.ws.rs.Produces}. + * + * @throws Exception + */ + public void testDifferentConsumeProducesMethodResources() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/diffconsumesproduces"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/diffconsumesproduces", rootResource + .getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertNull(rootResource.getResourceLocators()); + assertEquals(4, rootResource.getResourceMethods().size()); + + boolean isGETMethodWithXMLFound = false; + boolean isGETMethodWithJSONFound = false; + boolean isPOSTMethodWithXMLFound = false; + boolean isPOSTMethodWithJSONFound = false; + + for (ResourceMethod resourceMethod : rootResource + .getResourceMethods()) { + assertNull(resourceMethod.getPath()); + String method = resourceMethod.getHttpMethod(); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + Set expectedConsumesRepresentations = new HashSet(); + Set actualConsumesRepresentations = new HashSet(); + for (Representation r : consumesRepresentations) { + actualConsumesRepresentations.add(r.getMediaType()); + } + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + Set expectedProducesRepresentations = new HashSet(); + Set actualProducesRepresentations = new HashSet(); + for (Representation r : producesRepresentations) { + actualProducesRepresentations.add(r.getMediaType()); + } + if ("GET".equals(method)) { + if (consumesRepresentations.size() == 2) { + expectedConsumesRepresentations.add("text/xml"); + expectedConsumesRepresentations.add("text/plain"); + expectedProducesRepresentations.add("text/xml"); + isGETMethodWithXMLFound = true; + } else if (consumesRepresentations.size() == 1) { + expectedConsumesRepresentations.add("application/json"); + expectedProducesRepresentations.add("application/json"); + isGETMethodWithJSONFound = true; + } + } else if ("POST".equals(method)) { + if (consumesRepresentations.size() == 2) { + expectedConsumesRepresentations.add("application/json"); + expectedConsumesRepresentations.add("text/plain"); + expectedProducesRepresentations.add("text/xml"); + isPOSTMethodWithJSONFound = true; + } else if (consumesRepresentations.size() == 1) { + expectedConsumesRepresentations.add("text/xml"); + expectedProducesRepresentations.add("text/xml"); + expectedProducesRepresentations.add("text/plain"); + isPOSTMethodWithXMLFound = true; + } + } + assertEquals(expectedConsumesRepresentations, + actualConsumesRepresentations); + assertEquals(expectedProducesRepresentations, + actualProducesRepresentations); + } + assertTrue(isGETMethodWithJSONFound); + assertTrue(isGETMethodWithXMLFound); + assertTrue(isPOSTMethodWithJSONFound); + assertTrue(isPOSTMethodWithXMLFound); + + Set actualAllowedMethods = new HashSet(Arrays + .asList(optionsMethod.getResponseHeader("Allow").getValue() + .split(", "))); + Set expectedAllowedMethods = new HashSet(Arrays + .asList(new String[] { "POST", "GET", "OPTIONS", "HEAD" })); + assertEquals(expectedAllowedMethods, actualAllowedMethods); + } finally { + optionsMethod.releaseConnection(); + } + } + + // /** + // * Tests an OPTIONS request on the full application. + // * + // * @throws Exception + // */ + // public void testApplicationResources() throws Exception { + // fail(); + // } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubLocatorTest.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubLocatorTest.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubLocatorTest.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubLocatorTest.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,472 @@ +/* + * 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 demo.jaxrs.options.test; + +import java.util.List; + +import javax.xml.bind.JAXBContext; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.OptionsMethod; + +import demo.jaxrs.options.test.xml.Consumes; +import demo.jaxrs.options.test.xml.Produces; +import demo.jaxrs.options.test.xml.Representation; +import demo.jaxrs.options.test.xml.Resource; +import demo.jaxrs.options.test.xml.ResourceLocator; +import demo.jaxrs.options.test.xml.ResourceMethod; +import demo.jaxrs.options.test.xml.Resources; +import demo.jaxrs.options.test.xml.SubResource; +import framework.defaults.test.FVTTestCase; + +/** + * Tests OPTIONS with sub-locator requests. + */ +public class OptionsSubLocatorTest extends FVTTestCase { + + public static junit.framework.Test suite() { + return FVTTestCase.getTestSuite(OptionsSubLocatorTest.class, + "demo.jaxrs.options.server.Application"); + } + + private HttpClient client = new HttpClient(); + + /** + * Tests an OPTIONS request on a a simple root resource with sub-locators. + * + * @throws Exception + */ + public void testSubLocators() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/sublocators/"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/sublocators", rootResource.getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertEquals(1, rootResource.getResourceLocators().size()); + assertEquals(1, rootResource.getResourceMethods().size()); + + /* + * resource locator + */ + ResourceLocator resourceLocator = rootResource + .getResourceLocators().get(0); + assertEquals("customer", resourceLocator.getPath()); + + /* + * sub resource method + */ + assertNull(resources.getSubResources()); + + /* + * get resource method + */ + ResourceMethod resourceMethod = rootResource.getResourceMethods() + .get(0); + assertEquals("GET", resourceMethod.getHttpMethod()); + assertNull(resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0).getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("application/xml", producesRepresentations.get(0) + .getMediaType()); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request directly on a sub-locator method path. + * + * @throws Exception + */ + public void testOptionsDirectlyOnSubLocator() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/sublocators/customer/"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertNull(resourceList); + + List subResourceList = resources.getSubResources(); + assertEquals(1, subResourceList.size()); + + SubResource subResource = subResourceList.get(0); + assertNull(subResource.getPath()); + assertNull(subResource.getResourceLocators()); + assertEquals(1, subResource.getResourceMethods().size()); + boolean isSubResourcePutFound = false; + boolean isSubResourceGetFound = false; + for (ResourceMethod resourceMethod : subResource + .getResourceMethods()) { + String method = resourceMethod.getHttpMethod(); + if ("GET".equals(method)) { + isSubResourceGetFound = true; + + assertNull(resourceMethod.getPath()); + // assertEquals("/", resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0) + .getMediaType()); + } else if ("PUT".equals(method)) { + isSubResourcePutFound = true; + + assertNull(resourceMethod.getPath()); + // assertEquals("/", resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0) + .getMediaType()); + } + } + + assertFalse(isSubResourceGetFound); + assertTrue(isSubResourcePutFound); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request with a resource that has sub-locators but that + * does not have a root resource method. + * + * @throws Exception + */ + public void testResourceWithSublocatorsNoRootMethods() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/sublocatorsnoresmethods/"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/sublocatorsnoresmethods", rootResource + .getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + + /* + * resource locator + */ + assertEquals(1, rootResource.getResourceLocators().size()); + ResourceLocator resourceLocator = rootResource + .getResourceLocators().get(0); + assertEquals("/customer", resourceLocator.getPath()); + + /* + * sub resource method + */ + assertNull(resources.getSubResources()); + + /* + * root resource methods + */ + assertNull(rootResource.getResourceMethods()); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request on a sub-locator resource method with an + * interface return type. + * + * @throws Exception + */ + public void testRootWithSubLocatorWithInheritance() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/sublocatorinheritence/"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/sublocatorinheritence", rootResource + .getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertEquals(1, rootResource.getResourceLocators().size()); + assertEquals(1, rootResource.getResourceMethods().size()); + + /* + * resource locator + */ + ResourceLocator resourceLocator = rootResource + .getResourceLocators().get(0); + assertEquals("customer", resourceLocator.getPath()); + + /* + * sub resource method + */ + assertNull(resources.getSubResources()); + + /* + * get resource method + */ + ResourceMethod resourceMethod = rootResource.getResourceMethods() + .get(0); + assertEquals("GET", resourceMethod.getHttpMethod()); + assertNull(resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0).getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0).getMediaType()); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request directly on a sub-locator resource path with an + * interface return type. + * + * @throws Exception + */ + public void testRootWithSubLocatorDirectlyWithInheritance() + throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/sublocatorinheritence/customer"); + optionsMethod.setRequestHeader("Accept", "text/xml"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertNull(resourceList); + + List subResourceList = resources.getSubResources(); + assertEquals(1, subResourceList.size()); + + SubResource subResource = subResourceList.get(0); + assertNull(subResource.getPath()); + assertNull(subResource.getResourceLocators()); + assertEquals(1, subResource.getResourceMethods().size()); + boolean isSubResourcePutFound = false; + boolean isSubResourceGetFound = false; + for (ResourceMethod resourceMethod : subResource + .getResourceMethods()) { + String method = resourceMethod.getHttpMethod(); + if ("GET".equals(method)) { + isSubResourceGetFound = true; + + // assertEquals("/", resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0) + .getMediaType()); + } else if ("PUT".equals(method)) { + isSubResourcePutFound = true; + + // assertEquals("/", resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0) + .getMediaType()); + } + } + + assertFalse(isSubResourceGetFound); + assertTrue(isSubResourcePutFound); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request with a resource that has sub-locators methods + * that begin with HTTP method names. The sub-locator methods should not be + * listed as being a root resource method. + * + * @throws Exception + */ + public void testResourceWithSublocatorsRootMethodWithPost() + throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/sublocatormethodwithname/"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + // jc.createMarshaller().marshal(resources, System.out); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/sublocatormethodwithname", rootResource + .getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertEquals(1, rootResource.getResourceLocators().size()); + assertEquals(1, rootResource.getResourceMethods().size()); + + /* + * resource locator + */ + ResourceLocator resourceLocator = rootResource + .getResourceLocators().get(0); + assertEquals("/customer", resourceLocator.getPath()); + + /* + * sub resource method + */ + assertNull(resources.getSubResources()); + + /* + * get resource method + */ + ResourceMethod resourceMethod = rootResource.getResourceMethods() + .get(0); + assertEquals("POST", resourceMethod.getHttpMethod()); + assertNull(resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("*/*", consumesRepresentations.get(0).getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("*/*", producesRepresentations.get(0).getMediaType()); + } finally { + optionsMethod.releaseConnection(); + } + } + + // /** + // * Tests an OPTIONS request on a root resource with sub-resources and + // * recursion. + // * + // * @throws Exception + // */ + // public void testRootWithSubLocatorRecursion() throws Exception { + // fail(); + // } +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubResourceTest.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubResourceTest.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubResourceTest.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/OptionsSubResourceTest.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,252 @@ +/* + * 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 demo.jaxrs.options.test; + +import java.util.List; + +import javax.xml.bind.JAXBContext; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.OptionsMethod; + +import demo.jaxrs.options.test.xml.Consumes; +import demo.jaxrs.options.test.xml.Produces; +import demo.jaxrs.options.test.xml.Representation; +import demo.jaxrs.options.test.xml.Resource; +import demo.jaxrs.options.test.xml.ResourceMethod; +import demo.jaxrs.options.test.xml.Resources; +import framework.defaults.test.FVTTestCase; + +/** + * Tests the custom OPTIONS response in various sub-resource requests. + */ +public class OptionsSubResourceTest extends FVTTestCase { + + public static junit.framework.Test suite() { + return FVTTestCase.getTestSuite(OptionsSubResourceTest.class, + "demo.jaxrs.options.server.Application"); + } + + private HttpClient client = new HttpClient(); + + /** + * Tests a simple root resource with sub-resources. + * + * @throws Exception + */ + public void testOptionsOnRootWithSubResource() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/subresource"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/subresource", rootResource.getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertNull(rootResource.getResourceLocators()); + assertEquals(3, rootResource.getResourceMethods().size()); + + /* + * get method + */ + boolean isSubGETMethodFound = false; + boolean isRootDELETEMethodFound = false; + boolean isSubDELETEMethodFound = false; + for (ResourceMethod resourceMethod : rootResource + .getResourceMethods()) { + String method = resourceMethod.getHttpMethod(); + if ("GET".equals(method)) { + isSubGETMethodFound = true; + + assertEquals("/get", resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("text/plain", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("application/c1", producesRepresentations.get( + 0).getMediaType()); + } else if ("DELETE".equals(method)) { + String path = resourceMethod.getPath(); + // System.out.println(path); + if ("/delete".equals(path)) { + isSubDELETEMethodFound = true; + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("text/xml", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("text/xml", producesRepresentations.get(0) + .getMediaType()); + } else if (path == null) { + isRootDELETEMethodFound = true; + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("text/plain", consumesRepresentations.get( + 0).getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("application/json", + producesRepresentations.get(0).getMediaType()); + } + } + } + + assertTrue(isSubGETMethodFound); + assertTrue(isRootDELETEMethodFound); + assertTrue(isSubDELETEMethodFound); + } finally { + optionsMethod.releaseConnection(); + } + } + + /** + * Tests an OPTIONS request directly on a sub-resource method path. + * + * @throws Exception + */ + public void testOptionsDirectlyOnSubResource() throws Exception { + OptionsMethod optionsMethod = new OptionsMethod(getBaseURI() + + "/options/subresource/delete/"); + try { + client.executeMethod(optionsMethod); + assertEquals(200, optionsMethod.getStatusCode()); + JAXBContext jc = JAXBContext + .newInstance("demo.jaxrs.options.test.xml"); + Resources resources = (Resources) jc.createUnmarshaller() + .unmarshal(optionsMethod.getResponseBodyAsStream()); + List resourceList = resources.getResources(); + assertEquals(1, resourceList.size()); + + /* + * root resource + */ + Resource rootResource = resourceList.get(0); + assertEquals("/options/subresource", rootResource.getPath()); + assertNull(rootResource.getConsumes()); + assertNull(rootResource.getProduces()); + assertNull(rootResource.getResourceLocators()); + assertEquals(3, rootResource.getResourceMethods().size()); + + /* + * get method + */ + boolean isSubGETMethodFound = false; + boolean isRootDELETEMethodFound = false; + boolean isSubDELETEMethodFound = false; + for (ResourceMethod resourceMethod : rootResource + .getResourceMethods()) { + String method = resourceMethod.getHttpMethod(); + if ("GET".equals(method)) { + isSubGETMethodFound = true; + + assertEquals("/get", resourceMethod.getPath()); + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("text/plain", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("application/c1", producesRepresentations.get( + 0).getMediaType()); + } else if ("DELETE".equals(method)) { + String path = resourceMethod.getPath(); + // System.out.println(path); + if ("/delete".equals(path)) { + isSubDELETEMethodFound = true; + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("text/xml", consumesRepresentations.get(0) + .getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("text/xml", producesRepresentations.get(0) + .getMediaType()); + } else if (path == null) { + isRootDELETEMethodFound = true; + + Consumes consumes = resourceMethod.getConsumes(); + List consumesRepresentations = consumes + .getRepresentations(); + assertEquals(1, consumesRepresentations.size()); + assertEquals("text/plain", consumesRepresentations.get( + 0).getMediaType()); + + Produces produces = resourceMethod.getProduces(); + List producesRepresentations = produces + .getRepresentations(); + assertEquals(1, producesRepresentations.size()); + assertEquals("application/json", + producesRepresentations.get(0).getMediaType()); + } + } + } + + assertTrue(isSubGETMethodFound); + assertTrue(isRootDELETEMethodFound); + assertTrue(isSubDELETEMethodFound); + } finally { + optionsMethod.releaseConnection(); + } + } +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Consumes.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Consumes.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Consumes.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Consumes.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 demo.jaxrs.options.test.xml; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "consumes", namespace = "http://com.ibm.wsspi.options") +@XmlAccessorType(value = XmlAccessType.FIELD) +public class Consumes { + + @XmlElement(name = "representation", namespace = "http://com.ibm.wsspi.options") + private List representations; + + public List getRepresentations() { + return representations; + } + + public void setRepresentations(List representations) { + this.representations = representations; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ObjectFactory.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ObjectFactory.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ObjectFactory.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ObjectFactory.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,58 @@ +/* + * 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 demo.jaxrs.options.test.xml; + +import javax.xml.bind.annotation.XmlRegistry; + +@XmlRegistry +public class ObjectFactory { + + public Resources createResources() { + return new Resources(); + } + + public Resource createResource() { + return new Resource(); + } + + public SubResource createSubResource() { + return new SubResource(); + } + + public ResourceMethod createResourceMethod() { + return new ResourceMethod(); + } + + public ResourceLocator createResourceLocator() { + return new ResourceLocator(); + } + + public Consumes createConsumes() { + return new Consumes(); + } + + public Produces createProduces() { + return new Produces(); + } + + public Representation createRepresentation() { + return new Representation(); + } +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Produces.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Produces.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Produces.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Produces.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 demo.jaxrs.options.test.xml; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "produces", namespace = "http://com.ibm.wsspi.options") +@XmlAccessorType(value = XmlAccessType.FIELD) +public class Produces { + + @XmlElement(name = "representation", namespace = "http://com.ibm.wsspi.options") + private List representations; + + public List getRepresentations() { + return representations; + } + + public void setRepresentations(List representations) { + this.representations = representations; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Representation.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Representation.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Representation.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Representation.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,42 @@ +/* + * 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 demo.jaxrs.options.test.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "representation", namespace = "http://com.ibm.wsspi.options") +@XmlAccessorType(value = XmlAccessType.FIELD) +public class Representation { + + @XmlAttribute(name = "mediaType", namespace = "http://com.ibm.wsspi.options", required = true) + private String mediaType; + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resource.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resource.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resource.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resource.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,91 @@ +/* + * 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 demo.jaxrs.options.test.xml; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement +@XmlAccessorType(value = XmlAccessType.FIELD) +@XmlType(name = "resource", namespace = "http://com.ibm.wsspi.options") +public class Resource { + + @XmlAttribute(name = "path", namespace = "http://com.ibm.wsspi.options") + private String path; + + @XmlElement(name = "consumes", namespace = "http://com.ibm.wsspi.options") + private Consumes consumes; + + @XmlElement(name = "produces", namespace = "http://com.ibm.wsspi.options") + private Produces produces; + + @XmlElement(name = "resourceMethod", namespace = "http://com.ibm.wsspi.options") + private List resourceMethods; + + @XmlElement(name = "resourceLocator", namespace = "http://com.ibm.wsspi.options") + private List resourceLocators; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public Consumes getConsumes() { + return consumes; + } + + public void setConsumes(Consumes consumes) { + this.consumes = consumes; + } + + public Produces getProduces() { + return produces; + } + + public void setProduces(Produces produces) { + this.produces = produces; + } + + public List getResourceMethods() { + return resourceMethods; + } + + public void setResourceMethods(List resourceMethods) { + this.resourceMethods = resourceMethods; + } + + public List getResourceLocators() { + return resourceLocators; + } + + public void setResourceLocators(List resourceLocators) { + this.resourceLocators = resourceLocators; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceLocator.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceLocator.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceLocator.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceLocator.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,40 @@ +/* + * 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 demo.jaxrs.options.test.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +@XmlAccessorType(value = XmlAccessType.FIELD) +public class ResourceLocator { + + @XmlAttribute(name = "path", namespace = "http://com.ibm.wsspi.options") + private String path; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceMethod.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceMethod.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceMethod.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/ResourceMethod.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package demo.jaxrs.options.test.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +@XmlAccessorType(value = XmlAccessType.FIELD) +public class ResourceMethod { + + @XmlAttribute(name = "httpMethod", namespace = "http://com.ibm.wsspi.options") + private String httpMethod; + + @XmlElement(name = "consumes", namespace = "http://com.ibm.wsspi.options") + private Consumes consumes; + + @XmlElement(name = "produces", namespace = "http://com.ibm.wsspi.options") + private Produces produces; + + @XmlAttribute(name = "path", namespace = "http://com.ibm.wsspi.options") + private String path; + + @XmlElement(name = "schemaLocation", namespace = "http://com.ibm.wsspi.options") + private String schemaLocation; + + public String getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + } + + public Consumes getConsumes() { + return consumes; + } + + public void setConsumes(Consumes consumes) { + this.consumes = consumes; + } + + public Produces getProduces() { + return produces; + } + + public void setProduces(Produces produces) { + this.produces = produces; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getSchemaLocation() { + return schemaLocation; + } + + public void setSchemaLocation(String schemaLocation) { + this.schemaLocation = schemaLocation; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resources.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resources.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resources.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/Resources.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,57 @@ +/* + * 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 demo.jaxrs.options.test.xml; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement +@XmlAccessorType(value = XmlAccessType.FIELD) +@XmlType(name = "resources", namespace = "http://com.ibm.wsspi.options") +public class Resources { + + @XmlElement(name = "resource", namespace = "http://com.ibm.wsspi.options") + private List resources; + + @XmlElement(name = "subResource", namespace = "http://com.ibm.wsspi.options") + private List subResources; + + public List getResources() { + return resources; + } + + public void setResources(List resources) { + this.resources = resources; + } + + public List getSubResources() { + return subResources; + } + + public void setSubResources(List subResources) { + this.subResources = subResources; + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/SubResource.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/SubResource.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/SubResource.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/options/test/xml/SubResource.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package demo.jaxrs.options.test.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement +@XmlAccessorType(value = XmlAccessType.FIELD) +@XmlType(name = "subResource", namespace = "http://com.ibm.wsspi.options") +public class SubResource extends Resource { + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/buildTest.xml URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/buildTest.xml?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/buildTest.xml (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/buildTest.xml Tue Jun 23 05:37:57 2009 @@ -0,0 +1,24 @@ + + + + + + + Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/Address.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/Address.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/Address.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/Address.java Tue Jun 23 05:37:57 2009 @@ -0,0 +1,118 @@ +/* + * 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 demo.jaxrs.string.server; + +import javax.ws.rs.GET; +import javax.ws.rs.Produces; + +public class Address { + + private String entryName; + + private String zipCode; + + private String streetAddress; + + private String city; + + private String state; + + private String country; + + public Address(String entryName, String zipCode, String streetAddress, String city, String state, String country) { + this.entryName = entryName; + this.zipCode = zipCode; + this.streetAddress = streetAddress; + this.city = city; + this.state = state; + this.country = country; + } + + @GET + @Produces(value = { "text/xml" }) + public String get() { + return toString(); + } + + public String getEntryName() { + return entryName; + } + + public void setEntryName(String entryName) { + this.entryName = entryName; + } + + public String getZipCode() { + return zipCode; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + + public String getStreetAddress() { + return streetAddress; + } + + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("Entry Name: " + entryName); + sb.append("\n"); + sb.append("Street Address: " + streetAddress); + sb.append("\n"); + sb.append("City: " + city); + sb.append("\n"); + sb.append("Zip Code: " + zipCode); + sb.append("\n"); + sb.append("State: " + state); + sb.append("\n"); + sb.append("Country: " + country); + return sb.toString(); + } + +} Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/AddressApplication.java URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/AddressApplication.java?rev=787553&view=auto ============================================================================== --- incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/AddressApplication.java (added) +++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/demo/jaxrs/string/server/AddressApplication.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 demo.jaxrs.string.server; + +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.core.Application; + +public class AddressApplication extends Application { + + public Set> getClasses() { + Set> set = new HashSet>(); + set.add(AddressBook.class); + return set; + } + +}