Repository: wicket
Updated Branches:
  refs/heads/WICKET-4008-property-expression-parser cd96fb1c5 -> 2f302dbfd


WICKET-4008 property expression parser implementation

Add some weird test cases


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/2f302dbf
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2f302dbf
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2f302dbf

Branch: refs/heads/WICKET-4008-property-expression-parser
Commit: 2f302dbfdc7bd60afca76bccbfac81ccbcbf6af1
Parents: cd96fb1
Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Authored: Tue Sep 20 22:33:13 2016 +0200
Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Committed: Tue Sep 20 22:33:13 2016 +0200

----------------------------------------------------------------------
 .../util/lang/PropertyExpressionParser.java     |  6 +++---
 .../util/lang/PropertyExpressionParserTest.java | 22 +++++++++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/2f302dbf/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java
 
b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java
index 4588218..08fd061 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java
@@ -98,7 +98,7 @@ public class PropertyExpressionParser
                        case END_OF_EXPRESSION :
                                return expression;
                        default :
-                               throw new ParserException("expecting a new 
expression but got: " + currentToken);
+                               throw new ParserException("expecting a new 
expression but got: '" + currentToken + "'");
                }
        }
 
@@ -164,9 +164,9 @@ public class PropertyExpressionParser
        {
                if (lookaheadToken != ')')
                {
-                       throw new ParserException("expecting a method sign but 
got: " + currentToken);
+                       throw new ParserException("expecting a method sign but 
got: '" + currentToken + "'");
                }
                advance();// skips right bracket
                return true;
        }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/2f302dbf/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java
index 96d3739..d6c2803 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java
@@ -3,11 +3,9 @@ package org.apache.wicket.core.util.lang;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
-import org.apache.wicket.core.util.lang.ParserException;
-import org.apache.wicket.core.util.lang.PropertyExpression;
-import org.apache.wicket.core.util.lang.PropertyExpressionParser;
 import org.apache.wicket.core.util.lang.PropertyExpression.Property;
 import org.hamcrest.CoreMatchers;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -35,6 +33,24 @@ public class PropertyExpressionParserTest
                assertThat(parse.next, CoreMatchers.nullValue());
        }
 
+       // TODO mgrigorov: @pedrosans: I'd expect the error message to complain 
about the space, not 'r'
+       @Test
+       public void shouldFailParsePropertyExpressionsWithSpace()
+       {
+               expectedException.expect(ParserException.class);
+               expectedException
+                               .expectMessage("expecting a new expression but 
got: ' '");
+               parser.parse("per son");
+       }
+
+       // TODO mgrigorov: @pedrosans: IMO this should pass. Or otherwise 
should complain about the space, not '('
+       @Test
+       public void shouldParsePropertyExpressionsWithSpaceInMethod()
+       {
+               final PropertyExpression parse = parser.parse("person( )");
+               assertThat(parse.property, is(new Property("person", null, 
true)));
+       }
+
        @Test
        public void shouldParseIndexedPropertyExpressions()
        {

Reply via email to