1 25 26 package org.objectweb.jonas.jonasadmin.test.util; 27 28 import org.xml.sax.SAXException ; 29 30 import com.meterware.httpunit.TableCell; 31 import com.meterware.httpunit.WebResponse; 32 import com.meterware.httpunit.WebTable; 33 34 39 public class JonasAdminUtils { 40 41 46 public class CoordCell { 47 48 51 private Integer row = null; 52 53 56 private Integer column = null; 57 58 63 public CoordCell (Integer row, Integer column) { 64 this.row = row; 65 this.column = column; 66 } 67 68 72 public Integer getColumn() { 73 return column; 74 } 75 76 80 public void setColumn(Integer column) { 81 this.column = column; 82 } 83 84 88 public Integer getRow() { 89 return row; 90 } 91 92 96 public void setRow(Integer row) { 97 this.row = row; 98 } 99 } 100 101 107 public Integer getRow(String text, WebTable table) { 108 Integer row = new Integer (-1); 109 TableCell cell; 110 for (int i = 0; i < table.getRowCount(); i++) { 111 cell = table.getTableCell(i, 0); 112 if (cell.getText().indexOf(text) != -1) { 113 row = new Integer (i); 114 } 115 } 116 return row; 117 } 118 119 126 public Integer getFirstRow(String text, WebTable table, int column) { 127 boolean found = false; 128 Integer row = new Integer (-1); 129 TableCell cell; 130 int i = 0; 131 while (i < table.getRowCount() && !found) { 132 cell = table.getTableCell(i, column); 133 if (cell != null && cell.getText().indexOf(text) != -1) { 134 row = new Integer (i); 135 found = true; 136 } 137 i++; 138 } 139 return row; 140 } 141 142 149 public Integer getRow(String text, WebTable table, int column) { 150 Integer row = new Integer (-1); 151 TableCell cell; 152 for (int i = 0; i < table.getRowCount(); i++) { 153 cell = table.getTableCell(i, column); 154 if (cell.getText().indexOf(text) != -1) { 155 row = new Integer (i); 156 } 157 } 158 return row; 159 } 160 161 167 public Integer getColumn(String text, WebTable table) { 168 Integer column = new Integer (-1); 169 TableCell cell; 170 for (int i = 0; i < table.getColumnCount(); i++) { 171 cell = table.getTableCell(0, i); 172 if (cell.getText().indexOf(text) != -1) { 173 column = new Integer (i); 174 } 175 } 176 return column; 177 } 178 179 184 public CoordCell getSelectedItemRow(WebTable table) { 185 Integer row = null; 186 Integer column = null; 187 TableCell cell = null; 188 CoordCell coord = null; 189 String attribut; 190 boolean found = false; 191 int i = 0; 192 int j = 0; 193 194 while (i < table.getRowCount() && !found) { 195 j = 0; 196 while (j < table.getColumnCount() && !found) { 197 cell = table.getTableCell(i, j); 198 if (cell.getElementsWithAttribute("class", "tree-control-selected").length == 1) { 199 found = true; 200 row = new Integer (i); 201 column = new Integer (j); 202 coord = new CoordCell(row, column); 203 } 204 j++; 205 } 206 i++; 207 } 208 return coord; 209 } 210 211 218 public WebTable getTable(WebResponse contentFrame, int num) throws SAXException { 219 WebTable table = contentFrame.getTables()[1]; 220 TableCell cell = table.getTableCell(1, 0); 221 table = cell.getTables()[0]; 222 cell = table.getTableCell(0, 0); 223 table = cell.getTables()[0]; 224 cell = table.getTableCell(0, 0); 225 table = cell.getTables()[num]; 227 return table; 228 } 229 230 236 public WebTable getTabTable(WebResponse contentFrame) throws SAXException { 237 WebTable table = contentFrame.getTables()[1]; 238 TableCell cell = table.getTableCell(0, 0); 239 table = cell.getTables()[0]; 240 return table; 241 } 242 } 243 | Popular Tags |