Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java Mon Aug 17 11:01:25 2009 @@ -37,21 +37,21 @@ public class GroovyRunner { - private String urlName; - private SeleniumXml parent; - private SeleniumXml currentTest; - - private int currentRowIndx; + private String urlName; + private SeleniumXml parent; + private SeleniumXml currentTest; + + private int currentRowIndx; public static GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); - - - public GroovyRunner(String urlName, SeleniumXml parent) { - super(); - this.urlName = urlName; - this.parent = parent; - } + + + public GroovyRunner(String urlName, SeleniumXml parent) { + super(); + this.urlName = urlName; + this.parent = parent; + } - public void runTest() { + public void runTest() { Map map = this.parent.getMap(); map.put("url", this.urlName); @@ -69,7 +69,7 @@ System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage()); } - - } + + } } Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java Mon Aug 17 11:01:25 2009 @@ -33,45 +33,45 @@ */ public class InitJython { -// public Logger logger = Logger.getLogger(InitJython.class.getName()); - - private static PythonInterpreter SINGLETON; - - /** Only allow creation through the factory method */ - protected InitJython() { -// logger.setLevel(Level.DEBUG); - } - - /** - * getInterpreter initializes the Python environment the first time. It then issues a - * new Interpreter for each request. - * @return PythonInterpreter - */ - public static PythonInterpreter getInterpreter() { - - if (SINGLETON == null) { - synchronized (InitJython.class) { - Properties props = System.getProperties(); - //String ofbizHome = props.getProperty("ofbiz.home"); - - Properties pyProps = new Properties(); - - if (props.getProperty("python.home") == null) { - //pyProps.setProperty("python.home", "c:/devtools/jython2.2rc2"); - pyProps.setProperty("python.home", "c:/devtools/Python24"); - } - - //Debug.logInfo(props.toString(), module); - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - PySystemState.initialize(props, pyProps, new String[0], loader); - - SINGLETON = new PythonInterpreter(); - - SINGLETON.exec("import sys"); - SINGLETON.exec("sys.path.append(\"c:/dev/ag/seleniumXml/plugins\")"); - } - } - - return SINGLETON; +// public Logger logger = Logger.getLogger(InitJython.class.getName()); + + private static PythonInterpreter SINGLETON; + + /** Only allow creation through the factory method */ + protected InitJython() { +// logger.setLevel(Level.DEBUG); + } + + /** + * getInterpreter initializes the Python environment the first time. It then issues a + * new Interpreter for each request. + * @return PythonInterpreter + */ + public static PythonInterpreter getInterpreter() { + + if (SINGLETON == null) { + synchronized (InitJython.class) { + Properties props = System.getProperties(); + //String ofbizHome = props.getProperty("ofbiz.home"); + + Properties pyProps = new Properties(); + + if (props.getProperty("python.home") == null) { + //pyProps.setProperty("python.home", "c:/devtools/jython2.2rc2"); + pyProps.setProperty("python.home", "c:/devtools/Python24"); + } + + //Debug.logInfo(props.toString(), module); + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + PySystemState.initialize(props, pyProps, new String[0], loader); + + SINGLETON = new PythonInterpreter(); + + SINGLETON.exec("import sys"); + SINGLETON.exec("sys.path.append(\"c:/dev/ag/seleniumXml/plugins\")"); + } + } + + return SINGLETON; } } Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java Mon Aug 17 11:01:25 2009 @@ -38,20 +38,20 @@ public class JythonRunner { - private String urlName; - private SeleniumXml parent; - private SeleniumXml currentTest; - - private int currentRowIndx; - - - public JythonRunner(String urlName, SeleniumXml parent) { - super(); - this.urlName = urlName; - this.parent = parent; - } + private String urlName; + private SeleniumXml parent; + private SeleniumXml currentTest; + + private int currentRowIndx; + + + public JythonRunner(String urlName, SeleniumXml parent) { + super(); + this.urlName = urlName; + this.parent = parent; + } - public void runTest() { + public void runTest() { PythonInterpreter interp = InitJython.getInterpreter(); @@ -67,7 +67,7 @@ System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage()); } - - } + + } } Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java Mon Aug 17 11:01:25 2009 @@ -42,142 +42,142 @@ public class SeleniumIDEConverter { - private Document ideFile; - private Element xmlDestRoot; + private Document ideFile; + private Element xmlDestRoot; - private Namespace ns = Namespace.getNamespace("http://www.w3.org/1999/xhtml"); - private Map root; + private Namespace ns = Namespace.getNamespace("http://www.w3.org/1999/xhtml"); + private Map root; - public void convert(String ideFile, String xmlFile) throws JDOMException, IOException, SAXException, ParserConfigurationException { + public void convert(String ideFile, String xmlFile) throws JDOMException, IOException, SAXException, ParserConfigurationException { - readInputFile(ideFile); - - convertIDECommands(); - - createSeleniumXml(xmlFile); - } - - - private void readInputFile(String input) throws JDOMException, IOException, SAXException, ParserConfigurationException { - - File xmlFile = new File(input); - SAXBuilder builder = new SAXBuilder(); - this.ideFile = builder.build(xmlFile); - - //this.root = new HashMap(); - //this.root.put("doc", freemarker.ext.dom.NodeModel.parse(xmlFile)); - } - - - private void convertIDECommands() throws JDOMException { - - //XPath path = XPath.newInstance("html/body/table/tbody"); - Element root = this.ideFile.getRootElement(); - - this.xmlDestRoot = new Element("testcase"); - - //TODO: there must be a better way to do this with JDom - Element e1 = root.getChild("body",ns); - Element e2 = e1.getChild("table",ns); - Element e3 = e2.getChild("tbody",ns); - List<Element> list = e3.getChildren("tr", ns); - List<Element> commands = root.getChild("body",ns).getChild("table",ns).getChild("tbody",ns).getChildren("tr", ns); - for(Element elem: commands) { - processIDECommand(elem); - } - - } - - private void processIDECommand(Element elem) throws JDOMException { - - - List<Element> cmd = elem.getChildren("td", ns); - Element cmdElem = cmd.get(0); - - String cmdToCompare = cmdElem.getValue(); - System.out.println("Checking for cmd: " + cmdToCompare); - if ("clickAndWait".compareTo(cmdElem.getValue()) == 0) { - System.out.println("Found clickAndWait"); - this.xmlDestRoot.addContent(buildCommand("click", "locator", cmd.get(1).getValue(), null, null)); - this.xmlDestRoot.addContent(buildCommand("waitForPageToLoad", "value", "10000", null, null)); - - } else if ("type".compareTo(cmdElem.getValue()) == 0 ) { - System.out.println("Found type"); - this.xmlDestRoot.addContent (buildCommand("type", "name", cmd.get(1).getValue(), "value", cmd.get(2).getValue())); - - } else if ("select".compareTo(cmdElem.getValue()) == 0) { - System.out.println("Found select"); - this.xmlDestRoot.addContent(buildCommand("select", "locator", cmd.get(1).getValue(), "option", cmd.get(2).getValue())); - - } else if ("open".compareTo(cmdElem.getValue()) == 0) { - System.out.println("Found open"); - this.xmlDestRoot.addContent(buildCommand("open", "value", cmd.get(1).getValue(), null, null)); - - } else if ("click".compareTo(cmdElem.getValue()) == 0) { - Element newCmd = new Element("click"); - newCmd.setAttribute("locator", cmd.get(1).getValue()); - this.xmlDestRoot.addContent(newCmd); - - } else if ("doubleClick".compareTo(cmdElem.getValue()) == 0) { - Element newCmd = new Element("doubleClick"); - newCmd.setAttribute("locator", cmd.get(1).getValue()); - this.xmlDestRoot.addContent(newCmd); - - } else { - System.out.println("WARNING: No definition for " + cmdElem.getValue() + " defaulting to us 'reflection'."); - Element newCmd = new Element(cmdElem.getValue()); - //List attributes = cmdElem.getAttributes(); - int size = cmd.size()-1; - for(int i=1; i<size; i++) { - String paramValue = cmd.get(i).getValue(); - System.out.println("param" + (i) + " :" + paramValue); - newCmd.setAttribute("param" + (i), paramValue); - } - this.xmlDestRoot.addContent(newCmd); - } - - } - - private Element buildCommand(String name, String attrib1, String value1, String attrib2, String value2) { - - Element newCmd = new Element(name); - if (attrib1 != null) { - newCmd.setAttribute(attrib1, value1); - } - if (attrib2 != null) { - newCmd.setAttribute(attrib2, value2); - } - return newCmd; - } - private void createSeleniumXml(String outputFile) { - - try { - FileOutputStream out = new FileOutputStream(outputFile); - XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); - serializer.output(this.xmlDestRoot, out); - out.flush(); - out.close(); - } catch (IOException e) { - System.err.println(e); - } - } - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - if (args.length != 2) { - System.out.println("Please include the source and destination file paths."); - } else { - SeleniumIDEConverter sel = new SeleniumIDEConverter(); - try { - sel.convert(args[0], args[1]); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } + readInputFile(ideFile); + + convertIDECommands(); + + createSeleniumXml(xmlFile); + } + + + private void readInputFile(String input) throws JDOMException, IOException, SAXException, ParserConfigurationException { + + File xmlFile = new File(input); + SAXBuilder builder = new SAXBuilder(); + this.ideFile = builder.build(xmlFile); + + //this.root = new HashMap(); + //this.root.put("doc", freemarker.ext.dom.NodeModel.parse(xmlFile)); + } + + + private void convertIDECommands() throws JDOMException { + + //XPath path = XPath.newInstance("html/body/table/tbody"); + Element root = this.ideFile.getRootElement(); + + this.xmlDestRoot = new Element("testcase"); + + //TODO: there must be a better way to do this with JDom + Element e1 = root.getChild("body",ns); + Element e2 = e1.getChild("table",ns); + Element e3 = e2.getChild("tbody",ns); + List<Element> list = e3.getChildren("tr", ns); + List<Element> commands = root.getChild("body",ns).getChild("table",ns).getChild("tbody",ns).getChildren("tr", ns); + for(Element elem: commands) { + processIDECommand(elem); + } + + } + + private void processIDECommand(Element elem) throws JDOMException { + + + List<Element> cmd = elem.getChildren("td", ns); + Element cmdElem = cmd.get(0); + + String cmdToCompare = cmdElem.getValue(); + System.out.println("Checking for cmd: " + cmdToCompare); + if ("clickAndWait".compareTo(cmdElem.getValue()) == 0) { + System.out.println("Found clickAndWait"); + this.xmlDestRoot.addContent(buildCommand("click", "locator", cmd.get(1).getValue(), null, null)); + this.xmlDestRoot.addContent(buildCommand("waitForPageToLoad", "value", "10000", null, null)); + + } else if ("type".compareTo(cmdElem.getValue()) == 0 ) { + System.out.println("Found type"); + this.xmlDestRoot.addContent (buildCommand("type", "name", cmd.get(1).getValue(), "value", cmd.get(2).getValue())); + + } else if ("select".compareTo(cmdElem.getValue()) == 0) { + System.out.println("Found select"); + this.xmlDestRoot.addContent(buildCommand("select", "locator", cmd.get(1).getValue(), "option", cmd.get(2).getValue())); + + } else if ("open".compareTo(cmdElem.getValue()) == 0) { + System.out.println("Found open"); + this.xmlDestRoot.addContent(buildCommand("open", "value", cmd.get(1).getValue(), null, null)); + + } else if ("click".compareTo(cmdElem.getValue()) == 0) { + Element newCmd = new Element("click"); + newCmd.setAttribute("locator", cmd.get(1).getValue()); + this.xmlDestRoot.addContent(newCmd); + + } else if ("doubleClick".compareTo(cmdElem.getValue()) == 0) { + Element newCmd = new Element("doubleClick"); + newCmd.setAttribute("locator", cmd.get(1).getValue()); + this.xmlDestRoot.addContent(newCmd); + + } else { + System.out.println("WARNING: No definition for " + cmdElem.getValue() + " defaulting to us 'reflection'."); + Element newCmd = new Element(cmdElem.getValue()); + //List attributes = cmdElem.getAttributes(); + int size = cmd.size()-1; + for(int i=1; i<size; i++) { + String paramValue = cmd.get(i).getValue(); + System.out.println("param" + (i) + " :" + paramValue); + newCmd.setAttribute("param" + (i), paramValue); + } + this.xmlDestRoot.addContent(newCmd); + } + + } + + private Element buildCommand(String name, String attrib1, String value1, String attrib2, String value2) { + + Element newCmd = new Element(name); + if (attrib1 != null) { + newCmd.setAttribute(attrib1, value1); + } + if (attrib2 != null) { + newCmd.setAttribute(attrib2, value2); + } + return newCmd; + } + private void createSeleniumXml(String outputFile) { + + try { + FileOutputStream out = new FileOutputStream(outputFile); + XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); + serializer.output(this.xmlDestRoot, out); + out.flush(); + out.close(); + } catch (IOException e) { + System.err.println(e); + } + } + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + if (args.length != 2) { + System.out.println("Please include the source and destination file paths."); + } else { + SeleniumIDEConverter sel = new SeleniumIDEConverter(); + try { + sel.convert(args[0], args[1]); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java Mon Aug 17 11:01:25 2009 @@ -50,24 +50,24 @@ public class SeleniumXml { - - public static final String PROPS_NAME = "selenium.config"; - Logger logger = Logger.getLogger(SeleniumXml.class.getName()); - - public static final int MAX_STR_LENGTH = 15; - static String testPath; - private Map <String, Object> map; - private Document doc; - private DefaultSelenium sel; - private static Properties props; + + public static final String PROPS_NAME = "selenium.config"; + Logger logger = Logger.getLogger(SeleniumXml.class.getName()); + + public static final int MAX_STR_LENGTH = 15; + static String testPath; + private Map <String, Object> map; + private Document doc; + private DefaultSelenium sel; + private static Properties props; private String testSourcePath; private String username; private String password; - - public static void main(String[] args) throws JDOMException, IOException{ - if (args.length == 0) { - System.out.println("Please include a path for the selenium XML test file."); - } else { + + public static void main(String[] args) throws JDOMException, IOException{ + if (args.length == 0) { + System.out.println("Please include a path for the selenium XML test file."); + } else { SeleniumXml sel = new SeleniumXml(); for (String arg: args) { if (arg.startsWith("-username")) { @@ -78,160 +78,160 @@ sel.testSourcePath = arg; } } - sel.runTest(args[0]); - } - } - - public SeleniumXml() throws IOException { - this.map = new HashMap<String, Object>(); - if (props == null) { - props = new Properties(); - initConfig(); - } - logger.setLevel(Level.DEBUG); - } - - private static void initConfig() throws IOException { - try { - String configFile = System.getProperty(PROPS_NAME); - if (configFile == null) { - String errMsg = "The Java environment (-Dxxx=yyy) variable with name " + PROPS_NAME + " is not set, cannot resolve location."; - throw new MalformedURLException(errMsg); - } - BasicConfigurator.configure(); - InputStream in = new FileInputStream(configFile); - props.load(in); - in.close(); - - - } catch (IOException e) { - e.printStackTrace(); - throw e; - } - } - - /** - * Constructor to preset with an existing Map of parameters. Intended to be used - * for nested Selenium tests. - * @param map - */ - public SeleniumXml(SeleniumXml selenium) { - this.sel = selenium.getSelenium(); - this.map = selenium.getParameterMap(); - } - - public DefaultSelenium getSelenium() { - return this.sel; - } - public Map <String, Object> getParameterMap() { - return this.map; - } - public void runTest(String fileName) throws JDOMException, IOException { - readFile(fileName); - setupSelenium(); - runCommands(); - } - - public void runCommands() { - Element root = this.doc.getRootElement(); - List<Element> nodes = root.getChildren(); - runCommands(nodes); - } - - public void runCommands(List<Element> nodes) { - - for(Element elem: nodes) { - if ("type" == elem.getName()) { - typeCmd(elem); - - } else if ("clickAt" == elem.getName()) { - clickAt(elem); - } else if ("waitForValue" == elem.getName()) { - waitForValue(elem); - } else if ("waitForCondition" == elem.getName()) { - waitForCondition(elem); - } else if ("loadData" == elem.getName()) { - loadData(elem); + sel.runTest(args[0]); + } + } + + public SeleniumXml() throws IOException { + this.map = new HashMap<String, Object>(); + if (props == null) { + props = new Properties(); + initConfig(); + } + logger.setLevel(Level.DEBUG); + } + + private static void initConfig() throws IOException { + try { + String configFile = System.getProperty(PROPS_NAME); + if (configFile == null) { + String errMsg = "The Java environment (-Dxxx=yyy) variable with name " + PROPS_NAME + " is not set, cannot resolve location."; + throw new MalformedURLException(errMsg); + } + BasicConfigurator.configure(); + InputStream in = new FileInputStream(configFile); + props.load(in); + in.close(); + + + } catch (IOException e) { + e.printStackTrace(); + throw e; + } + } + + /** + * Constructor to preset with an existing Map of parameters. Intended to be used + * for nested Selenium tests. + * @param map + */ + public SeleniumXml(SeleniumXml selenium) { + this.sel = selenium.getSelenium(); + this.map = selenium.getParameterMap(); + } + + public DefaultSelenium getSelenium() { + return this.sel; + } + public Map <String, Object> getParameterMap() { + return this.map; + } + public void runTest(String fileName) throws JDOMException, IOException { + readFile(fileName); + setupSelenium(); + runCommands(); + } + + public void runCommands() { + Element root = this.doc.getRootElement(); + List<Element> nodes = root.getChildren(); + runCommands(nodes); + } + + public void runCommands(List<Element> nodes) { + + for(Element elem: nodes) { + if ("type" == elem.getName()) { + typeCmd(elem); + + } else if ("clickAt" == elem.getName()) { + clickAt(elem); + } else if ("waitForValue" == elem.getName()) { + waitForValue(elem); + } else if ("waitForCondition" == elem.getName()) { + waitForCondition(elem); + } else if ("loadData" == elem.getName()) { + loadData(elem); } else if ("loadData" == elem.getName()) { loadData(elem); } else if ("jythonRunner" == elem.getName()) { - jythonRunner(elem); + jythonRunner(elem); } else if ("groovyRunner" == elem.getName()) { - groovyRunner(elem); + groovyRunner(elem); } else if ("dataLoop" == elem.getName()) { dataLoop(elem); } else if ("remoteRequest" == elem.getName()) { remoteRequest(elem); - } else if ("selectPopup" == elem.getName()) { - selectPopup(elem); - } else if ("getAllWindowIds" == elem.getName()) { - getAllWindowIds(elem); - } else if ("captureTextInPage" == elem.getName()) { - captureTextInPageCmd(elem); - } else if ("getSelectedLabel" == elem.getName()) { - getSelectedLabel(elem); - } else if ("getSelectedValue" == elem.getName()) { - getSelectedValue(elem); - } else if ("getSelectedId" == elem.getName()) { - getSelectedId(elem); - } else if ("testcase" == elem.getName()) { - testcase(elem); - } else if ("assertContains" == elem.getName()) { - assertContains(elem); - } else if ("getHtmlSource" == elem.getName()) { - getHtmlSource(elem); - } else if ("getBodyText" == elem.getName()) { - getBodyText(elem); - } else if ("setup" == elem.getName()) { - continue; //setup is handled previously - } else if ("print" == elem.getName()) { - printCmd(elem); - } else if ("waitForPageToLoad" == elem.getName()) { - waitForPageToLoadCmd(elem); - } else if ("getSelectedIds" == elem.getName()) { - getSelectedIdsCmd(elem); - } else if ("copy" == elem.getName()) { - copyCmd(elem); - } else if ("append" == elem.getName()) { - appendCmd(elem); - } else if ("open" == elem.getName()) { - openCmd(elem); - } else if ("click" == elem.getName()) { - clickCmd(elem); - } else if ("select" == elem.getName()) { - selectCmd(elem); - } else if ("uniqueId" == elem.getName()) { - uniqueIdCmd(elem); - } else if ("randomAlphaString" == elem.getName()) { - randomAlphaStringCmd(elem); - } else if ("randomString" == elem.getName()) { - randomStringCmd(elem); + } else if ("selectPopup" == elem.getName()) { + selectPopup(elem); + } else if ("getAllWindowIds" == elem.getName()) { + getAllWindowIds(elem); + } else if ("captureTextInPage" == elem.getName()) { + captureTextInPageCmd(elem); + } else if ("getSelectedLabel" == elem.getName()) { + getSelectedLabel(elem); + } else if ("getSelectedValue" == elem.getName()) { + getSelectedValue(elem); + } else if ("getSelectedId" == elem.getName()) { + getSelectedId(elem); + } else if ("testcase" == elem.getName()) { + testcase(elem); + } else if ("assertContains" == elem.getName()) { + assertContains(elem); + } else if ("getHtmlSource" == elem.getName()) { + getHtmlSource(elem); + } else if ("getBodyText" == elem.getName()) { + getBodyText(elem); + } else if ("setup" == elem.getName()) { + continue; //setup is handled previously + } else if ("print" == elem.getName()) { + printCmd(elem); + } else if ("waitForPageToLoad" == elem.getName()) { + waitForPageToLoadCmd(elem); + } else if ("getSelectedIds" == elem.getName()) { + getSelectedIdsCmd(elem); + } else if ("copy" == elem.getName()) { + copyCmd(elem); + } else if ("append" == elem.getName()) { + appendCmd(elem); + } else if ("open" == elem.getName()) { + openCmd(elem); + } else if ("click" == elem.getName()) { + clickCmd(elem); + } else if ("select" == elem.getName()) { + selectCmd(elem); + } else if ("uniqueId" == elem.getName()) { + uniqueIdCmd(elem); + } else if ("randomAlphaString" == elem.getName()) { + randomAlphaStringCmd(elem); + } else if ("randomString" == elem.getName()) { + randomStringCmd(elem); } else if ("setSpeed" == elem.getName()) { setSpeed(elem); - } else { - //logger.error("Unknown SeleniumXml command found:"+elem.getName()); - //Use reflection with parameters using the naming convention param1, param2, and any return results stored - //in map using "out" - logger.info("Undefined command calling by reflection for command: " + elem.getName()); - callByReflection(elem); - } - } - - } - - private void callByReflection(Element elem) { - - String methodName = elem.getName(); - //Support two parameters for all selenium RC calls - String param1 = elem.getAttributeValue("param1"); - String param2 = elem.getAttributeValue("param2"); - - Class[] paramTypes = null; - Object[] args = null; - if ((param1 != null) && (param2 != null)) { - paramTypes = new Class[] {String.class, String.class}; - args = new Object[] {param1, param2}; - } else if (param1 != null) { + } else { + //logger.error("Unknown SeleniumXml command found:"+elem.getName()); + //Use reflection with parameters using the naming convention param1, param2, and any return results stored + //in map using "out" + logger.info("Undefined command calling by reflection for command: " + elem.getName()); + callByReflection(elem); + } + } + + } + + private void callByReflection(Element elem) { + + String methodName = elem.getName(); + //Support two parameters for all selenium RC calls + String param1 = elem.getAttributeValue("param1"); + String param2 = elem.getAttributeValue("param2"); + + Class[] paramTypes = null; + Object[] args = null; + if ((param1 != null) && (param2 != null)) { + paramTypes = new Class[] {String.class, String.class}; + args = new Object[] {param1, param2}; + } else if (param1 != null) { paramTypes = new Class[] {String.class}; args = new Object[] {param1}; } else { @@ -239,73 +239,73 @@ args = new Object[] {}; } - //Capture the output name for "get" methods - String out = elem.getAttributeValue("out"); - - Method m; - try { - m = (Method) this.sel.getClass().getDeclaredMethod(methodName, paramTypes); - Object results = m.invoke(this.sel, args); - - //Add output parameter to common map - if ((out != null) && (results != null)) { - addParam(out, results); - } - } catch (Exception e) { - // TODO Auto-generated catch block - logger.error("Exception occurred when Unknown SeleniumXml command found:"+elem.getName()); - e.printStackTrace(); - } - - - } - - public void waitForValue(Element elem) { - - String locator = elem.getAttributeValue("locator"); - String timeout = elem.getAttributeValue("timeout"); - String outParam = elem.getAttributeValue("out"); - - int maxTime = Integer.parseInt(timeout); - int maxSeconds = maxTime/1000; - logger.debug("waitForValue: locator=" + locator + " timeout=" + timeout); - //this.sel.waitForCondition(script, timeout); - String foundValue = null; - for(int second=0;; second++) { - if (second >= maxSeconds) { -// throw new SeleniumException("waitForValue exceeded timeout: " + maxTime); - } - try { - //getValue throws an exception if it can't find locator - // - sleep for 1 sec and try again - // - otherwise break as we found the value - foundValue = sel.getValue(locator); - if (outParam != null) { - this.addParam(outParam, foundValue); - } - break; // - } catch (Exception e) { - //wait for 1 second and then resume - try { - Thread.sleep(1000); - } catch (InterruptedException threadE) { - // TODO Auto-generated catch block - threadE.printStackTrace(); - - } - } - } - } - - public void waitForCondition(Element elem) { - - String script = elem.getAttributeValue("script"); - String timeout = elem.getAttributeValue("timeout"); - - logger.debug("waitForCondition: script=" + script + " timeout=" + timeout); - this.sel.waitForCondition(script, timeout); - } - + //Capture the output name for "get" methods + String out = elem.getAttributeValue("out"); + + Method m; + try { + m = (Method) this.sel.getClass().getDeclaredMethod(methodName, paramTypes); + Object results = m.invoke(this.sel, args); + + //Add output parameter to common map + if ((out != null) && (results != null)) { + addParam(out, results); + } + } catch (Exception e) { + // TODO Auto-generated catch block + logger.error("Exception occurred when Unknown SeleniumXml command found:"+elem.getName()); + e.printStackTrace(); + } + + + } + + public void waitForValue(Element elem) { + + String locator = elem.getAttributeValue("locator"); + String timeout = elem.getAttributeValue("timeout"); + String outParam = elem.getAttributeValue("out"); + + int maxTime = Integer.parseInt(timeout); + int maxSeconds = maxTime/1000; + logger.debug("waitForValue: locator=" + locator + " timeout=" + timeout); + //this.sel.waitForCondition(script, timeout); + String foundValue = null; + for(int second=0;; second++) { + if (second >= maxSeconds) { +// throw new SeleniumException("waitForValue exceeded timeout: " + maxTime); + } + try { + //getValue throws an exception if it can't find locator + // - sleep for 1 sec and try again + // - otherwise break as we found the value + foundValue = sel.getValue(locator); + if (outParam != null) { + this.addParam(outParam, foundValue); + } + break; // + } catch (Exception e) { + //wait for 1 second and then resume + try { + Thread.sleep(1000); + } catch (InterruptedException threadE) { + // TODO Auto-generated catch block + threadE.printStackTrace(); + + } + } + } + } + + public void waitForCondition(Element elem) { + + String script = elem.getAttributeValue("script"); + String timeout = elem.getAttributeValue("timeout"); + + logger.debug("waitForCondition: script=" + script + " timeout=" + timeout); + this.sel.waitForCondition(script, timeout); + } + public void loadData(Element elem) { String file = elem.getAttributeValue("file"); @@ -371,126 +371,126 @@ this.map.put(name, value); } - private void assertContains(Element elem) { - String src = replaceParam(elem.getAttributeValue("src")); - String test = replaceParam(elem.getAttributeValue("test")); - int indxSearch = src.indexOf(test); - if (indxSearch == -1) { - logger.info("assertContains didn't find " + test + " in the src"); - } else { - logger.info("assertContains found " + test + " in the src"); - } - Assert.assertTrue(indxSearch != -1); - //String text = this.sel.getHtmlSource(); - } - - private void selectPopup(Element elem) { - String locator = elem.getAttributeValue("locator"); -// String winId = elem.getAttributeValue("windowId"); - String timeout = elem.getAttributeValue("timeout"); - - //this.sel.waitForPopUp(winId, timeout); - this.sel.click(locator); - - String[] winNames = this.sel.getAllWindowNames(); - this.sel.selectWindow("name=" + winNames[1]); - } - - private void getAllWindowIds(Element elem) { - String[] winIds = this.sel.getAllWindowIds(); - for(int i=0; i<winIds.length; i++) { - logger.info("WindowId: " + winIds[i]); - } - String[] winNames = this.sel.getAllWindowNames(); - for(int i=0; i<winIds.length; i++) { - logger.info("WindowName: " + winNames[i]); - } - - //this.sel.selectWindow("name=" + winNames[1]); - //System.out.println("Did we select WindowName: " + winNames[1]); - } - - private void getWindowPopup(Element elem) { - - } - /** - * Gets the hidden value of a list box - * @param elem - */ - private void getSelectedValue(Element elem) { - String locator = elem.getAttributeValue("locator"); - String out = elem.getAttributeValue("out"); - String text = this.sel.getSelectedValue(locator); - logger.info("getSelectedValue: locator=" + locator + " text="+text); - addParam(out, text); - } - - /** - * Gets the visible (displayed) value of a list box - * @param elem - */ - private void getSelectedLabel(Element elem) { - String locator = elem.getAttributeValue("locator"); - String out = elem.getAttributeValue("out"); - String text = this.sel.getSelectedLabel(locator); - logger.info("getSelectedValue: locator=" + locator + " text="+text); - addParam(out, text); - } - private void getSelectedId(Element elem) { - String locator = elem.getAttributeValue("locator"); - String out = elem.getAttributeValue("out"); - String text = this.sel.getSelectedId(locator); - addParam(out, text); - } - private void getHtmlSource(Element elem) { - String paramName = elem.getAttributeValue("out"); - String text = this.sel.getHtmlSource(); - //logger.info("getHtmlsource: paramName=" + paramName + " text=" + text); - addParam(paramName, text); - } - - private void getBodyText(Element elem) { - String paramName = elem.getAttributeValue("out"); - String text = this.sel.getBodyText(); - //logger.info("getBodyText: paramName=" + paramName + " text=" + text); - addParam(paramName, text); - } - private void testcase(Element elem) { - System.err.println("New testcase: " + elem.getAttributeValue("file")); - String testFile = elem.getAttributeValue("file"); - SeleniumXml newTest = new SeleniumXml(this); - try { - newTest.runTest(testFile); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Testcase error for file: " + testFile); - } - } - private void clickAt(Element elem) { - logger.debug("clickAt: " + replaceParam(elem.getAttributeValue("locator"))); - String locator = elem.getAttributeValue("locator"); - String coordString = elem.getAttributeValue("coordString"); - this.sel.clickAt(locator, coordString); - } - /** - * @param elem takes a Selenium String locator. See Javadocs for more information. Here are some - * example locators: - * id="buttonId" - the easiest - * css=input[type='submit'] - uses css selector notation - * xpath= <TBD> - * dom= <TBD> - */ - private void clickCmd(Element elem) { - String locator = this.replaceParam(elem.getAttributeValue("locator")); - logger.info("clickCmd: " + locator); - this.sel.click(locator); - } - private void typeCmd(Element elem) { - String name = elem.getAttributeValue("name"); - String value = replaceParam(elem.getAttributeValue("value")); - logger.info("typeCmd: id=" + name + " value=" + value); - this.sel.type(name, value); - } + private void assertContains(Element elem) { + String src = replaceParam(elem.getAttributeValue("src")); + String test = replaceParam(elem.getAttributeValue("test")); + int indxSearch = src.indexOf(test); + if (indxSearch == -1) { + logger.info("assertContains didn't find " + test + " in the src"); + } else { + logger.info("assertContains found " + test + " in the src"); + } + Assert.assertTrue(indxSearch != -1); + //String text = this.sel.getHtmlSource(); + } + + private void selectPopup(Element elem) { + String locator = elem.getAttributeValue("locator"); +// String winId = elem.getAttributeValue("windowId"); + String timeout = elem.getAttributeValue("timeout"); + + //this.sel.waitForPopUp(winId, timeout); + this.sel.click(locator); + + String[] winNames = this.sel.getAllWindowNames(); + this.sel.selectWindow("name=" + winNames[1]); + } + + private void getAllWindowIds(Element elem) { + String[] winIds = this.sel.getAllWindowIds(); + for(int i=0; i<winIds.length; i++) { + logger.info("WindowId: " + winIds[i]); + } + String[] winNames = this.sel.getAllWindowNames(); + for(int i=0; i<winIds.length; i++) { + logger.info("WindowName: " + winNames[i]); + } + + //this.sel.selectWindow("name=" + winNames[1]); + //System.out.println("Did we select WindowName: " + winNames[1]); + } + + private void getWindowPopup(Element elem) { + + } + /** + * Gets the hidden value of a list box + * @param elem + */ + private void getSelectedValue(Element elem) { + String locator = elem.getAttributeValue("locator"); + String out = elem.getAttributeValue("out"); + String text = this.sel.getSelectedValue(locator); + logger.info("getSelectedValue: locator=" + locator + " text="+text); + addParam(out, text); + } + + /** + * Gets the visible (displayed) value of a list box + * @param elem + */ + private void getSelectedLabel(Element elem) { + String locator = elem.getAttributeValue("locator"); + String out = elem.getAttributeValue("out"); + String text = this.sel.getSelectedLabel(locator); + logger.info("getSelectedValue: locator=" + locator + " text="+text); + addParam(out, text); + } + private void getSelectedId(Element elem) { + String locator = elem.getAttributeValue("locator"); + String out = elem.getAttributeValue("out"); + String text = this.sel.getSelectedId(locator); + addParam(out, text); + } + private void getHtmlSource(Element elem) { + String paramName = elem.getAttributeValue("out"); + String text = this.sel.getHtmlSource(); + //logger.info("getHtmlsource: paramName=" + paramName + " text=" + text); + addParam(paramName, text); + } + + private void getBodyText(Element elem) { + String paramName = elem.getAttributeValue("out"); + String text = this.sel.getBodyText(); + //logger.info("getBodyText: paramName=" + paramName + " text=" + text); + addParam(paramName, text); + } + private void testcase(Element elem) { + System.err.println("New testcase: " + elem.getAttributeValue("file")); + String testFile = elem.getAttributeValue("file"); + SeleniumXml newTest = new SeleniumXml(this); + try { + newTest.runTest(testFile); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Testcase error for file: " + testFile); + } + } + private void clickAt(Element elem) { + logger.debug("clickAt: " + replaceParam(elem.getAttributeValue("locator"))); + String locator = elem.getAttributeValue("locator"); + String coordString = elem.getAttributeValue("coordString"); + this.sel.clickAt(locator, coordString); + } + /** + * @param elem takes a Selenium String locator. See Javadocs for more information. Here are some + * example locators: + * id="buttonId" - the easiest + * css=input[type='submit'] - uses css selector notation + * xpath= <TBD> + * dom= <TBD> + */ + private void clickCmd(Element elem) { + String locator = this.replaceParam(elem.getAttributeValue("locator")); + logger.info("clickCmd: " + locator); + this.sel.click(locator); + } + private void typeCmd(Element elem) { + String name = elem.getAttributeValue("name"); + String value = replaceParam(elem.getAttributeValue("value")); + logger.info("typeCmd: id=" + name + " value=" + value); + this.sel.type(name, value); + } /* * setSpeed delays the time for the next selenium command to execute */ @@ -498,228 +498,228 @@ logger.info("setSpeed: " + elem.getAttributeValue("value")); this.sel.setSpeed(elem.getAttributeValue("value")); } - /* - * waitForPageToLoadCmd is the max timeout selenium will wait for a page to load. - * Commands are executed immediately after the page loads therefore if the pages are - * fast the test will go through the pages very quickly. Use setSpeed if you want to - * see the pages executed slower. - */ - private void waitForPageToLoadCmd(Element elem) { - logger.info("waitForPageToLoadCmd: " + elem.getAttributeValue("value")); - this.sel.waitForPageToLoad(elem.getAttributeValue("value")); - } - private void openCmd(Element elem) { - String cmd = replaceParam(elem.getAttributeValue("value")); - logger.info("openCmd: " + cmd); - this.sel.open(cmd); + /* + * waitForPageToLoadCmd is the max timeout selenium will wait for a page to load. + * Commands are executed immediately after the page loads therefore if the pages are + * fast the test will go through the pages very quickly. Use setSpeed if you want to + * see the pages executed slower. + */ + private void waitForPageToLoadCmd(Element elem) { + logger.info("waitForPageToLoadCmd: " + elem.getAttributeValue("value")); + this.sel.waitForPageToLoad(elem.getAttributeValue("value")); + } + private void openCmd(Element elem) { + String cmd = replaceParam(elem.getAttributeValue("value")); + logger.info("openCmd: " + cmd); + this.sel.open(cmd); //this.sel.windowMaximize(); - } - private void uniqueIdCmd(Element elem) { - String paramName = elem.getAttributeValue("out"); + } + private void uniqueIdCmd(Element elem) { + String paramName = elem.getAttributeValue("out"); String paramValue = RandomStringUtils.randomAlphanumeric(MAX_STR_LENGTH).toUpperCase(); logger.info("uniqueIdCmd: parameter=" + paramName + " value=" + paramValue); - addParam(paramName, paramValue); + addParam(paramName, paramValue); } - - /* - * captureText command captures the current HTML page and runs a regex to - * get the specified string. - * - * For example: if the following string existed in a web page - * - * "xx <tag a=b> yy </tag> zz" - * - * - * And you wanted to capture the value in the of the XML (yy). You would do the following; - * Use regxp: "<(\\S+?).*?>(.*?)</\\1>"; //The \\1 reuses group 1 - * - * <captureText regex="<(\\S+?).*?>(.*?)</\\1>" group="2" results="xmlValue" /> - * - * The command will find the <tag>.. and group 2 contains the 'yy' value. - * - * Note: if 'group' is null it will default to the entire regex group. - */ - private void captureTextInPageCmd(Element elem) { - - String regex = elem.getAttributeValue("regex"); - String group = elem.getAttributeValue("group"); - String results = elem.getAttributeValue("results"); - Pattern pattern = Pattern.compile(regex); - - String targetString = this.sel.getHtmlSource(); - - // Create the 'target' string we wish to interrogate. - // Get a Matcher based on the target string. - Matcher matcher = pattern.matcher(targetString); - - // Find all the matches. - if (matcher.find()) { - String resultsValue = null; - if (group != null) { - resultsValue = matcher.group(Integer.parseInt(group)); - } else { - resultsValue = matcher.group(); - } - logger.info("Found match for " + resultsValue); - logger.debug("Using regex " + regex); - logger.debug("Copy results to " + results); - addParam(results, resultsValue); - } else { - logger.info("Didn't find results with regex: " + regex); - - //TODO: temporary to capture the missed string - /*try { - FileWriter out = new FileWriter("c:/dev/erep/output/failure.txt"); - BufferedWriter buffWriter = new BufferedWriter(out); - buffWriter.write(targetString); - out.flush(); - out.close(); - } catch (IOException e) { - System.err.println(e); - } */ - } - } - - private void randomAlphaStringCmd(Element elem) { - int nSize = 0; - int nPrefixSize = 0; - String paramName = elem.getAttributeValue("out"); - String size = elem.getAttributeValue("size"); - if (size != null) { - nSize = Integer.parseInt(size); - } - String prefix = elem.getAttributeValue("prefix"); - if (prefix != null) { - nPrefixSize = prefix.length(); - } - - String paramValue = null; - if (prefix != null) { - paramValue = prefix + RandomStringUtils.randomAlphabetic(nSize - nPrefixSize); - } else { - paramValue = RandomStringUtils.randomAlphabetic(nSize); - } - //String paramValue = TestUtils.createRandomString(prefix, Integer.parseInt(size)); - logger.info("randomStringAlphaCmd: paramName=" + paramName + " paramValue=" + paramValue); - addParam(paramName, paramValue); - } - private void randomStringCmd(Element elem) { - String paramName = elem.getAttributeValue("out"); - String size = elem.getAttributeValue("size"); - String prefix = elem.getAttributeValue("prefix"); - String paramValue = TestUtils.createRandomString(prefix, Integer.parseInt(size)); - logger.info("randomStringCmd: paramName=" + paramName + " paramValue=" + paramValue); - addParam(paramName, paramValue); - } - private void getSelectedIdsCmd(Element elem) { - logger.info("getSelectdIdsCmd: " + elem.getAttributeValue("value")); - this.sel.getSelectedIds(elem.getAttributeValue("value")); - } - private void selectCmd(Element elem) { - String selectLocator = elem.getAttributeValue("locator"); - String optionLocator = elem.getAttributeValue("option"); - logger.info("selectCmd: selectLocator=" + selectLocator + " optionLocator=" + optionLocator); - this.sel.select(selectLocator, optionLocator); - } - private void printCmd(Element elem) { - String value = replaceParam(elem.getAttributeValue("value")); - logger.info("Print: " + value); - } - private void copyCmd(Element elem) { - String toStr = replaceParam(elem.getAttributeValue("to")); - String fromStr = replaceParam(elem.getAttributeValue("from")); - logger.info("copyCmd: to=" + toStr + " from=" + fromStr); - addParam(toStr, fromStr); - } - private void appendCmd(Element elem) { - logger.info("appendCmd: src1=" + elem.getAttributeValue("src1") + " src2=" + elem.getAttributeValue("src2")); - String newStr = replaceParam(elem.getAttributeValue("src1")) + replaceParam(elem.getAttributeValue("src2")); - addParam(elem.getAttributeValue("out"), newStr); - } + + /* + * captureText command captures the current HTML page and runs a regex to + * get the specified string. + * + * For example: if the following string existed in a web page + * + * "xx <tag a=b> yy </tag> zz" + * + * + * And you wanted to capture the value in the of the XML (yy). You would do the following; + * Use regxp: "<(\\S+?).*?>(.*?)</\\1>"; //The \\1 reuses group 1 + * + * <captureText regex="<(\\S+?).*?>(.*?)</\\1>" group="2" results="xmlValue" /> + * + * The command will find the <tag>.. and group 2 contains the 'yy' value. + * + * Note: if 'group' is null it will default to the entire regex group. + */ + private void captureTextInPageCmd(Element elem) { + + String regex = elem.getAttributeValue("regex"); + String group = elem.getAttributeValue("group"); + String results = elem.getAttributeValue("results"); + Pattern pattern = Pattern.compile(regex); + + String targetString = this.sel.getHtmlSource(); + + // Create the 'target' string we wish to interrogate. + // Get a Matcher based on the target string. + Matcher matcher = pattern.matcher(targetString); + + // Find all the matches. + if (matcher.find()) { + String resultsValue = null; + if (group != null) { + resultsValue = matcher.group(Integer.parseInt(group)); + } else { + resultsValue = matcher.group(); + } + logger.info("Found match for " + resultsValue); + logger.debug("Using regex " + regex); + logger.debug("Copy results to " + results); + addParam(results, resultsValue); + } else { + logger.info("Didn't find results with regex: " + regex); + + //TODO: temporary to capture the missed string + /*try { + FileWriter out = new FileWriter("c:/dev/erep/output/failure.txt"); + BufferedWriter buffWriter = new BufferedWriter(out); + buffWriter.write(targetString); + out.flush(); + out.close(); + } catch (IOException e) { + System.err.println(e); + } */ + } + } + + private void randomAlphaStringCmd(Element elem) { + int nSize = 0; + int nPrefixSize = 0; + String paramName = elem.getAttributeValue("out"); + String size = elem.getAttributeValue("size"); + if (size != null) { + nSize = Integer.parseInt(size); + } + String prefix = elem.getAttributeValue("prefix"); + if (prefix != null) { + nPrefixSize = prefix.length(); + } - public String replaceParam(String value) { + String paramValue = null; + if (prefix != null) { + paramValue = prefix + RandomStringUtils.randomAlphabetic(nSize - nPrefixSize); + } else { + paramValue = RandomStringUtils.randomAlphabetic(nSize); + } + //String paramValue = TestUtils.createRandomString(prefix, Integer.parseInt(size)); + logger.info("randomStringAlphaCmd: paramName=" + paramName + " paramValue=" + paramValue); + addParam(paramName, paramValue); + } + private void randomStringCmd(Element elem) { + String paramName = elem.getAttributeValue("out"); + String size = elem.getAttributeValue("size"); + String prefix = elem.getAttributeValue("prefix"); + String paramValue = TestUtils.createRandomString(prefix, Integer.parseInt(size)); + logger.info("randomStringCmd: paramName=" + paramName + " paramValue=" + paramValue); + addParam(paramName, paramValue); + } + private void getSelectedIdsCmd(Element elem) { + logger.info("getSelectdIdsCmd: " + elem.getAttributeValue("value")); + this.sel.getSelectedIds(elem.getAttributeValue("value")); + } + private void selectCmd(Element elem) { + String selectLocator = elem.getAttributeValue("locator"); + String optionLocator = elem.getAttributeValue("option"); + logger.info("selectCmd: selectLocator=" + selectLocator + " optionLocator=" + optionLocator); + this.sel.select(selectLocator, optionLocator); + } + private void printCmd(Element elem) { + String value = replaceParam(elem.getAttributeValue("value")); + logger.info("Print: " + value); + } + private void copyCmd(Element elem) { + String toStr = replaceParam(elem.getAttributeValue("to")); + String fromStr = replaceParam(elem.getAttributeValue("from")); + logger.info("copyCmd: to=" + toStr + " from=" + fromStr); + addParam(toStr, fromStr); + } + private void appendCmd(Element elem) { + logger.info("appendCmd: src1=" + elem.getAttributeValue("src1") + " src2=" + elem.getAttributeValue("src2")); + String newStr = replaceParam(elem.getAttributeValue("src1")) + replaceParam(elem.getAttributeValue("src2")); + addParam(elem.getAttributeValue("out"), newStr); + } + + public String replaceParam(String value) { StringBuffer buf = new StringBuffer(); int end = 0; int start = 0; String replacedVal = null; String remainingStr = value; - while (isParam(remainingStr)) { + while (isParam(remainingStr)) { start = remainingStr.indexOf("${"); buf.append(remainingStr.substring(end, start)); - end = remainingStr.indexOf("}"); - String paramName = remainingStr.substring(start + 2, end); - replacedVal = getParamValue(paramName); + end = remainingStr.indexOf("}"); + String paramName = remainingStr.substring(start + 2, end); + replacedVal = getParamValue(paramName); if (replacedVal == null) { replacedVal = ""; } buf.append(replacedVal); remainingStr = remainingStr.substring(end + 1); end = 0; - } + } buf.append(remainingStr.substring(end)); - return buf.toString(); - } + return buf.toString(); + } - private boolean isParam(String value) { + private boolean isParam(String value) { - if ((value.indexOf("${") != -1) && - (value.indexOf("}", 1) != -1)) { - return true; - } - return false; - } - - //TODO read properties file to setup selenium - private void setupSelenium() { - - //return if Selenium has already been setup - //e.g. nested selenium test cases. - if (this.sel != null) return; - - String serverHost = null; - String serverPort = null; - String browser = null; - String startUrl = null; - - //First initialize with property values - if (props != null) { //Get setup params from property value - - serverHost = props.getProperty("serverHost", "localhost"); - serverPort = props.getProperty("proxyPort", "4444"); - browser = props.getProperty("browser", "*firefox"); - startUrl = props.getProperty("startUrl", "http://localhost:8080"); - } - - //Second over ride properties if defined in the "setup" element - Element elem = this.doc.getRootElement().getChild("setup"); - if (elem != null) { - - //Override properties if specified - if (elem.getAttributeValue("serverHost") != null) { - serverHost = elem.getAttributeValue("serverHost"); - } - if (elem.getAttributeValue("serverPort") != null) { - serverPort = elem.getAttributeValue("serverPort"); - } - if (elem.getAttributeValue("browser") != null) { - browser = elem.getAttributeValue("browser"); - } - if (elem.getAttributeValue("startUrl") != null) { - startUrl = elem.getAttributeValue("startUrl"); - } - } - logger.info("setup: serverHost=" + serverHost); - logger.info("setup: serverPort=" + serverPort); - logger.info("setup: browser=" + browser); - logger.info("setup: startUrl=" + startUrl); - this.sel = new DefaultSelenium(serverHost, Integer.parseInt(serverPort), browser, startUrl); - this.sel.start(); - } - private void readFile(String fileName) throws JDOMException, IOException { - File xmlFile = new File(fileName); - SAXBuilder builder = new SAXBuilder(); - this.doc = builder.build(xmlFile); - } + if ((value.indexOf("${") != -1) && + (value.indexOf("}", 1) != -1)) { + return true; + } + return false; + } + + //TODO read properties file to setup selenium + private void setupSelenium() { + + //return if Selenium has already been setup + //e.g. nested selenium test cases. + if (this.sel != null) return; + + String serverHost = null; + String serverPort = null; + String browser = null; + String startUrl = null; + + //First initialize with property values + if (props != null) { //Get setup params from property value + + serverHost = props.getProperty("serverHost", "localhost"); + serverPort = props.getProperty("proxyPort", "4444"); + browser = props.getProperty("browser", "*firefox"); + startUrl = props.getProperty("startUrl", "http://localhost:8080"); + } + + //Second over ride properties if defined in the "setup" element + Element elem = this.doc.getRootElement().getChild("setup"); + if (elem != null) { + + //Override properties if specified + if (elem.getAttributeValue("serverHost") != null) { + serverHost = elem.getAttributeValue("serverHost"); + } + if (elem.getAttributeValue("serverPort") != null) { + serverPort = elem.getAttributeValue("serverPort"); + } + if (elem.getAttributeValue("browser") != null) { + browser = elem.getAttributeValue("browser"); + } + if (elem.getAttributeValue("startUrl") != null) { + startUrl = elem.getAttributeValue("startUrl"); + } + } + logger.info("setup: serverHost=" + serverHost); + logger.info("setup: serverPort=" + serverPort); + logger.info("setup: browser=" + browser); + logger.info("setup: startUrl=" + startUrl); + this.sel = new DefaultSelenium(serverHost, Integer.parseInt(serverPort), browser, startUrl); + this.sel.start(); + } + private void readFile(String fileName) throws JDOMException, IOException { + File xmlFile = new File(fileName); + SAXBuilder builder = new SAXBuilder(); + this.doc = builder.build(xmlFile); + } public String getUserName() { return this.username; Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/TestUtils.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/TestUtils.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/TestUtils.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/TestUtils.java Mon Aug 17 11:01:25 2009 @@ -27,42 +27,42 @@ public class TestUtils { - static char[] charMap = {'A', 'B', 'C','D','E','F','G','H','I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','X','Y','Z', - 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', - 's','t','u','v','w','x','y','z', - '0','1','2','3','4','5','6','7','8','9'}; - - static public String createUniqueString() { - long time = System.currentTimeMillis(); - - return String.valueOf(time); - } - - static public String createRandomString(int size) { - - return createRandomString(null, size); - } - - static public String createRandomString(String prefix, String size) { - return createRandomString(prefix, Integer.valueOf(size).intValue()); - } - - static public String createRandomString(String prefix, int size) { - StringBuffer buff = new StringBuffer(size); - int startIndx = 0; - - if (prefix != null) { - buff.append(prefix); - startIndx = prefix.length(); - } - - Random rad = new Random(); - for(int i=startIndx; i<size; i++) { - buff.append(charMap[rad.nextInt(charMap.length)]); - } - return buff.toString(); - } + static char[] charMap = {'A', 'B', 'C','D','E','F','G','H','I','J','K','L','M','N','O','P', + 'Q','R','S','T','U','V','X','Y','Z', + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', + 's','t','u','v','w','x','y','z', + '0','1','2','3','4','5','6','7','8','9'}; + + static public String createUniqueString() { + long time = System.currentTimeMillis(); + + return String.valueOf(time); + } + + static public String createRandomString(int size) { + + return createRandomString(null, size); + } + + static public String createRandomString(String prefix, String size) { + return createRandomString(prefix, Integer.valueOf(size).intValue()); + } + + static public String createRandomString(String prefix, int size) { + StringBuffer buff = new StringBuffer(size); + int startIndx = 0; + + if (prefix != null) { + buff.append(prefix); + startIndx = prefix.length(); + } + + Random rad = new Random(); + for(int i=startIndx; i<size; i++) { + buff.append(charMap[rad.nextInt(charMap.length)]); + } + return buff.toString(); + } public static String readUrlText(String urlString) throws IOException { URL url = new URL(urlString); Modified: ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_login.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_login.xml?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_login.xml (original) +++ ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_login.xml Mon Aug 17 11:01:25 2009 @@ -6,8 +6,8 @@ <type name="PASSWORD" value="ofbiz" /> <click locator="//input[@value='Login']" /> <waitForPageToLoad value="10000" /> - <getBodyText out="bodyText"/> - <getHtmlSource out="htmlSource"/> + <getBodyText out="bodyText"/> + <getHtmlSource out="htmlSource"/> <assertContains src="${htmlSource}" test="Welcome" /> </testcase> Modified: ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_testsuite.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_testsuite.xml?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_testsuite.xml (original) +++ ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_testsuite.xml Mon Aug 17 11:01:25 2009 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <testcase> <setSpeed value="500" /> - <testcase file="testdef/seleniumxml/example/example_login.xml"/> + <testcase file="testdef/seleniumxml/example/example_login.xml"/> <testcase file="testdef/seleniumxml/example/example_new.xml"/> <testcase file="testdef/seleniumxml/example/example_search.xml"/> </testcase> Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Mon Aug 17 11:01:25 2009 @@ -135,9 +135,9 @@ } // check for default request if (requestMap == null) { - if (controllerConfig.defaultRequest != null) { // required! to avoid a null pointer exception and generate a requesthandler exception if default request not found. - requestMap = controllerConfig.requestMapMap.get(controllerConfig.defaultRequest); - } + if (controllerConfig.defaultRequest != null) { // required! to avoid a null pointer exception and generate a requesthandler exception if default request not found. + requestMap = controllerConfig.requestMapMap.get(controllerConfig.defaultRequest); + } } // still not found so stop if (requestMap == null) { @@ -497,7 +497,7 @@ // if the request has the save-last-view attribute set, save it now before the view can be rendered or other chain done so that the _LAST* session attributes will represent the previous request if (nextRequestResponse.saveLastView) { - // Debug.log("======save last view: " + session.getAttribute("_LAST_VIEW_NAME_")); + // Debug.log("======save last view: " + session.getAttribute("_LAST_VIEW_NAME_")); String lastViewName = (String) session.getAttribute("_LAST_VIEW_NAME_"); // Do not save the view if the last view is the same as the current view and saveCurrentView is false if (!(!nextRequestResponse.saveCurrentView && "view".equals(nextRequestResponse.type) && nextRequestResponse.value.equals(lastViewName))) { @@ -733,18 +733,18 @@ req.getSession().setAttribute("_LAST_VIEW_PARAMS_", paramMap); if ("SAVED".equals(saveName)) { - //Debug.log("======save current view: " + view); - req.getSession().setAttribute("_SAVED_VIEW_NAME_", view); - req.getSession().setAttribute("_SAVED_VIEW_PARAMS_", paramMap); + //Debug.log("======save current view: " + view); + req.getSession().setAttribute("_SAVED_VIEW_NAME_", view); + req.getSession().setAttribute("_SAVED_VIEW_PARAMS_", paramMap); } if ("HOME".equals(saveName)) { - //Debug.log("======save home view: " + view); - req.getSession().setAttribute("_HOME_VIEW_NAME_", view); - req.getSession().setAttribute("_HOME_VIEW_PARAMS_", paramMap); - // clear other saved views - req.getSession().removeAttribute("_SAVED_VIEW_NAME_"); - req.getSession().removeAttribute("_SAVED_VIEW_PARAMS_"); + //Debug.log("======save home view: " + view); + req.getSession().setAttribute("_HOME_VIEW_NAME_", view); + req.getSession().setAttribute("_HOME_VIEW_PARAMS_", paramMap); + // clear other saved views + req.getSession().removeAttribute("_SAVED_VIEW_NAME_"); + req.getSession().removeAttribute("_SAVED_VIEW_PARAMS_"); } ConfigXMLReader.ViewMap viewMap = (view == null ? null : getControllerConfig().viewMapMap.get(view)); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java Mon Aug 17 11:01:25 2009 @@ -90,13 +90,13 @@ Debug.logVerbose("Loading BSF Script at location: " + cacheName, module); } URL scriptUrl = FlexibleLocation.resolveLocation(cacheName); - if (scriptUrl == null) { - throw new EventHandlerException("BSF script not found at location [" + cacheName + "]"); - } + if (scriptUrl == null) { + throw new EventHandlerException("BSF script not found at location [" + cacheName + "]"); + } scriptStream = scriptUrl.openStream(); - scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream)); + scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream)); scriptStream.close(); - eventCache.put(cacheName, scriptString); + eventCache.put(cacheName, scriptString); } } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Mon Aug 17 11:01:25 2009 @@ -162,7 +162,7 @@ ModelForm modelForm = modelFormField.getModelForm(); String idName = modelFormField.getIdName(); if (UtilValidate.isNotEmpty(idName) && ("list".equals(modelForm.getType()) || "multi".equals(modelForm.getType()))) { - idName += "_" + modelForm.getRowCount(); + idName += "_" + modelForm.getRowCount(); } String description = displayField.getDescription(context); if (UtilValidate.isNotEmpty(description)) { @@ -332,9 +332,9 @@ String className = ""; String alert = "false"; if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { - className = modelFormField.getWidgetStyle(); + className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { - alert = "true"; + alert = "true"; } } @@ -342,7 +342,7 @@ String textSize = Integer.toString(textField.getSize()); String maxlength = ""; if (textField.getMaxlength() != null) { - maxlength = Integer.toString(textField.getMaxlength()); + maxlength = Integer.toString(textField.getMaxlength()); } String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); @@ -392,7 +392,7 @@ ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { - makeHyperlinkString(writer,subHyperlink,context); + makeHyperlinkString(writer,subHyperlink,context); } this.addAsterisks(writer, context, modelFormField); this.appendTooltip(writer, context, modelFormField); @@ -1875,12 +1875,12 @@ List<String> targetParameterList = lookupField.getTargetParameterList(); targetParameterIter.append("["); for (String targetParameter: targetParameterList) { - if (targetParameterIter.length()>1) { - targetParameterIter.append(","); - } - targetParameterIter.append("'"); - targetParameterIter.append(targetParameter); - targetParameterIter.append("'"); + if (targetParameterIter.length()>1) { + targetParameterIter.append(","); + } + targetParameterIter.append("'"); + targetParameterIter.append(targetParameter); + targetParameterIter.append("'"); } targetParameterIter.append("]"); this.appendContentUrl(imgSrc, "/images/fieldlookup.gif"); @@ -1939,7 +1939,7 @@ } public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - boolean ajaxEnabled = false; + boolean ajaxEnabled = false; List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas(); String targetService = modelForm.getPaginateTarget(context); if (this.javaScriptEnabled) { @@ -2046,15 +2046,15 @@ if (viewIndex > 0) { if (ajaxEnabled) { - ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); + ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); } else { - linkText = prepLinkText + 0 + anchor; + linkText = prepLinkText + 0 + anchor; firstUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (viewIndex > 0) { if (ajaxEnabled) { - ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); + ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex - 1) + anchor; previousUrl = rh.makeLink(this.request, this.response, urlPath + linkText); @@ -2063,7 +2063,7 @@ // Page select dropdown if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { - ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); + ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); } else { linkText = prepLinkText; if (linkText.startsWith("/")) { @@ -2076,7 +2076,7 @@ // Next button if (highIndex < listSize) { if (ajaxEnabled) { - ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); + ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex + 1) + anchor; nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText); @@ -2086,7 +2086,7 @@ // Last button if (highIndex < listSize) { if (ajaxEnabled) { - ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (listSize / viewSize) + anchor, context); + ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (listSize / viewSize) + anchor, context); } else { linkText = prepLinkText + (listSize / viewSize) + anchor; lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText); @@ -2209,7 +2209,7 @@ } public void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField) throws IOException { - ModelFormField modelFormField = passwordField.getModelFormField(); + ModelFormField modelFormField = passwordField.getModelFormField(); String className = ""; String alert = "false"; @@ -2657,11 +2657,11 @@ public void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { String requiredField = "false"; String requiredStyle = ""; - if (modelFormField.getRequiredField()) { - requiredField = "true"; - requiredStyle = modelFormField.getRequiredFieldStyle(); + if (modelFormField.getRequiredField()) { + requiredField = "true"; + requiredStyle = modelFormField.getRequiredFieldStyle(); } - StringWriter sr = new StringWriter(); + StringWriter sr = new StringWriter(); sr.append("<@renderAsterisks "); sr.append("requiredField=\""); sr.append(requiredField); @@ -2722,7 +2722,7 @@ } if (UtilValidate.isNotEmpty(request.getAttribute("image"))) { - imgSrc = request.getAttribute("image").toString(); + imgSrc = request.getAttribute("image").toString(); } StringWriter sr = new StringWriter(); @@ -2751,9 +2751,9 @@ public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField); - String event = ""; - String action = ""; - String imgSrc = ""; + String event = ""; + String action = ""; + String imgSrc = ""; if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) { event = modelFormField.getEvent(); @@ -2761,7 +2761,7 @@ } if (UtilValidate.isNotEmpty(request.getAttribute("image"))) { - imgSrc = request.getAttribute("image").toString(); + imgSrc = request.getAttribute("image").toString(); } StringWriter sr = new StringWriter(); @@ -2784,21 +2784,21 @@ } public void makeHiddenFormLinkForm(Appendable writer, String target, String targetType, String targetWindow, List<WidgetWorker.Parameter> parameterList, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { - StringBuilder actionUrl = new StringBuilder(); - WidgetWorker.buildHyperlinkUrl(actionUrl, target, targetType, null, null, false, false, true, request, response, context); + StringBuilder actionUrl = new StringBuilder(); + WidgetWorker.buildHyperlinkUrl(actionUrl, target, targetType, null, null, false, false, true, request, response, context); String name = WidgetWorker.makeLinkHiddenFormName(context, modelFormField); - StringBuilder parameters = new StringBuilder(); - parameters.append("["); + StringBuilder parameters = new StringBuilder(); + parameters.append("["); for (WidgetWorker.Parameter parameter: parameterList) { - if (parameters.length() > 1) { - parameters.append(","); + if (parameters.length() > 1) { + parameters.append(","); } - parameters.append("{'name':'"); - parameters.append(parameter.getName()); - parameters.append("'"); - parameters.append(",'value':'"); - parameters.append(parameter.getValue(context)); - parameters.append("'}"); + parameters.append("{'name':'"); + parameters.append(parameter.getName()); + parameters.append("'"); + parameters.append(",'value':'"); + parameters.append(parameter.getValue(context)); + parameters.append("'}"); } parameters.append("]"); Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Mon Aug 17 11:01:25 2009 @@ -146,7 +146,7 @@ <script type='text/javascript' language='JavaScript'><!-- disa = ' disabled'; if(other_choice(document.${formName}.${fieldName})) - disa = ''; + disa = ''; document.write("<input type='text' name='${otherFieldName}' value='${otherValue}' size='${otherFieldSize}'"+disa+" onfocus='check_choice(document.${formName}.${fieldName})' />"); if(disa && document.styleSheets) document.${formName}.${fieldName}.style.visibility = 'hidden'; @@ -313,7 +313,7 @@ <#macro renderTextFindField name value defaultOption opEquals opBeginsWith opContains opIsEmpty opNotEqual className alert size maxlength autocomplete titleStyle hideIgnoreCase ignCase ignoreCase> <#if opEquals?has_content> -<select <#if name?has_content>name="${name}_op"</#if> class="selectBox"><#rt/> +<select <#if name?has_content>name="${name}_op"</#if> class="selectBox"><#rt/> <option value="equals"<#if defaultOption=="equals"> selected</#if>>${opEquals}</option><#rt/> <option value="like"<#if defaultOption=="like"> selected</#if>>${opBeginsWith}</option><#rt/> <option value="contains"<#if defaultOption=="contains"> selected</#if>>${opContains}</option><#rt/> @@ -321,7 +321,7 @@ <option value="notEqual"<#if defaultOption=="notEqual"> selected</#if>>${opNotEqual}</option><#rt/> </select> <#else> -<input type="hidden" name=<#if name?has_content> "${name}_op"</#if> value="${defaultOption}"/><#rt/> +<input type="hidden" name=<#if name?has_content> "${name}_op"</#if> value="${defaultOption}"/><#rt/> </#if> <input type="text" <@renderClass className alert /> name="${name}"<#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/> <#if titleStyle?has_content><span class="${titleStyle}" ><#rt/></#if> Modified: ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java (original) +++ ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java Mon Aug 17 11:01:25 2009 @@ -210,32 +210,32 @@ // create security group(s) Timestamp now = UtilDateTime.nowTimestamp(); for (String securityGroup : user.getUserGroupMapper().getSecurityGroups()) { - // check and make sure the security group exists - GenericValue secGroup = null; - try { - secGroup = delegator.findOne("SecurityGroup", UtilMisc.toMap("groupId", securityGroup), true); - } catch (GenericEntityException e) { - Debug.logError(e, e.getMessage(), module); - } - - // add it to the user if it exists - if (secGroup != null) { - Map<String, Serializable> createSecGrpMap = FastMap.newInstance(); - createSecGrpMap.put("userLoginId", user.getName()); - createSecGrpMap.put("groupId", securityGroup); - createSecGrpMap.put("fromDate", now); - createSecGrpMap.put("userLogin", system); - - Map<String, Object> createSecGrpResult; - try { - createSecGrpResult = dispatcher.runSync("addUserLoginToSecurityGroup", createSecGrpMap); - } catch (GenericServiceException e) { - throw new AuthenticatorException(e.getMessage(), e); - } - if (ServiceUtil.isError(createSecGrpResult)) { - throw new AuthenticatorException(ServiceUtil.getErrorMessage(createSecGrpResult)); - } - } + // check and make sure the security group exists + GenericValue secGroup = null; + try { + secGroup = delegator.findOne("SecurityGroup", UtilMisc.toMap("groupId", securityGroup), true); + } catch (GenericEntityException e) { + Debug.logError(e, e.getMessage(), module); + } + + // add it to the user if it exists + if (secGroup != null) { + Map<String, Serializable> createSecGrpMap = FastMap.newInstance(); + createSecGrpMap.put("userLoginId", user.getName()); + createSecGrpMap.put("groupId", securityGroup); + createSecGrpMap.put("fromDate", now); + createSecGrpMap.put("userLogin", system); + + Map<String, Object> createSecGrpResult; + try { + createSecGrpResult = dispatcher.runSync("addUserLoginToSecurityGroup", createSecGrpMap); + } catch (GenericServiceException e) { + throw new AuthenticatorException(e.getMessage(), e); + } + if (ServiceUtil.isError(createSecGrpResult)) { + throw new AuthenticatorException(ServiceUtil.getErrorMessage(createSecGrpResult)); + } + } } } Modified: ofbiz/trunk/specialpurpose/ecommerce/templates/email/emailpayretry.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/templates/email/emailpayretry.ftl?rev=804935&r1=804934&r2=804935&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/templates/email/emailpayretry.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/templates/email/emailpayretry.ftl Mon Aug 17 11:01:25 2009 @@ -19,11 +19,11 @@ <BR> <#if orderHeader.statusId == "ORDER_REJECTED"> - ${uiLabelMap.OrderEmailProblemWithYourPaymentMethod} ${orderHeader.orderId}.<br/> - ${uiLabelMap.OrderEmailProblemCancelledNotProcessed}<br/> + ${uiLabelMap.OrderEmailProblemWithYourPaymentMethod} ${orderHeader.orderId}.<br/> + ${uiLabelMap.OrderEmailProblemCancelledNotProcessed}<br/> <#elseif orderHeader.statusId == "ORDER_APPROVED"> - ${uiLabelMap.OrderEmailPaymentOK} ${orderHeader.orderId} ${uiLabelMap.OrderEmailAccepted} + ${uiLabelMap.OrderEmailPaymentOK} ${orderHeader.orderId} ${uiLabelMap.OrderEmailAccepted} <#else> - ${uiLabelMap.OrderEmailSorry} ${orderHeader.orderId}.<br/> + ${uiLabelMap.OrderEmailSorry} ${orderHeader.orderId}.<br/> </#if> - <br/>${uiLabelMap.OrderEmailCustomerService} ([hidden email])<br/> <#-- Customer service email (not a variable why?) must be adapted - JLR 1/6/5 --> + <br/>${uiLabelMap.OrderEmailCustomerService} ([hidden email])<br/> <#-- Customer service email (not a variable why?) must be adapted - JLR 1/6/5 --> |
Free forum by Nabble | Edit this page |