You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by rf...@apache.org on 2011/03/11 05:23:59 UTC

svn commit: r1080436 - in /incubator/wink/trunk/wink-component-test-support/src/test: ./ java/ java/org/ java/org/apache/ java/org/apache/wink/ java/org/apache/wink/test/ java/org/apache/wink/test/mock/

Author: rfeng
Date: Fri Mar 11 04:23:59 2011
New Revision: 1080436

URL: http://svn.apache.org/viewvc?rev=1080436&view=rev
Log:
Apply the patch for WINK-339 from myself as the first commit

Added:
    incubator/wink/trunk/wink-component-test-support/src/test/
    incubator/wink/trunk/wink-component-test-support/src/test/java/
    incubator/wink/trunk/wink-component-test-support/src/test/java/org/
    incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/
    incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/
    incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/
    incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/
    incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java   (with props)

Added: incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java?rev=1080436&view=auto
==============================================================================
--- incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java (added)
+++ incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java Fri Mar 11 04:23:59 2011
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.test.mock;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class MockHttpServletRequestWrapperTestCase {
+    @Test
+    public void testContentType() {
+        HttpServletRequest req =
+            MockRequestConstructor.constructMockRequest("POST",
+                                                        "/test",
+                                                        "application/json",
+                                                        "application/x-www-form-urlencoded",
+                                                        null);
+        Assert.assertEquals("application/x-www-form-urlencoded", req.getContentType());
+        Assert.assertEquals("application/json", req.getHeader("Accept"));
+    }
+
+    @Test
+    public void testParameter() throws Exception {
+        HttpServletRequest req =
+            MockRequestConstructor.constructMockRequest("POST",
+                                                        "/test",
+                                                        "application/json",
+                                                        "application/x-www-form-urlencoded",
+                                                        "x=1&y=2&z=%20".getBytes("UTF-8"));
+        String x = req.getParameter("x");
+        String y = req.getParameter("y");
+        String z = req.getParameter("z");
+        String a = req.getParameter("a");
+
+        Assert.assertEquals("1", x);
+        Assert.assertEquals("2", y);
+        Assert.assertEquals(" ", z);
+        Assert.assertNull(a);
+
+        Assert.assertEquals(3, req.getParameterMap().size());
+    }
+}
+

Propchange: incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/wink/trunk/wink-component-test-support/src/test/java/org/apache/wink/test/mock/MockHttpServletRequestWrapperTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date