[embjopr-commits] EMBJOPR SVN: r143 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as4 and 1 other directory.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Fri Feb 6 16:23:36 EST 2009


Author: ozizka at redhat.com
Date: 2009-02-06 16:23:36 -0500 (Fri, 06 Feb 2009)
New Revision: 143

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/
Log:
Added conversion of possibly double values from decimal coma to decimal dot.

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java	2009-02-06 20:18:26 UTC (rev 142)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java	2009-02-06 21:23:36 UTC (rev 143)
@@ -971,6 +971,7 @@
             String metricName = (String)i.next();
             String expected = metricsMap.get(metricName);
             String actual = getMetricValueFromTable(metricName, "dataTable");
+						actual = normalizeIfDoubleExpected(expected, actual); // Some LOCALEs encode doubles with coma.
             assertEquals("Incorrect metric value for '"+metricName+"'='"+actual+"'," +
                          " expected '"+expected+"'", expected, actual);
         }
@@ -987,6 +988,7 @@
             String metricName = (String)i.next();
             String expected = metricsMap.get(metricName);
             String actual = getMetricValueFromTable(metricName, "dataTable");
+						actual = normalizeIfDoubleExpected(expected, actual); // Some LOCALEs encode doubles with coma.
             assertEquals("Incorrect summary metric value for '"+metricName+"'='"+actual+"'," +
 										" expected '"+expected+"'", expected, actual);
         }

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java	2009-02-06 20:18:26 UTC (rev 142)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java	2009-02-06 21:23:36 UTC (rev 143)
@@ -564,6 +564,40 @@
         }
 
     }
+
+
+		/**
+		 * Checks whether given string looks like a double in terms of Java's Double,
+		 * i.e. /<digit>+(\.<digit>+)?/
+		 * @param value  The string to check.
+		 * @returns true if the
+		 */
+		protected boolean looksLikeDouble(String value) {
+			try{
+				Double.parseDouble(value);
+			}catch(NumberFormatException ex){
+				return false;
+			}
+			return true;
+		}
+
+		/**
+		 * If both expected and actual string look like a double,
+		 * returns normalized double (with a decimal dot);
+		 * Otherwise, returns original actual value.
+		 * @param expected
+		 * @param actual
+		 */
+		protected String normalizeIfDoubleExpected(String expected, String actual) {
+			//return looksLikeDouble(expected) ? actual.replace(',', '.') : actual;
+
+			if( !looksLikeDouble(expected) )
+				return actual;
+
+			String converted = actual.replace(',', '.');
+			return looksLikeDouble(converted) ? converted : actual;
+		}
+
 		
 }
 


Property changes on: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4
___________________________________________________________________
Name: svn:ignore
   + HelloJoprTest.java
ManipulationTest.java
ClientUtil.java





More information about the embjopr-commits mailing list