TAP5-736: add a test to ensure that null is not accepted as a TextField's validate parameter
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/875ca1c0 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/875ca1c0 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/875ca1c0 Branch: refs/heads/master Commit: 875ca1c0bd8aff462715315ec668dd9e23c2560a Parents: c8bf6f9 Author: Jochen Kemnade <jochen.kemn...@eddyson.de> Authored: Mon Aug 18 12:34:03 2014 +0200 Committer: Jochen Kemnade <jochen.kemn...@eddyson.de> Committed: Mon Aug 18 12:34:03 2014 +0200 ---------------------------------------------------------------------- .../app1/TextFieldWithNullValidateParameter.tml | 11 ++++++++++ .../tapestry5/integration/app1/FormTests.java | 11 ++++++++++ .../tapestry5/integration/app1/pages/Index.java | 4 +++- .../TextFieldWithNullValidateParameter.java | 23 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml b/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml new file mode 100644 index 0000000..21059d7 --- /dev/null +++ b/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml @@ -0,0 +1,11 @@ +<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> + + <t:form> + <t:errors/> + + <t:textfield value="literal:foobar" validate="prop:nullvalidate"/> + + </t:form> + + +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java index 58f252a..70f77e7 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java @@ -1219,4 +1219,15 @@ public class FormTests extends App1TestCase assertEquals("text", getAttribute("emailValidator@type")); // if HTML5 support was enabled, this would be "email" } + /** TAP5-736 **/ + @Test + public void textfield_requires_non_null_validate_parameter() throws Exception + { + openLinks("TextField with null validate parameter"); + if(isTextPresent("java.lang.NullPointerException")){ + reportAndThrowAssertionError("Unexpected NullPointerException was thrown"); + } + assertTextPresent("This parameter is not allowed to be null."); + } + } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java index 42a4ffa..ae49e59 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java @@ -578,7 +578,9 @@ public class Index new Item("FormFieldClientIdParameterDemo", "Form Field clientId Parameter Demo", "Shows and tests how to explicitly set the id of a form field component"), - new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context") + new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context"), + + new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null") ); static http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java new file mode 100644 index 0000000..e116497 --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java @@ -0,0 +1,23 @@ +// Copyright 2008 The Apache Software Foundation +// +// Licensed 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.tapestry5.integration.app1.pages; + + +public class TextFieldWithNullValidateParameter { + + public Object getNullValidate() { + return null; + } +}