Author: ozizka(a)redhat.com
Date: 2009-07-24 15:02:36 -0400 (Fri, 24 Jul 2009)
New Revision: 585
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
* JBossCacheTest updated
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-24
17:02:05 UTC (rev 584)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-24
19:02:36 UTC (rev 585)
@@ -829,7 +829,7 @@
* @param value The string to check.
* @returns true if the
*/
- protected boolean looksLikeDouble(String value) {
+ public static boolean looksLikeDouble(String value) {
try{
Double.parseDouble(value);
}catch(NumberFormatException ex){
@@ -845,7 +845,7 @@
* @param expected
* @param actual
*/
- protected String normalizeIfDoubleExpected(String expected, String actual) {
+ public static String normalizeIfDoubleExpected(String expected, String actual) {
//return looksLikeDouble(expected) ? actual.replace(',', '.') :
actual;
if( !looksLikeDouble(expected) )
@@ -854,12 +854,35 @@
String converted = actual.replace(',', '.');
return looksLikeDouble(converted) ? converted : actual;
}
+
+
+
+ /** Converts a decimal number in either english or german notation to Java-like
double. */
+ public static String normalizeIfNumber( String val ){
+ String val2 = val.replace(",", "");
+ // English notation - 1,322.51
+ if( EmbjoprTestCase.looksLikeDouble(val2) )
+ return val2;
+
+ // Still can be numbe: 1 358,84
+ val2 = val.replace(" ", "");
+ val2 = val.replace(" ", "").replace(',', '.');
+ if( EmbjoprTestCase.looksLikeDouble(val2) )
+ return val2;
+
+ return val;
+ }
+
+
+
+
+
/**
* Transform the given map of Strings to MetaValues into a
* map of Strings to Strings.
*/
- protected Map<String, String> formatPropertiesMap(Map<String, MetaValue>
propertiesMap) {
+ protected static Map<String, String> formatPropertiesMap(Map<String,
MetaValue> propertiesMap) {
Map<String, String> formattedPropertiesMap = new HashMap<String,
String>();
for(String propertyName : propertiesMap.keySet()) {
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-24
17:02:05 UTC (rev 584)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-24
19:02:36 UTC (rev 585)
@@ -7,7 +7,6 @@
import java.net.UnknownHostException;
import java.util.*;
-import java.util.logging.Level;
import javax.management.MalformedObjectNameException;
import javax.naming.NamingException;
import org.jboss.jopr.jsfunit.exceptions.*;
@@ -30,7 +29,6 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.jboss.jopr.jsfunit.AppConstants;
@@ -1198,6 +1196,9 @@
return props;
}
+ /**
+ * Calls getProperties( key, value ) with default column names (Name and Value).
+ */
public Properties getProperties() throws HtmlElementNotFoundException {
return this.getProperties(EmbJoprTestConstants.COL_PROP_NAME,
EmbJoprTestConstants.COL_PROP_VALUE);
}
@@ -1225,6 +1226,10 @@
log.info("Checking '"+propName+"'...");
String exp = propsExpected.getProperty(propName);
String act = propsActual.getProperty(propName);
+
+ exp = EmbjoprTestCase.normalizeIfNumber(exp);
+ act = EmbjoprTestCase.normalizeIfNumber(act);
+
if( !StringUtils.equals( exp, act ) ){
// If this table has a name, use it in the exception message.
String msgFormat = (null == this.getTableName() ? "%2$s: expected
'%3$s', actual '%4$s'." : "%s - %s: expected '%s',
actual '%s'.");
@@ -1234,6 +1239,7 @@
}
+
}// inner class ContentTable
Show replies by date