Author: scabanovich
Date: 2008-09-23 11:42:06 -0400 (Tue, 23 Sep 2008)
New Revision: 10415
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath
trunk/common/tests/org.jboss.tools.common.el.core.test/.cvsignore
trunk/common/tests/org.jboss.tools.common.el.core.test/.project
trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/
trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
trunk/common/tests/org.jboss.tools.common.el.core.test/about.html
trunk/common/tests/org.jboss.tools.common.el.core.test/ant.properties
trunk/common/tests/org.jboss.tools.common.el.core.test/build.properties
trunk/common/tests/org.jboss.tools.common.el.core.test/info.xml
trunk/common/tests/org.jboss.tools.common.el.core.test/src/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/
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.
Initial import.
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath 2008-09-23 15:42:06
UTC (rev 10415)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/.cvsignore
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/.cvsignore
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/.cvsignore 2008-09-23 15:42:06
UTC (rev 10415)
@@ -0,0 +1 @@
+bin
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/.project
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/.project
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/.project 2008-09-23 15:42:06
UTC (rev 10415)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.common.el.core.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF 2008-09-23
15:42:06 UTC (rev 10415)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JSF Tests Plug-in
+Bundle-SymbolicName: org.jboss.tools.common.el.core.test;singleton:=true
+Bundle-Version: 2.0.0
+Bundle-ClassPath: common-el-tests.jar
+Bundle-Vendor: Red Hat, Inc.
+Export-Package: org.jboss.tools.common.el.core.test
+Require-Bundle:
+ org.junit,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.jboss.tools.common.el.core,
+ org.jboss.tools.common.test,
+ org.jboss.tools.tests
+Provide-Package: org.jboss.tools.common.el.core.test
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/about.html
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/about.html
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/about.html 2008-09-23 15:42:06
UTC (rev 10415)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+
+<BODY lang="EN-US">
+
+<H3>About This Content</H3>
+
+<P>©2007 Red Hat, Inc. All rights reserved</P>
+
+<H3>License</H3>
+
+<P>Red Hat Inc., through its JBoss division, makes available all content in this
plug-in
+("Content"). Unless otherwise indicated below, the Content is provided to you
+under the terms and conditions of the Eclipse Public License Version 1.0
+("EPL"). A copy of the EPL is available at
+<A
href="http://www.eclipse.org/org/documents/epl-v10.php">http...;.
+For purposes of the EPL, "Program" will mean the Content.</P>
+
+<P>If you did not receive this Content directly from Red Hat Inc., the
+Content is being redistributed by another party ("Redistributor") and different
+terms and conditions may apply to your use of any object code in the Content.
+Check the Redistributor's license that was provided with the Content. If no such
+license exists, contact the Redistributor. Unless otherwise indicated below, the
+terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at
+ <A
href="http://www.jboss.org/tools">http://www.jboss.org/tools...
+
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/ant.properties
===================================================================
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/build.properties
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/build.properties
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/build.properties 2008-09-23
15:42:06 UTC (rev 10415)
@@ -0,0 +1,14 @@
+bin.includes = plugin.xml,\
+ META-INF/,\
+ common-el-tests.jar,\
+ info.xml,\
+ projects/
+src.includes = META-INF/,\
+ ant.properties,\
+ build.properties,\
+ info.xml,\
+ plugin.xml,\
+ src/,\
+ test.xml
+source.common-el-tests.jar = src/
+jars.compile.order =
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/info.xml
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/info.xml
(rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/info.xml 2008-09-23 15:42:06
UTC (rev 10415)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin name="org.jboss.tools.common.model">
+ <classes>
+ <class path="/XModelEntityGroup/MAPPINGS/MAPPING/PAIR@value" />
+ <class path="/XModelEntityGroup/XModelEntity@AdoptManagerClass" />
+ <class path="/XModelEntityGroup/XModelEntity@ImplementationLoadingClass"
/>
+ <class path="/XModelEntityGroup/XModelEntity@ImplementingClass" />
+ </classes>
+</plugin>
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2008-09-23
15:42:06 UTC (rev 10415)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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 junit.framework.Test;
+import junit.framework.TestSuite;
+/**
+ * @author V.Kabanovich
+ *
+ */
+public class CommonELAllTests {
+ public static final String PLUGIN_ID = "org.jboss.tools.common.el.core";
+ //
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.setName("All tests for " + PLUGIN_ID);
+ suite.addTestSuite(ELParserTest.class);
+ return suite;
+ }
+}
Added:
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
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-09-23
15:42:06 UTC (rev 10415)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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.parser.LexicalToken;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+import org.jboss.tools.common.el.core.parser.TokenizerFactory;
+
+import junit.framework.TestCase;
+
+public class ELParserTest extends TestCase {
+
+ public ELParserTest() {}
+
+ protected void setUp() throws Exception {
+ }
+
+ public void testTokenizerOnCorrectEL() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+
+ //1. One variable
+ checkCorrectEL(t, "#{a}");
+ //2. Two EL instances
+ checkCorrectEL(t, "#{a}#{b}");
+ //3. Property invocation
+ checkCorrectEL(t, "#{a.b}");
+ //4. Argument invocation
+ checkCorrectEL(t, "#{a.b['xxx']}");
+ //5a. Method invocation
+ checkCorrectEL(t, "#{a.b()}");
+ //5b. Method invocation with one parameter
+ checkCorrectEL(t, "#{a.b(c)}");
+ //5b. Method invocation with two parameters
+ checkCorrectEL(t, "#{a.b(c.d , e['u'])}");
+ //6. Numeric
+ checkCorrectEL(t, "#{a.b(16.900)}");
+ //7. Boolean
+ checkCorrectEL(t, "#{a.b(false)}");
+ //8. Operators
+ checkCorrectEL(t, "#{a.b(7 + 8) * 4 / 2 - 1}");
+ //9. Complex expressions
+ checkCorrectEL(t, "#{a.b(7 + 8) * (4 / 2 - 1)/c.d}");
+ }
+
+ private void checkCorrectEL(Tokenizer t, String test) {
+ LexicalToken token = t.parse(test);
+ assertEquals(test, restore(token));
+ List<SyntaxError> errors = t.getErrors();
+ assertEquals("EL '" + test + "' has no syntax problems.",
0, errors.size());
+ System.out.println("Passed correct EL '" + test + "'");
+ }
+
+ public void testTokenizerOnIncorrectEL() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+
+ //1. Dot unfollowed by name
+ checkIncorrectEL(t, "#{a.}", 4);
+
+ //2. Incorrect use of ')'
+ checkIncorrectEL(t, "#{a.b + -c.d + g)}", 16);
+ //2. Incorrect use of ')' in second EL instance
+ checkIncorrectEL(t, "#{a.b + -c.d + g}#{hh.vv..m()}", 16);
+ }
+
+ private void checkIncorrectEL(Tokenizer t, String test, int expectedErrorPosition) {
+ LexicalToken token = t.parse(test);
+ List<SyntaxError> errors = t.getErrors();
+ assertTrue("EL '" + test + "' has syntax problems. ",
errors.size() > 0);
+ assertEquals(expectedErrorPosition, errors.get(0).getPosition());
+ String correctPart = test.substring(0, expectedErrorPosition);
+ String parsed = restore(token);
+ assertTrue("Parsed value should be identical to source at least until first
problem.", parsed.startsWith(correctPart));
+ System.out.println("Passed incorrect EL '" + test + "'");
+ }
+
+ private String restore(LexicalToken token) {
+ StringBuffer sb = new StringBuffer();
+ while(token != null) {
+ sb.append(token.getText());
+ token = token.getNextToken();
+ }
+ return sb.toString();
+ }
+
+}