IDEMPIERE-92 Implement Selenium testing framework. Added evaluate method for integration with selenium test using dynamic variables.

This commit is contained in:
Heng Sin Low 2013-03-26 17:02:48 +08:00
parent 9e0d59f543
commit bf14ca9958
1 changed files with 15 additions and 4 deletions

View File

@ -105,6 +105,7 @@ public class Util {
if (cell_value.toLowerCase().startsWith("@sql=")) {
String sqlcmd = Env.parseContext(ctx, windowNo, lowerContextTableColumn(cell_value.substring(5)), false, false);
String newval = DB.getSQLValueStringEx(null, sqlcmd);
if (parse != null)
parse.addToBody("<hr/>" + newval);
if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval);
return newval;
@ -120,6 +121,7 @@ public class Util {
String whereParsed = Env.parseContext(ctx, windowNo, where, false);
String columnname = cell_value.substring(pos_clsqb+2);
String newval = DB.getSQLValueStringEx(null, "SELECT " + columnname + " FROM " + tablename + " WHERE " + whereParsed);
if (parse != null)
parse.addToBody("<hr/>" + newval);
if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval);
return newval;
@ -131,6 +133,7 @@ public class Util {
String newval = Env.getContext(ctx, windowNo, cell_value.substring(1, cell_value.length()-1));
if (newval == null)
return cell_value;
if (parse != null)
parse.addToBody("<hr/>" + newval);
if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval);
return newval;
@ -191,6 +194,7 @@ public class Util {
String newval = randomstr.toString();
if (newval == null)
return cell_value;
if (parse != null)
parse.addToBody("<hr/>" + newval);
if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval);
return newval;
@ -239,4 +243,11 @@ public class Util {
} // parseContext
public static String evaluate(String expr) {
Instance adempiereInstance = Static_iDempiereInstance.getInstance();
Properties ctx = adempiereInstance.getAdempiereService().getCtx();
int windowNo = adempiereInstance.getAdempiereService().getWindowNo();
return evaluate(ctx, windowNo, expr, null);
}
} // AdempiereUtil