You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/05/30 08:01:12 UTC
svn commit: r661572 [2/2] - in /geronimo/gshell/trunk: ./ gshell-assembly/
gshell-assembly/src/main/underlay/etc/ gshell-cli/ gshell-command-api/
gshell-command-api/src/main/java/org/apache/geronimo/gshell/ gshell-core/
gshell-core/src/main/java/org/ap...
Added: geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java?rev=661572&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java Thu May 29 23:01:10 2008
@@ -0,0 +1,104 @@
+/*
+ * 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.geronimo.gshell.expression;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the {@link JexlExpressionEvaluator} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JexlExpressionEvaluatorTest
+ extends TestCase
+{
+ protected JexlExpressionEvaluator evaluator;
+
+ protected void setUp() throws Exception {
+ evaluator = new JexlExpressionEvaluator(System.getProperties());
+ }
+
+ protected void tearDown() throws Exception {
+ evaluator = null;
+ }
+
+ public void testComplexDefault() throws Exception {
+ String value = "${java.home}";
+ String result = evaluator.parse(value);
+ assertEquals(System.getProperty("java.home"), result);
+ }
+
+ public void testComplexSubst() throws Exception {
+ String value = "BEFORE${java.home}AFTER";
+ String result = evaluator.parse(value);
+ assertEquals("BEFORE" + System.getProperty("java.home") + "AFTER", result);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void testComplexVariable() throws Exception {
+ String myvar = "this is my variable";
+ evaluator.getVariables().put("my.var", myvar);
+
+ String value = "${my.var}";
+ String result = evaluator.parse(value);
+ assertEquals(myvar, result);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void testComplexFlatVariable() throws Exception {
+ String myvar = "this is my variable";
+ evaluator.getVariables().put("my.var", myvar);
+ evaluator.getVariables().put("my", "not used");
+
+ String value = "${my.var}";
+ String result = evaluator.parse(value);
+ assertEquals(myvar, result);
+ }
+
+ public void testComplexSyntaxError() throws Exception {
+ String value = "${java.home";
+
+ try {
+ evaluator.parse(value);
+ fail("Should have thrown an exception");
+ }
+ catch (ExpressionEvaluator.SyntaxException expected) {
+ // ignore
+ }
+ }
+
+ public void testSimple() throws Exception {
+ String value = "$java.home";
+ String result = evaluator.parse(value);
+ assertEquals(System.getProperty("java.home"), result);
+ }
+
+ public void testSimpleSubst() throws Exception {
+ String value = "BEFORE$java.home AFTER";
+ String result = evaluator.parse(value);
+ assertEquals("BEFORE" + System.getProperty("java.home") + " AFTER", result);
+ }
+
+ public void testSimpleSubst2() throws Exception {
+ String value = "BEFORE$java.home\tAFTER";
+ String result = evaluator.parse(value);
+ assertEquals("BEFORE" + System.getProperty("java.home") + "\tAFTER", result);
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-expr/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-support/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/pom.xml?rev=661572&r1=661571&r2=661572&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-support/pom.xml Thu May 29 23:01:10 2008
@@ -48,6 +48,7 @@
<module>gshell-io</module>
<module>gshell-prefs</module>
<module>gshell-plexus</module>
+ <module>gshell-expr</module>
</modules>
</project>
\ No newline at end of file
Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=661572&r1=661571&r2=661572&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Thu May 29 23:01:10 2008
@@ -326,6 +326,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.geronimo.gshell.support</groupId>
+ <artifactId>gshell-expr</artifactId>
+ <version>1.0-alpha-2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.geronimo.gshell</groupId>
<artifactId>gshell-command-api</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
@@ -342,7 +348,13 @@
<artifactId>gshell-model</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-loader</artifactId>
+ <version>1.0-alpha-2-SNAPSHOT</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.geronimo.gshell</groupId>
<artifactId>gshell-core</artifactId>
@@ -450,6 +462,7 @@
<module>gshell-bootstrap</module>
<module>gshell-model</module>
<module>gshell-command-api</module>
+ <module>gshell-loader</module>
<module>gshell-parser</module>
<module>gshell-core</module>
<module>gshell-cli</module>