Author: scabanovich
Date: 2008-10-08 10:07:16 -0400 (Wed, 08 Oct 2008)
New Revision: 10744
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
Log:
JBIDE-1497.
Tests added
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2008-10-08
14:06:11 UTC (rev 10743)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2008-10-08
14:07:16 UTC (rev 10744)
@@ -23,6 +23,7 @@
TestSuite suite = new TestSuite();
suite.setName("All tests for " + PLUGIN_ID);
suite.addTestSuite(ELParserTest.class);
+ suite.addTestSuite(ELModelTest.class);
return suite;
}
}
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java 2008-10-08
14:07:16 UTC (rev 10744)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.test;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELMethodInvocation;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELMultiExpression;
+import org.jboss.tools.common.el.core.model.ELObject;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.model.ELParameters;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+
+import junit.framework.TestCase;
+
+public class ELModelTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ }
+
+ public void testELModel() {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ String el = "#{a.b(c.d(),\"ooo\",s['h'])}xx#{(18 + a) * d +
14}";
+ ELModel model = parser.parse(el);
+
+ List<ELInstance> instances = model.getInstances();
+
+ assertEquals(2, instances.size());
+
+ ELInstance instance_1 = instances.get(0);
+ ELExpression expr1 = instance_1.getExpression();
+ assertTrue(expr1 instanceof ELMethodInvocation);
+
+ ELMethodInvocation method1 = (ELMethodInvocation)expr1;
+ ELParameters paramsObject1 = method1.getParameters();
+ List<ELExpression> paramsList1 = paramsObject1.getParameters();
+ assertEquals(3, paramsList1.size());
+
+ ELExpression param_1_1 = paramsList1.get(0);
+ assertEquals(ELObjectType.EL_METHOD_INVOCATION, param_1_1.getType());
+
+ ELExpression param_1_2 = paramsList1.get(1);
+ assertEquals(ELObjectType.EL_VALUE, param_1_2.getType());
+
+ ELExpression param_1_3 = paramsList1.get(2);
+ assertEquals(ELObjectType.EL_ARGUMENT_INVOCATION, param_1_3.getType());
+
+
+ ELInstance instance_2 = instances.get(1);
+ ELExpression expr2 = instance_2.getExpression();
+ assertEquals(ELObjectType.EL_MULTI_EXPRESSION, expr2.getType());
+
+ List<ELExpression> exprList2 = ((ELMultiExpression)expr2).getExpressions();
+ assertEquals(3, exprList2.size());
+ ELExpression expr_2_1 = exprList2.get(0);
+ assertEquals(ELObjectType.EL_COMPLEX_EXPRESSION, expr_2_1.getType());
+ }
+
+}
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-10-08
14:06:11 UTC (rev 10743)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-10-08
14:07:16 UTC (rev 10744)
@@ -140,6 +140,21 @@
checkCorrectEL(t,"#{true}");
checkCorrectEL(t,"#{false}");
}
+
+ public void testComplexMath() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t, "#{(7 * (13 + 7.9)) * (a + b.c / d) / (1.E5) -
(1/a.b+8./c.d)}");
+ }
+
+ public void testComplexInvocation() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t,
"#{a.b[a1.b1(a2.b2,a3.b3(x))][y].c(a4.b4,a5.b5[a6(b6)])}");
+ }
+
+ public void testSeveralELInstances() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t, "aaa#{a}bbb#{1}#{c()}");
+ }
private void checkCorrectEL(Tokenizer t, String test) {
LexicalToken token = t.parse(test);
@@ -155,7 +170,7 @@
checkIncorrectEL(t, "#{a.}", 4);
//2. Incorrect use of ')'
checkIncorrectEL(t, "#{a.b + -c.d + g)}", 16);
- //2. Incorrect use of ')' in second EL instance
+ //2. Incorrect use of '.' in second EL instance
checkIncorrectEL(t, "#{a.b + -c.d + g}#{hh.vv..m()}", 25);
}