1. opensymphony
  2. xwork

Commits

davsclaus  committed c9311a9

improved unit test

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@955e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits a96e1a0
  • Branches master

Comments (0)

Files changed (1)

File src/test/com/opensymphony/xwork/util/TextParseUtilTest.java

View file
+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.xwork.util;
 
 import com.opensymphony.xwork.XWorkTestCase;
 import java.util.Arrays;
 
 /**
- * User: plightbo
- * Date: Aug 3, 2005
- * Time: 5:41:36 AM
+ * Unit test of {@link TextParseUtil}.
+ *
+ * @author plightbo
  */
 public class TextParseUtilTest extends XWorkTestCase {
+
     public void testTranslateVariables() {
         OgnlValueStack stack = new OgnlValueStack();
 
         assertEquals(new HashSet(Arrays.asList(new String[] { "foo", "bar", "tee" })),
                 TextParseUtil.commaDelimitedStringToSet(" foo, bar,tee"));
     }
+
+    public void testTranslateVariablesOpenChar() {
+        // just a quick test to see if the open char works
+        // most test are done the methods above
+        OgnlValueStack stack = new OgnlValueStack();
+
+        Object s = TextParseUtil.translateVariables('$', "foo: ${{1, 2, 3}}, bar: ${1}", stack);
+        assertEquals("foo: [1, 2, 3], bar: 1", s);
+
+        Object s2 = TextParseUtil.translateVariables('#', "foo: #{{1, 2, 3}}, bar: #{1}", stack);
+        assertEquals("foo: [1, 2, 3], bar: 1", s2);
+    }
+
+    public void testTranslateNoVariables() {
+        OgnlValueStack stack = new OgnlValueStack();
+
+        Object s = TextParseUtil.translateVariables('$', "foo: ${}", stack);
+        assertEquals("foo: ", s);
+    }
+
 }