You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/08/07 05:10:46 UTC
svn commit: r801869 [6/21] - in /incubator/wink/trunk: wink-integration-test/
wink-integration-test/wink-server-integration-test-support/
wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/
wink-in...
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/SecurityContextTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/SecurityContextTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/SecurityContextTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/securitycontext/SecurityContextTest.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.securitycontext;
+
+import java.io.IOException;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.itest.securitycontext.xml.ObjectFactory;
+import org.apache.wink.itest.securitycontext.xml.SecurityContextInfo;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class SecurityContextTest extends TestCase {
+
+ public String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/securitycontext";
+ }
+
+ /**
+ * Tests that a security context can be injected via a parameter.
+ *
+ * @throws IOException
+ * @throws HttpException
+ * @throws JAXBException
+ */
+ public void testSecurityContextParamResource() throws HttpException, IOException, JAXBException {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/securitycontext/param");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+
+ JAXBContext context =
+ JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
+ SecurityContextInfo secContextInfo =
+ (SecurityContextInfo)context.createUnmarshaller().unmarshal(getMethod
+ .getResponseBodyAsStream());
+ assertNotNull(secContextInfo);
+ assertEquals(false, secContextInfo.isSecure());
+ assertEquals(false, secContextInfo.isUserInRoleAdmin());
+ assertEquals(false, secContextInfo.isUserInRoleNull());
+ assertEquals(false, secContextInfo.isUserInRoleUser());
+ assertEquals("null", secContextInfo.getUserPrincipal());
+ assertNull(secContextInfo.getAuthScheme());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a security context can be injected via a constructor.
+ *
+ * @throws IOException
+ * @throws HttpException
+ * @throws JAXBException
+ */
+ public void testSecurityContextConstructorResource() throws HttpException, IOException,
+ JAXBException {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/securitycontext/constructor");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+
+ JAXBContext context =
+ JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
+ SecurityContextInfo secContextInfo =
+ (SecurityContextInfo)context.createUnmarshaller().unmarshal(getMethod
+ .getResponseBodyAsStream());
+ assertNotNull(secContextInfo);
+ assertEquals(false, secContextInfo.isSecure());
+ assertEquals(false, secContextInfo.isUserInRoleAdmin());
+ assertEquals(false, secContextInfo.isUserInRoleNull());
+ assertEquals(false, secContextInfo.isUserInRoleUser());
+ assertEquals("null", secContextInfo.getUserPrincipal());
+ assertNull(secContextInfo.getAuthScheme());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a security context can be injected via a bean method.
+ *
+ * @throws IOException
+ * @throws HttpException
+ * @throws JAXBException
+ */
+ public void testSecurityContextBeanResource() throws HttpException, IOException, JAXBException {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/securitycontext/bean");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+
+ JAXBContext context =
+ JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
+ SecurityContextInfo secContextInfo =
+ (SecurityContextInfo)context.createUnmarshaller().unmarshal(getMethod
+ .getResponseBodyAsStream());
+ assertNotNull(secContextInfo);
+ assertEquals(false, secContextInfo.isSecure());
+ assertEquals(false, secContextInfo.isUserInRoleAdmin());
+ assertEquals(false, secContextInfo.isUserInRoleNull());
+ assertEquals(false, secContextInfo.isUserInRoleUser());
+ assertEquals("null", secContextInfo.getUserPrincipal());
+ assertNull(secContextInfo.getAuthScheme());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a security context will not be injected into non-bean methods.
+ *
+ * @throws IOException
+ * @throws HttpException
+ */
+ public void testSecurityContextNotBeanResource() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/securitycontext/notbeanmethod");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(getMethod.getResponseBodyAsString(), "false");
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a security context can be injected via a member field.
+ *
+ * @throws IOException
+ * @throws HttpException
+ * @throws JAXBException
+ */
+ public void testSecurityContextFieldResource() throws HttpException, IOException, JAXBException {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/securitycontext/field");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+
+ JAXBContext context =
+ JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
+ SecurityContextInfo secContextInfo =
+ (SecurityContextInfo)context.createUnmarshaller().unmarshal(getMethod
+ .getResponseBodyAsStream());
+ assertNotNull(secContextInfo);
+ assertEquals(false, secContextInfo.isSecure());
+ assertEquals(false, secContextInfo.isUserInRoleAdmin());
+ assertEquals(false, secContextInfo.isUserInRoleNull());
+ assertEquals(false, secContextInfo.isUserInRoleUser());
+ assertEquals("null", secContextInfo.getUserPrincipal());
+ assertNull(secContextInfo.getAuthScheme());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoDetailedMethodTest.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,915 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.uriinfo;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.UriInfo;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.itest.uriinfo.MatchedResourcesSubResource;
+import org.apache.wink.itest.uriinfo.UriInfoDetailedMethods;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Tests that various {@link UriInfo} methods work as expected.
+ */
+public class URIInfoDetailedMethodTest extends TestCase {
+
+ public String appBase = "/uriinfo";
+
+ public String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + appBase;
+ }
+
+ /**
+ * Tests the {@link UriInfo#getAbsolutePath()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetAbsolutePath() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getAbsolutePath");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(getBaseURI() + "/context/uriinfo/detailed", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getAbsolutePathBuilder()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetAbsoluteBuilder() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getAbsolutePathBuilder");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(getBaseURI().replace(ServerEnvironmentInfo.getHostname(), "abcd") + "/context/uriinfo/detailed",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getBaseUri()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetBaseUri() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getBaseUri");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(getBaseURI() + "/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getBaseUriBuilder()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetBaseUriBuilder() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getBaseUriBuilder");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ String contextRoot = ServerEnvironmentInfo.getContextRoot();
+ if (!"".equals(contextRoot)) {
+ contextRoot = "/" + contextRoot;
+ }
+ String baseUri =
+ "http://" + "abcd"
+ + ":"
+ + ServerEnvironmentInfo.getPort()
+ + contextRoot
+ + appBase
+ + "/";
+ assertEquals(baseUri, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPath()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPath() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPath");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPath(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathDecoded() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathDecodedTrue");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathDecodedFalse");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/decoded/!%40%23%24%25%5E%26*()?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed/decoded/!%40%23%24%25%5E%26*()", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/decoded/!%40%23%24%25%5E%26*()?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed/decoded/!@#$%^&*()", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedResources()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedResourcesSimple() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedResources");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(UriInfoDetailedMethods.class.getName() + ":", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedResources()} in a sub resource method.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedResourcesSubresource() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/matchedresources");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(UriInfoDetailedMethods.class.getName() + ":"
+ + "-"
+ + MatchedResourcesSubResource.class.getName()
+ + ":"
+ + UriInfoDetailedMethods.class.getName()
+ + ":", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedURIs()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedURIs() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIs");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed" + ":", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedURIs()} in a sub-resource method.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedURIsSubresource() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/matcheduris");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed/matcheduris" + ":"
+ + "context/uriinfo/detailed"
+ + ":"
+ + "-"
+ + "context/uriinfo/detailed/matcheduris"
+ + ":"
+ + "context/uriinfo/detailed"
+ + ":", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedURIs(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedURIsDecodeTrue() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIsDecodedTrue");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed" + ":", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedURIs(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedURIsDecodeFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed?reqInfo=getMatchedURIsDecodedFalse");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed" + ":", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedURIs(boolean)} in a sub-locator.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedURIsSublocatorDecodeTrue() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/matchedurisdecoded/!%40%23%24%25%5E%26*()?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed/matchedurisdecoded/!@#$%^&*()", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getMatchedURIs(boolean)} in a sub-locator.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetMatchedURIsSublocatorDecodeFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/matchedurisdecoded/!%40%23%24%25%5E%26*()?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context/uriinfo/detailed/matchedurisdecoded/!%40%23%24%25%5E%26*()",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersZero() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParameters");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersOne() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/foo");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/foo:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/foo/bar");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/foo/bar:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersMany() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar/xyz");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=foo:p2=b:p3=ar/xyz:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=foo:p2=b:p3=ar:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersZeroDecodedFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParametersDecodedFalse");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersOneDecodedFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!%40%23%24%25%5E%26*()?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/!%40%23%24%25%5E%26*():", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!%40%23%24%25%5E%26*()/!%40%23%24%25%5E%26*()?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/!%40%23%24%25%5E%26*()/!%40%23%24%25%5E%26*():", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersManyDecodedFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar/xyz?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=foo:p2=b:p3=ar/xyz:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/foo/bar?decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=foo:p2=b:p3=ar:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersZeroDecodedTrue() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathParametersDecodedTrue");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersOneDecodedTrue() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone/?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed/pathparamsone?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!%40%23%24%25%5E%26*()?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/!@#$%^&*():", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsone/!%40%23%24%25%5E%26*()/!%40%23%24%25%5E%26*()?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=/!@#$%^&*()/!@#$%^&*():", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathParametersManyDecodedTrue() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/!%40%23%24%25%5E%26*()/bar/xyz?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=!@#$%^&*():p2=b:p3=ar/xyz:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/pathparamsmany/!%40%23%24%25%5E%26*()/bar?decoded=true");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("p1=!@#$%^&*():p2=b:p3=ar:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathSegments()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathSegments() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathSegments");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context#:uriinfo#:detailed#:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context;matrixp1=value1;matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegments");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context#foo=bar:matrixp1=value1:matrixp2=value2::uriinfo#:detailed#:",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context;matrixp1=!%40%23%24%25%5E%26*();matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegments");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context#foo=bar:matrixp1=!@#$%^&*():matrixp2=value2::uriinfo#:detailed#:",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getPathSegments(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetPathSegmentsDecodedFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context#:uriinfo#:detailed#:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context;matrixp1=value1;matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context#foo=bar:matrixp1=value1:matrixp2=value2::uriinfo#:detailed#:",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context;matrixp1=!%40%23%24%25%5E%26*();matrixp2=value2;foo=bar/uriinfo/detailed?reqInfo=getPathSegmentsDecodedFalse");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("context#foo=bar:matrixp1=!%40%23%24%25%5E%26*():matrixp2=value2::uriinfo#:detailed#:",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getQueryParameters()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetQueryParametersZero() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/detailed/queryparams");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getQueryParameters()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetQueryParametersOne() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getQueryParameters");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("reqInfo=getQueryParameters:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q1=value2");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("q1=value1:value2:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q1=value2");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("q1=value1:value2:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getQueryParameters()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetQueryParametersMany() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=value1&q2=value2");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("q1=value1:q2=value2:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=!%40%23%24%25%5E%26*()&q2=value2");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("q1=!@#$%^&*():q2=value2:", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getQueryParameters(boolean)}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetQueryParametersManyDecodedFalse() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(
+ getBaseURI() + "/context/uriinfo/detailed/queryparams?q1=!%40%23%24%25%5E%26*()&q2=value2&decoded=false");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("decoded=false:q1=!%40%23%24%25%5E%26*():q2=value2:", getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getRequestUri()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetRequestUri() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUri");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUri",
+ getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests the {@link UriInfo#getRequestUriBuilder()}.
+ *
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testURIInfoGetRequestUriBuilder() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUriBuilder");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ String expected =
+ (getBaseURI() + "/context/uriinfo/detailed?reqInfo=getRequestUriBuilder")
+ .replace(ServerEnvironmentInfo.getHostname(), "abcd");
+ assertEquals(expected, getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoInjectionTest.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.uriinfo;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+/**
+ * Tests that the UriInfo can be injected via various means.
+ */
+public class URIInfoInjectionTest extends TestCase {
+
+ public String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/uriinfo";
+ }
+
+ /**
+ * Tests that a URIInfo object is injected into method parameters.
+ *
+ * @throws IOException
+ * @throws HttpException
+ */
+ public void testURIInfoParamInjection() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/param");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(204, getMethod.getStatusCode());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a URIInfo object is injected via a bean method.
+ *
+ * @throws IOException
+ * @throws HttpException
+ */
+ public void testURIInfoBeanMethodInjection() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/bean");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(204, getMethod.getStatusCode());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a URIInfo object is injected via a constructor parameter.
+ *
+ * @throws IOException
+ * @throws HttpException
+ */
+ public void testURIInfoConstructorInjection() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/constructor");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(204, getMethod.getStatusCode());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a URIInfo object is injected via a field member.
+ *
+ * @throws IOException
+ * @throws HttpException
+ */
+ public void testURIInfoFieldMemberInjection() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/field");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(204, getMethod.getStatusCode());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a URIInfo object is not injected via non bean methods.
+ *
+ * @throws IOException
+ * @throws HttpException
+ */
+ public void testURIInfoNotBeanMethod() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/context/uriinfo/notbeanmethod");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(204, getMethod.getStatusCode());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-context/src/test/java/org/apache/wink/itest/uriinfo/URIInfoNormalizationTest.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,319 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.uriinfo;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class URIInfoNormalizationTest extends TestCase {
+
+ private final String appRoot = "/uriinfo";
+
+ public String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + appRoot;
+ }
+
+ /**
+ * Tests that a normal "good" path is returned.
+ *
+ * @throws Exception
+ */
+ public void testPathNormal() throws Exception {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that a path which removes the initial path to the resource class
+ * but adds it back in is okay.
+ *
+ * @throws Exception
+ */
+ public void testRemoveResourcePathThenAddItBack() throws Exception {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo/../uriinfo" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/." + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/./" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/./.././uriinfo/./" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/../uriinfo/" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/sub", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub/" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/sub/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests adding some extra paths to resource paths and then removing them.
+ *
+ * @throws Exception
+ */
+ public void testAddPathThenRemoveIt() throws Exception {
+ HttpClient client = new HttpClient();
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo/something/../" + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod = new GetMethod(getBaseURI() + "/uriinfo/something/.." + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub/something/../"
+ + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/sub/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/uriinfo/sub/../uriinfo/../sub/something/.."
+ + "?info=path");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("uriinfo/sub/", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that the capitalization is correct.
+ *
+ * @throws Exception
+ */
+ public void testCapitalization() throws Exception {
+ HttpClient client = new HttpClient();
+ String contextRoot = ServerEnvironmentInfo.getContextRoot();
+ if (!"".equals(contextRoot)) {
+ contextRoot = "/" + contextRoot;
+ }
+
+ GetMethod getMethod = new GetMethod(getBaseURI() + "/uriinfo/something/../" + "?info=host");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(ServerEnvironmentInfo.getHostname().toLowerCase(), getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * should be the same as first test above
+ */
+ getMethod =
+ new GetMethod("http://" + ServerEnvironmentInfo.getHostname()
+ + ":"
+ + ServerEnvironmentInfo.getPort()
+ + contextRoot
+ + appRoot
+ + "/uriinfo/something/../"
+ + "?info=host");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(ServerEnvironmentInfo.getHostname().toLowerCase(), getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * uppercased
+ */
+ getMethod =
+ new GetMethod("http://" + ServerEnvironmentInfo.getHostname().toUpperCase()
+ + ":"
+ + ServerEnvironmentInfo.getPort()
+ + contextRoot
+ + appRoot
+ + "/uriinfo/something/../"
+ + "?info=host");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals(ServerEnvironmentInfo.getHostname().toLowerCase(), getMethod
+ .getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * uppercased
+ */
+ getMethod =
+ new GetMethod("HTTP://" + ServerEnvironmentInfo.getHostname().toUpperCase()
+ + ":"
+ + ServerEnvironmentInfo.getPort()
+ + contextRoot
+ + appRoot
+ + "/uriinfo/something/../"
+ + "?info=protocol");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("http", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests that the capitalization is correct.
+ *
+ * @throws Exception
+ */
+ public void testPercentEncoding() throws Exception {
+ HttpClient client = new HttpClient();
+
+ /*
+ * regular query
+ */
+ GetMethod getMethod =
+ new GetMethod(getBaseURI() + "/uriinfo/something/../" + "?info=query&hello1=%3F");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("info=query&hello1=?", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * raw query
+ */
+ getMethod =
+ new GetMethod(getBaseURI() + "/uriinfo/something/../" + "?info=rawquery&hello1=%3F");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("info=rawquery&hello1=%3F", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ getMethod =
+ new GetMethod(getBaseURI() + "/uriinfo/something/../" + "?info=query&hello%31=%3F");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("info=query&hello1=?", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ /*
+ * %75 should eventually be normalized to /uriinfo/something %31 should
+ * be normalized to 1
+ */
+ getMethod =
+ new GetMethod(getBaseURI() + "/%75riinfo/something/../" + "?info=rawquery&hello%31=%3F");
+ try {
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ /*
+ * in this case, the %31 should remain encoded
+ */
+ assertEquals("info=rawquery&hello%31=%3F", getMethod.getResponseBodyAsString());
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml Fri Aug 7 03:10:22 2009
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+<!--
+ 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.
+-->
+ <parent>
+ <artifactId>wink-itest</artifactId>
+ <groupId>org.apache.wink</groupId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-itest-extra-providers</artifactId>
+ <packaging>war</packaging>
+ <name>wink-jaxrs-optional-providers Maven Webapp</name>
+ <version>0.1-incubating-SNAPSHOT</version>
+</project>
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/Application.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/Application.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/Application.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/Application.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/Application.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Author.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Author.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Author.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Author.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Author.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Blog.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Blog.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Blog.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Blog.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Blog.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogEntry.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogEntry.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogEntry.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogEntry.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogEntry.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogService.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogService.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogService.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogService.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/BlogService.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Comment.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Comment.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Comment.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Comment.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/java/org/apache/wink/jaxrs/test/atom/Comment.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/webapp/WEB-INF/geronimo-web.xml (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-context/src/main/webapp/WEB-INF/geronimo-web.xml)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/webapp/WEB-INF/geronimo-web.xml?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/webapp/WEB-INF/geronimo-web.xml&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-context/src/main/webapp/WEB-INF/geronimo-web.xml&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/webapp/WEB-INF/web.xml (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/webapp/WEB-INF/web.xml)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/webapp/WEB-INF/web.xml?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/main/webapp/WEB-INF/web.xml&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/main/webapp/WEB-INF/web.xml&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Copied: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/AtomTest.java (from r801788, incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/test/java/org/apache/wink/jaxrs/test/AtomTest.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/AtomTest.java?p2=incubator/wink/trunk/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/AtomTest.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-optional-providers/src/test/java/org/apache/wink/jaxrs/test/AtomTest.java&r1=801788&r2=801869&rev=801869&view=diff
==============================================================================
(empty)
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/pom.xml?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/pom.xml (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/pom.xml Fri Aug 7 03:10:22 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project>
+ <parent>
+ <artifactId>wink-itest</artifactId>
+ <groupId>org.apache.wink</groupId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>wink-itest-inheritance</artifactId>
+ <packaging>war</packaging>
+ <name>wink-jaxrs-test-inheritance Maven Webapp</name>
+</project>
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/InheritanceApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/InheritanceApplication.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/InheritanceApplication.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/InheritanceApplication.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+import org.apache.wink.itest.abc.ClassC;
+import org.apache.wink.itest.carstorage.CarFerry;
+import org.apache.wink.itest.carstorage.Carport;
+import org.apache.wink.itest.carstorage.ParkingGarage;
+import org.apache.wink.itest.carstorage.ParkingLot;
+import org.apache.wink.itest.fruits.Fruit;
+
+public class InheritanceApplication extends Application {
+
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(CarFerry.class);
+ classes.add(Carport.class);
+ classes.add(ParkingGarage.class);
+ classes.add(ParkingLot.class);
+ classes.add(ClassC.class);
+ classes.add(Fruit.class);
+ return classes;
+ }
+
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/AbstractClassB.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/AbstractClassB.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/AbstractClassB.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/AbstractClassB.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.abc;
+
+import javax.ws.rs.Encoded;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+public abstract class AbstractClassB {
+
+ @GET
+ @Path("abstract_method1/{p}")
+ @Encoded
+ public String method1(@PathParam("p") String path) {
+ return "Abstract Method1";
+ }
+
+ @POST
+ @Path("abstract_method2/{p}")
+ @Encoded
+ public Response method2(@PathParam("p") String path) {
+ Response resp = Response.ok().build();
+ resp.getMetadata().putSingle("Invoked", "AbstractClassB.method2");
+ return resp;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/ClassC.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/ClassC.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/ClassC.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/ClassC.java Fri Aug 7 03:10:22 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 org.apache.wink.itest.abc;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+@Path("/classc")
+public class ClassC extends AbstractClassB implements InterfaceA {
+
+ public String method1(@PathParam("p") String path) {
+ return "ClassC Method1;" + path;
+ }
+
+ @GET
+ @Path("method2/{p}")
+ public Response method2(@PathParam("p") String path) {
+ Response res = Response.ok("ClassC Method2;" + path).build();
+ return res;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/InterfaceA.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/InterfaceA.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/InterfaceA.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/abc/InterfaceA.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.abc;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+public interface InterfaceA {
+
+ @GET
+ @Path("/interface_method1/{p}")
+ public String method1(@PathParam("p") String path);
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarFerry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarFerry.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarFerry.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarFerry.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.carstorage;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path(value = "/carferry")
+public class CarFerry extends ParkingGarage {
+
+ Logger logger = LoggerFactory.getLogger(CarFerry.class);
+
+ @Context
+ protected UriInfo uriInfo;
+
+ public Response addCar(String licenseNum) {
+ super.setURIInfo(uriInfo);
+ Response resp = super.addCar(licenseNum);
+ resp.getMetadata().putSingle("Invoked", "CarFerry.addCar");
+ return resp;
+ }
+
+ public Response getCars() {
+ super.setURIInfo(uriInfo);
+ Response resp = super.getCars();
+ resp.getMetadata().putSingle("Invoked", "CarFerry.getCars");
+ return resp;
+ }
+
+ @GET
+ public Response removeCar(String licenseNum) {
+ super.setURIInfo(uriInfo);
+ Response resp = super.getCars();
+ resp.getMetadata().putSingle("Invoked", "CarFerry.removeCar");
+ return resp;
+ }
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarStorage.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarStorage.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarStorage.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/CarStorage.java Fri Aug 7 03:10:22 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 org.apache.wink.itest.carstorage;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+public interface CarStorage {
+
+ @GET
+ @Path(value = "/carstorage")
+ public Response getCars();
+
+ @POST
+ @Path(value = "/carstorage")
+ public Response addCar(String licenseNum);
+
+}
Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/Carport.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/Carport.java?rev=801869&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/Carport.java (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-inheritance/src/main/java/org/apache/wink/itest/carstorage/Carport.java Fri Aug 7 03:10:22 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.itest.carstorage;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path(value = "/carport")
+public class Carport implements CarStorage {
+
+ private static Set<String> cars = new HashSet<String>();
+
+ public Response addCar(String licenseNum) {
+ cars.add(licenseNum);
+ Response resp = Response.ok().build();
+ resp.getMetadata().putSingle("Invoked", "Carport.addCar");
+ return resp;
+ }
+
+ public Response getCars() {
+ StringBuffer sb = new StringBuffer();
+ for (String car : cars) {
+ sb.append(car).append(";");
+ }
+ Response resp = Response.ok(sb.toString()).build();
+ resp.getMetadata().putSingle("Invoked", "Carport.getCars");
+ return resp;
+ }
+
+ public static void clear() {
+ cars.clear();
+ }
+
+}