geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r514273 - /geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
Date Sat, 03 Mar 2007 23:37:03 GMT
Author: jdillon
Date: Sat Mar  3 15:37:02 2007
New Revision: 514273

URL: http://svn.apache.org/viewvc?view=rev&rev=514273
Log:
Add tests for ExpressionParser (resurrected from ancient cvs incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/Attic/StringValueParserTest.java,v)

Added:
    geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
  (with props)

Added: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java?view=auto&rev=514273
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
(added)
+++ geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
Sat Mar  3 15:37:02 2007
@@ -0,0 +1,88 @@
+/**
+ *  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.system.configuration.condition;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the {@link ExpressionParser} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExpressionParserTest
+    extends TestCase
+{
+    protected ExpressionParser parser;
+    
+    /**
+     * Set up instance variables required by this test case.
+     */
+    protected void setUp() {
+        parser = new ExpressionParser();
+    }
+    
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    protected void tearDown() {
+        parser = null;
+    }
+    
+    
+    public void testDefault() throws Exception {
+        String value = "${java.home}";
+        String result = parser.parse(value);
+        assertEquals(result, System.getProperty("java.home"));
+    }
+    
+    public void testSubst() throws Exception {
+        String value = "BEFORE${java.home}AFTER";
+        String result = parser.parse(value);
+        assertEquals(result, "BEFORE" + System.getProperty("java.home") + "AFTER");
+    }
+    
+    public void testVariable() throws Exception {
+        String myvar = "this is my variable";
+        parser.getVariables().put("my.var", myvar);
+        
+        String value = "${my.var}";
+        String result = parser.parse(value);
+        assertEquals(result, myvar);
+    }
+    
+    public void testFlatVariable() throws Exception {
+        String myvar = "this is my variable";
+        parser.getVariables().put("my.var", myvar);
+        parser.getVariables().put("my", "not used");
+        
+        String value = "${my.var}";
+        String result = parser.parse(value);
+        assertEquals(result, myvar);
+    }
+    
+    public void testSyntax() throws Exception {
+        String value = "${java.home";
+            
+        try {
+            String result = parser.parse(value);
+            assertTrue("Should have thrown an exception", false);
+        }
+        catch (Exception ignore) {}
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/ExpressionParserTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message