You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/07/19 04:46:13 UTC
svn commit: r795464 [2/2] - in
/incubator/wink/trunk/wink-integration-test/wink-server-integration-test: ./
wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/contentencoding/
wink-jaxrs-test-validation/ wink-jaxrs-test-validation/src/...
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/entity/EntityValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/entity/EntityValidationTest.java?rev=795464&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/entity/EntityValidationTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/entity/EntityValidationTest.java Sun Jul 19 02:46:11 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.jaxrs.test.param.entity;
+
+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 EntityValidationTest extends TestCase {
+
+ private static String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/param/entity/";
+ }
+
+ public void testValidationMultipleEntities() throws Exception {
+ HttpClient httpclient = new HttpClient();
+
+ GetMethod httpMethod = new GetMethod(getBaseURI() + "/params/multientity");
+ try {
+ httpclient.executeMethod(httpMethod);
+ assertEquals(404, httpMethod.getStatusCode());
+ // framework.defaults.test.FVTAssert
+ // .assertInstallLogContainsException("ResourceValidationException");
+ // if (Environment.getCurrentEnvironment() ==
+ // Environment.GENERIC_WAS) {
+ // framework.defaults.test.FVTAssert
+ // .assertInstallLogContainsException("Uncaught exception created in one of the service methods "
+ // + "of the servlet jaxrs.tests.validation.param.entity in "
+ // + "application jaxrs.tests.validation.param.entity. "
+ // + "Exception created : javax.servlet.ServletException: An error "
+ // + "occurred validating JAX-RS artifacts in the application.");
+ // }
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formfield/FormFieldValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formfield/FormFieldValidationTest.java?rev=795464&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formfield/FormFieldValidationTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formfield/FormFieldValidationTest.java Sun Jul 19 02:46:11 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.jaxrs.test.param.formfield;
+
+import javax.ws.rs.FormParam;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class FormFieldValidationTest extends TestCase {
+
+ private static String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/param/formfield";
+ }
+
+ /**
+ * {@link FormParam} annotated fields are not supported.
+ *
+ * @throws Exception
+ */
+ public void testFormFieldNoMultivaluedMapEntityValidation() throws Exception {
+ HttpClient httpclient = new HttpClient();
+
+ PostMethod httpMethod =
+ new PostMethod(getBaseURI() + "/params/form/validate/fieldnotmultivaluedmapparam");
+ try {
+ StringRequestEntity s =
+ new StringRequestEntity("firstkey=somevalue&someothervalue=somethingelse",
+ "application/x-www-form-urlencoded", null);
+ httpMethod.setRequestEntity(s);
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("null:firstkey=somevalue&someothervalue=somethingelse", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formparam/FormParamValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formparam/FormParamValidationTest.java?rev=795464&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formparam/FormParamValidationTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formparam/FormParamValidationTest.java Sun Jul 19 02:46:11 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.jaxrs.test.param.formparam;
+
+import javax.ws.rs.FormParam;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class FormParamValidationTest extends TestCase {
+
+ private static String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/param/formparam/";
+ }
+
+ /**
+ * {@link FormParam} annotated parameters with entity parameters are not
+ * supported.
+ *
+ * @throws Exception
+ */
+ public void testFormPropertyNoMultivaluedMapEntityValidation() throws Exception {
+ HttpClient httpclient = new HttpClient();
+
+ PostMethod httpMethod =
+ new PostMethod(getBaseURI() + "/params/form/validate/paramnotmultivaluedmaparam");
+ try {
+ StringRequestEntity s =
+ new StringRequestEntity("firstkey=somevalue&someothervalue=somethingelse",
+ "application/x-www-form-urlencoded", null);
+ httpMethod.setRequestEntity(s);
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("somevalue:", httpMethod.getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formproperty/FormPropertyValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formproperty/FormPropertyValidationTest.java?rev=795464&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formproperty/FormPropertyValidationTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/param/formproperty/FormPropertyValidationTest.java Sun Jul 19 02:46:11 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.jaxrs.test.param.formproperty;
+
+import javax.ws.rs.FormParam;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class FormPropertyValidationTest extends TestCase {
+
+ private static String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/param/formproperty";
+ }
+
+ /**
+ * {@link FormParam} annotated JavaBean property methods are not supported.
+ *
+ * @throws Exception
+ */
+ public void testFormPropertyNoMultivaluedMapEntityValidation() throws Exception {
+ HttpClient httpclient = new HttpClient();
+
+ PostMethod httpMethod =
+ new PostMethod(getBaseURI() + "/params/form/validate/propertynotmultivaluedmaparam");
+ try {
+ StringRequestEntity s =
+ new StringRequestEntity("firstkey=somevalue&someothervalue=somethingelse",
+ "application/x-www-form-urlencoded", null);
+ httpMethod.setRequestEntity(s);
+ httpclient.executeMethod(httpMethod);
+ assertEquals(200, httpMethod.getStatusCode());
+ assertEquals("null:firstkey=somevalue&someothervalue=somethingelse", httpMethod
+ .getResponseBodyAsString());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/pathmethods/PathMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/pathmethods/PathMethodTest.java?rev=795464&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/pathmethods/PathMethodTest.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-validation/src/test/java/org/apache/wink/jaxrs/test/pathmethods/PathMethodTest.java Sun Jul 19 02:46:11 2009
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wink.jaxrs.test.pathmethods;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class PathMethodTest extends TestCase {
+
+ protected HttpClient httpclient = new HttpClient();
+
+ private static String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/pathmethod/pathwarnings";
+ }
+
+ public void testNonPublicMethodPathWarning() {
+ try {
+ GetMethod httpMethod = new GetMethod();
+ httpMethod.setURI(new URI(getBaseURI() + "/private", false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(404, result);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ GetMethod httpMethod = new GetMethod();
+ httpMethod.setURI(new URI(getBaseURI() + "/protected", false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(404, result);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ GetMethod httpMethod = new GetMethod();
+ httpMethod.setURI(new URI(getBaseURI() + "/package", false));
+ httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(httpMethod);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ String responseBody = httpMethod.getResponseBodyAsString();
+ System.out.println(responseBody);
+ assertEquals(404, result);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ fail(ioe.getMessage());
+ } finally {
+ httpMethod.releaseConnection();
+ }
+ } catch (URIException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}