You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/09/02 14:25:40 UTC

svn commit: r991908 - in /click/trunk/click/framework/test: org/apache/click/PageTest.java org/apache/click/pages/RequestBindingPage.java web/request-binding-page.htm

Author: sabob
Date: Thu Sep  2 12:25:39 2010
New Revision: 991908

URL: http://svn.apache.org/viewvc?rev=991908&view=rev
Log:
added test for binding page variables to request parameters

Added:
    click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java
    click/trunk/click/framework/test/web/request-binding-page.htm
Modified:
    click/trunk/click/framework/test/org/apache/click/PageTest.java

Modified: click/trunk/click/framework/test/org/apache/click/PageTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/PageTest.java?rev=991908&r1=991907&r2=991908&view=diff
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/PageTest.java (original)
+++ click/trunk/click/framework/test/org/apache/click/PageTest.java Thu Sep  2 12:25:39 2010
@@ -25,7 +25,9 @@ import org.apache.click.pages.JspRedirec
 import org.apache.click.pages.RedirectToHtm;
 import org.apache.click.pages.RedirectToJsp;
 import org.apache.click.pages.RedirectToSelfPage;
+import org.apache.click.pages.RequestBindingPage;
 import org.apache.click.pages.SetPathToJspPage;
+import org.apache.click.servlet.MockRequest;
 
 /**
  * Tests for the Page class.
@@ -238,4 +240,29 @@ public class PageTest extends TestCase {
 
         container.stop();
     }
+
+    /**
+     * Check that Page variables are bound to request parameters.
+     */
+    public void testRequestParameterBinding() {
+        MockContainer container = new MockContainer("web");
+        container.start();
+
+        MockRequest request = container.getRequest();
+        String bigDecimalValue = "100.99";
+        String stringValue = "hello";
+        String boolValue = "true";
+
+        request.setParameter("bigDecimal", bigDecimalValue);
+        request.setParameter("string", stringValue);
+        request.setParameter("bool", boolValue);
+
+        RequestBindingPage page = container.testPage(RequestBindingPage.class);
+
+        assertEquals(bigDecimalValue.toString(), page.getBigDecimal().toString());
+        assertEquals(stringValue, page.getString());
+        assertEquals(boolValue, Boolean.toString(page.getBoolean()));
+
+        container.stop();
+    }
 }

Added: click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java?rev=991908&view=auto
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java (added)
+++ click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java Thu Sep  2 12:25:39 2010
@@ -0,0 +1,50 @@
+/*
+ * 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.click.pages;
+
+import java.math.BigDecimal;
+import org.apache.click.Page;
+import org.apache.click.util.Bindable;
+
+/**
+ * Page with bindable variables for testing that request parameters are bound to
+ * Page variables.
+ */
+public class RequestBindingPage extends Page {
+    private static final long serialVersionUID = 1L;
+
+    @Bindable private BigDecimal bigDecimal = BigDecimal.ZERO;
+    public String string = "";
+    @Bindable private boolean bool = false;
+
+    public RequestBindingPage() {
+    }
+
+    public BigDecimal getBigDecimal() {
+        return bigDecimal;
+    }
+
+    public String getString() {
+        return string;
+    }
+
+    public boolean getBoolean() {
+        return bool;
+    }
+}

Added: click/trunk/click/framework/test/web/request-binding-page.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/web/request-binding-page.htm?rev=991908&view=auto
==============================================================================
--- click/trunk/click/framework/test/web/request-binding-page.htm (added)
+++ click/trunk/click/framework/test/web/request-binding-page.htm Thu Sep  2 12:25:39 2010
@@ -0,0 +1,18 @@
+<!--
+   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.
+-->