Author: doogie
Date: Tue Sep 8 02:22:05 2009 New Revision: 812320 URL: http://svn.apache.org/viewvc?rev=812320&view=rev Log: Generics, enhanced-for, similiar changes to the other java 1.5 patches. Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/TestUtils.java Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java?rev=812320&r1=812319&r2=812320&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java Tue Sep 8 02:22:05 2009 @@ -18,10 +18,11 @@ */ package org.ofbiz.testtools.seleniumxml; -import java.util.HashMap; import java.util.List; import java.util.Map; +import javolution.util.FastMap; + import org.jdom.Element; import org.python.core.PyArray; import org.python.core.PyDictionary; @@ -35,7 +36,7 @@ private String iterations; private SeleniumXml parent; private SeleniumXml currentTest; - private List children; + private List<Element> children; private int currentRowIndx; @@ -62,7 +63,7 @@ // Read header and get record count PythonInterpreter interp = InitJython.getInterpreter(); - Map map = new HashMap(); + Map<String, Object> map = FastMap.newInstance(); map.put("file", this.file); interp.set("params", map); interp.exec("from csvreader import CSVReader"); Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java?rev=812320&r1=812319&r2=812320&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java Tue Sep 8 02:22:05 2009 @@ -31,12 +31,14 @@ import org.python.core.PyObject; import org.python.util.PythonInterpreter; +import org.ofbiz.base.util.UtilGenerics; + public class DataLoop { private String dataListName; private SeleniumXml parent; private SeleniumXml currentTest; - private List children; + private List<Element> children; private int currentRowIndx; @@ -52,17 +54,12 @@ public void runTest() { this.currentTest = new SeleniumXml(this.parent); - Map dataMap = this.parent.getMap(); - List dataList = (List)dataMap.get(this.dataListName); - Iterator iter = dataList.iterator(); - while (iter.hasNext()) { - Map mp = (Map)iter.next(); + Map<String, Object> dataMap = this.parent.getMap(); + List<Map<String, Object>> dataList = UtilGenerics.cast(dataMap.get(this.dataListName)); + for (Map<String, Object> mp: dataList) { // TODO, WARNING - these name could collide with names already in the test context - Set eSet = mp.entrySet(); - Iterator iter2 = eSet.iterator(); - while (iter2.hasNext()) { - Map.Entry entry = (Map.Entry)iter2.next(); - String name = (String)entry.getKey(); + for (Map.Entry<String, Object> entry: mp.entrySet()) { + String name = entry.getKey(); Object value = entry.getValue(); dataMap.put(name, value); } 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=812320&r1=812319&r2=812320&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 Tue Sep 8 02:22:05 2009 @@ -53,7 +53,7 @@ public void runTest() { - Map map = this.parent.getMap(); + Map<String, Object> map = this.parent.getMap(); map.put("url", this.urlName); try { String scriptText = TestUtils.readUrlText(this.urlName); 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=812320&r1=812319&r2=812320&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 Tue Sep 8 02:22:05 2009 @@ -55,7 +55,7 @@ PythonInterpreter interp = InitJython.getInterpreter(); - Map map = this.parent.getMap(); + Map<String, Object> map = this.parent.getMap(); map.put("url", this.urlName); try { String scriptText = TestUtils.readUrlText(this.urlName); Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java?rev=812320&r1=812319&r2=812320&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java (original) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java Tue Sep 8 02:22:05 2009 @@ -21,12 +21,13 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import javolution.util.FastMap; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpHost; @@ -124,8 +125,8 @@ private void initData() { - this.inMap = new HashMap(); - this.outMap = new HashMap(); + this.inMap = FastMap.newInstance(); + this.outMap = FastMap.newInstance(); String nm, name, value, fieldName = null; for(Element elem: this.children) { nm = elem.getName(); @@ -318,7 +319,7 @@ } Set<Map.Entry<String, String>> paramSet = this.parentRemoteRequest.outMap.entrySet(); Iterator<Map.Entry<String, String>> paramIter = paramSet.iterator(); - Map parentDataMap = this.parentRemoteRequest.parent.getMap(); + Map<String, Object> parentDataMap = this.parentRemoteRequest.parent.getMap(); while (paramIter.hasNext()) { Map.Entry<String, String> paramPair = paramIter.next(); if (jsonObject.containsKey(paramPair.getKey())) { 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=812320&r1=812319&r2=812320&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 Tue Sep 8 02:22:05 2009 @@ -40,6 +40,8 @@ import org.jdom.xpath.XPath; import org.xml.sax.SAXException; +import org.ofbiz.base.util.UtilGenerics; + public class SeleniumIDEConverter { private Document ideFile; @@ -80,8 +82,8 @@ 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); + List<Element> list = UtilGenerics.cast(e3.getChildren("tr", ns)); + List<Element> commands = UtilGenerics.cast(root.getChild("body",ns).getChild("table",ns).getChild("tbody",ns).getChildren("tr", ns)); for(Element elem: commands) { processIDECommand(elem); } @@ -91,7 +93,7 @@ private void processIDECommand(Element elem) throws JDOMException { - List<Element> cmd = elem.getChildren("td", ns); + List<Element> cmd = UtilGenerics.cast(elem.getChildren("td", ns)); Element cmdElem = cmd.get(0); String cmdToCompare = cmdElem.getValue(); 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=812320&r1=812319&r2=812320&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 Tue Sep 8 02:22:05 2009 @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; -import java.util.HashMap; import java.util.List; import java.util.ArrayList; import java.util.Map; @@ -32,6 +31,8 @@ import java.util.regex.Pattern; import java.lang.reflect.*; +import javolution.util.FastMap; + import junit.framework.Assert; import org.apache.commons.lang.RandomStringUtils; @@ -43,6 +44,7 @@ import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.testtools.seleniumxml.util.TestUtils; import com.thoughtworks.selenium.DefaultSelenium; @@ -83,7 +85,7 @@ } public SeleniumXml() throws IOException { - this.map = new HashMap<String, Object>(); + this.map = FastMap.newInstance(); if (props == null) { props = new Properties(); initConfig(); @@ -134,7 +136,7 @@ public void runCommands() { Element root = this.doc.getRootElement(); - List<Element> nodes = root.getChildren(); + List<Element> nodes = UtilGenerics.cast(root.getChildren()); runCommands(nodes); } @@ -310,7 +312,7 @@ String file = elem.getAttributeValue("file"); String iterations = elem.getAttributeValue("iterations"); - List children = elem.getChildren(); + List<Element> children = UtilGenerics.cast(elem.getChildren()); DataLoader loader = new DataLoader(file, iterations, this, children); loader.runTest(); @@ -333,7 +335,7 @@ public void dataLoop(Element elem) { String dataListName = elem.getAttributeValue("dataListName"); - List children = elem.getChildren(); + List<Element> children = UtilGenerics.cast(elem.getChildren()); DataLoop looper = new DataLoop(dataListName, this, children); looper.runTest(); @@ -347,7 +349,7 @@ host = props.getProperty("startUrl"); } String responseHandlerMode = elem.getAttributeValue("responseHandlerMode"); - List <Element> children = elem.getChildren(); + List <Element> children = UtilGenerics.cast(elem.getChildren()); RemoteRequest loader = new RemoteRequest(this, children, requestUrl, host, responseHandlerMode); loader.runTest(); @@ -398,12 +400,12 @@ private void getAllWindowIds(Element elem) { String[] winIds = this.sel.getAllWindowIds(); - for(int i=0; i<winIds.length; i++) { - logger.info("WindowId: " + winIds[i]); + for (String winId: winIds) { + logger.info("WindowId: " + winId); } String[] winNames = this.sel.getAllWindowNames(); - for(int i=0; i<winIds.length; i++) { - logger.info("WindowName: " + winNames[i]); + for (String winName: winNames) { + logger.info("WindowName: " + winName); } //this.sel.selectWindow("name=" + winNames[1]); @@ -638,7 +640,7 @@ } public String replaceParam(String value) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); int end = 0; int start = 0; String replacedVal = null; @@ -729,7 +731,7 @@ return this.password; } - public Map <String, ? extends Object> getMap() { + public Map <String, Object> getMap() { return this.map; } } 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=812320&r1=812319&r2=812320&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 Tue Sep 8 02:22:05 2009 @@ -49,7 +49,7 @@ } static public String createRandomString(String prefix, int size) { - StringBuffer buff = new StringBuffer(size); + StringBuilder buff = new StringBuilder(size); int startIndx = 0; if (prefix != null) { |
Free forum by Nabble | Edit this page |