You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2010/05/25 00:41:51 UTC

svn commit: r947842 - in /poi/trunk/src/testcases/org/apache/poi: hssf/record/formula/functions/TestText.java ss/format/CellFormatTestBase.java

Author: josh
Date: Mon May 24 22:41:51 2010
New Revision: 947842

URL: http://svn.apache.org/viewvc?rev=947842&view=rev
Log:
Changed JRE 6 dependent code to its JRE 5 equivalent

Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java
    poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java?rev=947842&r1=947841&r2=947842&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java Mon May 24 22:41:51 2010
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.record.formu
 import java.text.DecimalFormatSymbols;
 import java.text.SimpleDateFormat;
 import java.util.GregorianCalendar;
+import java.util.Locale;
 
 import junit.framework.TestCase;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
@@ -34,7 +35,7 @@ import org.apache.poi.hssf.record.formul
  */
 public final class TestText extends TestCase {
 	private static final TextFunction T = null;
-	
+
 	public void testTextWithStringFirstArg() {
 
 		ValueEval strArg = new StringEval("abc");
@@ -43,32 +44,32 @@ public final class TestText extends Test
 		ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
 		assertEquals(ErrorEval.VALUE_INVALID, result);
 	}
-	
+
 	public void testTextWithDeciamlFormatSecondArg() {
 
 		ValueEval numArg = new NumberEval(321321.321);
 		ValueEval formatArg = new StringEval("#,###.00000");
 		ValueEval[] args = { numArg, formatArg };
 		ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
-		char groupSeparator = DecimalFormatSymbols.getInstance().getGroupingSeparator();
-		char decimalSeparator = DecimalFormatSymbols.getInstance().getDecimalSeparator();
+		char groupSeparator = new DecimalFormatSymbols(Locale.getDefault()).getGroupingSeparator();
+		char decimalSeparator = new DecimalFormatSymbols(Locale.getDefault()).getDecimalSeparator();
 		ValueEval testResult = new StringEval("321" + groupSeparator + "321" + decimalSeparator + "32100");
 		assertEquals(testResult.toString(), result.toString());
 		numArg = new NumberEval(321.321);
 		formatArg = new StringEval("00000.00000");
-		args[0] = numArg; 
-		args[1] = formatArg; 
+		args[0] = numArg;
+		args[1] = formatArg;
 		result = T.TEXT.evaluate(args, -1, (short)-1);
 		testResult = new StringEval("00321" + decimalSeparator + "32100");
 		assertEquals(testResult.toString(), result.toString());
-		
+
 		formatArg = new StringEval("$#.#");
-		args[1] = formatArg; 
+		args[1] = formatArg;
 		result = T.TEXT.evaluate(args, -1, (short)-1);
 		testResult = new StringEval("$321" + decimalSeparator + "3");
 		assertEquals(testResult.toString(), result.toString());
 	}
-	
+
 	public void testTextWithFractionFormatSecondArg() {
 
 		ValueEval numArg = new NumberEval(321.321);
@@ -77,20 +78,20 @@ public final class TestText extends Test
 		ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
 		ValueEval testResult = new StringEval("321 1/3");
 		assertEquals(testResult.toString(), result.toString());
-		
+
 		formatArg = new StringEval("# #/##");
-		args[1] = formatArg; 
+		args[1] = formatArg;
 		result = T.TEXT.evaluate(args, -1, (short)-1);
 		testResult = new StringEval("321 26/81");
 		assertEquals(testResult.toString(), result.toString());
-		
+
 		formatArg = new StringEval("#/##");
-		args[1] = formatArg; 
+		args[1] = formatArg;
 		result = T.TEXT.evaluate(args, -1, (short)-1);
 		testResult = new StringEval("26027/81");
 		assertEquals(testResult.toString(), result.toString());
 	}
-	
+
 	public void testTextWithDateFormatSecondArg() {
 
 		ValueEval numArg = new NumberEval(321.321);
@@ -99,16 +100,14 @@ public final class TestText extends Test
 		ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
 		ValueEval testResult = new StringEval("16:11:1900 07:42:14");
 		assertEquals(testResult.toString(), result.toString());
-		
-        // this line is intended to compute how "November" would look like in the current locale
-        String november = new SimpleDateFormat("MMMM").format(new GregorianCalendar(2010,10,15).getTime());
-		
+
+		// this line is intended to compute how "November" would look like in the current locale
+		String november = new SimpleDateFormat("MMMM").format(new GregorianCalendar(2010,10,15).getTime());
+
 		formatArg = new StringEval("MMMM dd, yyyy");
-		args[1] = formatArg; 
+		args[1] = formatArg;
 		result = T.TEXT.evaluate(args, -1, (short)-1);
 		testResult = new StringEval(november + " 16, 1900");
 		assertEquals(testResult.toString(), result.toString());
 	}
-	
-	
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java?rev=947842&r1=947841&r2=947842&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java Mon May 24 22:41:51 2010
@@ -104,7 +104,7 @@ public class CellFormatTestBase extends 
             String format = row.getCell(1).getStringCellValue();
             String testCategoryList = row.getCell(3).getStringCellValue();
             boolean byCategory = runByCategory(runCategories, testCategoryList);
-            if ((!expectedText.isEmpty() || !format.isEmpty()) && byCategory) {
+            if ((expectedText.length() > 0 || format.length() > 0) && byCategory) {
                 Cell cell = row.getCell(2);
                 tryFormat(r, expectedText, format, valueGetter, cell);
             }
@@ -290,4 +290,4 @@ public class CellFormatTestBase extends 
                             " = \"" + actual + "\" [not \"" + expected + "\"]");
         }
     }
-}
\ No newline at end of file
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org