[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit ParsedHTML.java,1.4,1.5 ReceivedPage.java
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2000-09-25 21:28:48
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv21823/src/com/meterware/httpunit Modified Files: ParsedHTML.java ReceivedPage.java WebForm.java Log Message: Support the checkbox value parameter Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ParsedHTML.java 2000/09/01 14:54:03 1.4 +++ ParsedHTML.java 2000/09/25 21:28:44 1.5 @@ -198,10 +198,14 @@ if (tables[i].getCellAsText(0,0).equalsIgnoreCase( text )) { return tables[i]; } else { - WebTable[] innerTables = tables[i].getTableCell(0,0).getTables(); - if (innerTables.length != 0) { - WebTable result = getTableStartingWith( text, innerTables ); - if (result != null) return result; + for (int j = 0; j < tables[i].getRowCount(); j++) { + for (int k = 0; k < tables[i].getColumnCount(); k++) { + WebTable[] innerTables = tables[i].getTableCell(j,k).getTables(); + if (innerTables.length != 0) { + WebTable result = getTableStartingWith( text, innerTables ); + if (result != null) return result; + } + } } } } @@ -220,10 +224,14 @@ if (tables[i].getCellAsText(0,0).toUpperCase().startsWith( text )) { return tables[i]; } else { - WebTable[] innerTables = tables[i].getTableCell(0,0).getTables(); - if (innerTables.length != 0) { - WebTable result = getTableStartingWithPrefix( text, innerTables ); - if (result != null) return result; + for (int j = 0; j < tables[i].getRowCount(); j++) { + for (int k = 0; k < tables[i].getColumnCount(); k++) { + WebTable[] innerTables = tables[i].getTableCell(j,k).getTables(); + if (innerTables.length != 0) { + WebTable result = getTableStartingWithPrefix( text, innerTables ); + if (result != null) return result; + } + } } } } Index: ReceivedPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ReceivedPage.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ReceivedPage.java 2000/09/15 16:38:44 1.5 +++ ReceivedPage.java 2000/09/25 21:28:44 1.6 @@ -48,6 +48,8 @@ **/ public String getTitle() throws SAXException { NodeList nl = ((Document) getDOM()).getElementsByTagName( "title" ); + if (nl.getLength() == 0) return ""; + if (!nl.item(0).hasChildNodes()) return ""; return nl.item(0).getFirstChild().getNodeValue(); } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebForm.java 2000/09/15 16:38:44 1.7 +++ WebForm.java 2000/09/25 21:28:44 1.8 @@ -231,7 +231,13 @@ } else if (type.equals( "RADIO" ) && parameters[i].getNamedItem( "checked" ) != null) { defaults.put( name, value ); } else if (type.equals( "CHECKBOX" ) && parameters[i].getNamedItem( "checked" ) != null) { - defaults.put( name, "on" ); + if (value.length() == 0) value = "on"; + String[] currentDefaults = (String[]) defaults.get( name ); + if (currentDefaults == null) { + defaults.put( name, new String[] { value } ); + } else { + defaults.put( name, withNewValue( currentDefaults, value ) ); + } } } HTMLSelectElement[] selections = getSelections(); @@ -265,22 +271,20 @@ if (_optionValues == null) { Hashtable options = new Hashtable(); NamedNodeMap[] parameters = getParameters(); - Hashtable types = new Hashtable(); for (int i = 0; i < parameters.length; i++) { String name = getValue( parameters[i].getNamedItem( "name" ) ); String value = getValue( parameters[i].getNamedItem( "value" ) ); String type = getValue( parameters[i].getNamedItem( "type" ) ).toUpperCase(); if (type == null) type = "TEXT"; - if (type.equals( "RADIO" )) { + if (type.equals( "RADIO" ) || type.equals( "CHECKBOX" )) { + if (value.length() == 0 && type.equals( "CHECKBOX" )) value = "on"; String[] radioOptions = (String[]) options.get( name ); if (radioOptions == null) { options.put( name, new String[] { value } ); } else { options.put( name, withNewValue( radioOptions, value ) ); } - } else if (type.equals( "CHECKBOX" )) { - options.put( name, new String[] { "on" } ); } } HTMLSelectElement[] selections = getSelections(); @@ -307,7 +311,6 @@ Hashtable types = new Hashtable(); for (int i = 0; i < parameters.length; i++) { String name = getValue( parameters[i].getNamedItem( "name" ) ); - String value = getValue( parameters[i].getNamedItem( "value" ) ); String type = getValue( parameters[i].getNamedItem( "type" ) ).toUpperCase(); if (type == null) type = "TEXT"; @@ -316,7 +319,7 @@ } else if (type.equals( "RADIO" )) { types.put( name, TYPE_SCALAR ); } else if (type.equals( "CHECKBOX" )) { - types.put( name, TYPE_SCALAR ); + types.put( name, TYPE_MULTI_VALUED ); } } HTMLSelectElement[] selections = getSelections(); |