Update of /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8308/src/net/sourceforge/jwebunit
Modified Files:
WebTester.java WebTestCase.java
Log Message:
bug 897022 fix : allow users to disable table compression
Index: WebTester.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** WebTester.java 29 Aug 2004 19:04:26 -0000 1.50
--- WebTester.java 16 Sep 2004 16:41:38 -0000 1.51
***************
*** 29,32 ****
--- 29,34 ----
private TestContext context = new TestContext();
+
+ private boolean tableEmptyCellCompression = true;
/**
***************
*** 333,356 ****
String[][] expectedCellValues) {
assertTablePresent(tableSummaryOrId);
! String[][] sparseTableCellValues = dialog
! .getSparseTableBySummaryOrId(tableSummaryOrId);
! if (expectedCellValues.length > (sparseTableCellValues.length - startRow))
Assert.fail("Expected rows [" + expectedCellValues.length
+ "] larger than actual rows in range being compared"
! + " [" + (sparseTableCellValues.length - startRow)
+ "].");
for (int i = 0; i < expectedCellValues.length; i++) {
String[] row = expectedCellValues[i];
for (int j = 0; j < row.length; j++) {
! if (row.length != sparseTableCellValues[i].length)
Assert.fail("Unequal number of columns for row " + i
+ " of table " + tableSummaryOrId
+ ". Expected [" + row.length + "] found ["
! + sparseTableCellValues[i].length + "].");
String expectedString = row[j];
Assert.assertEquals("Expected " + tableSummaryOrId
+ " value at [" + i + "," + j + "] not found.",
expectedString, context
! .toEncodedString(sparseTableCellValues[i
+ startRow][j].trim()));
}
--- 335,362 ----
String[][] expectedCellValues) {
assertTablePresent(tableSummaryOrId);
! String[][] actualTableCellValues;
! if (tableEmptyCellCompression) {
! actualTableCellValues =
dialog.getSparseTableBySummaryOrId(tableSummaryOrId);
! } else {
! actualTableCellValues =
dialog.getWebTableBySummaryOrId(tableSummaryOrId).asText();
! }
! if (expectedCellValues.length > (actualTableCellValues.length - startRow))
Assert.fail("Expected rows [" + expectedCellValues.length
+ "] larger than actual rows in range being compared"
! + " [" + (actualTableCellValues.length - startRow)
+ "].");
for (int i = 0; i < expectedCellValues.length; i++) {
String[] row = expectedCellValues[i];
for (int j = 0; j < row.length; j++) {
! if (row.length != actualTableCellValues[i].length)
Assert.fail("Unequal number of columns for row " + i
+ " of table " + tableSummaryOrId
+ ". Expected [" + row.length + "] found ["
! + actualTableCellValues[i].length + "].");
String expectedString = row[j];
Assert.assertEquals("Expected " + tableSummaryOrId
+ " value at [" + i + "," + j + "] not found.",
expectedString, context
! .toEncodedString(actualTableCellValues[i
+ startRow][j].trim()));
}
***************
*** 1231,1234 ****
--- 1237,1269 ----
dialog.dumpTable(tableNameOrId, table, stream);
}
+
+ //Settings
+ /**
+ * This setting controls whether the tester will compress html tables before
+ * compaing them against expecteds via table assertions. Compression means that
+ * rows with no displayable contents in their cells are eliminated before
comparison,
+ * and also that empty cells in a row are discarded except as padding at the end
of
+ * a row to reach the number of columns needed for non-empty content.
+ *
+ * The default is compression true. The point of compressing the table before
comparison
+ * is to prevent testers from having to worry about testing table spacing rather
than content.
+ *
+ * Confused? Example:
+ *
+ * If compression is true the following html table (,'s mark cell divisions):
+ *
+ * alpha,beta,charlie
+ * delta, ,echo,
+ * , ,
+ * ,foxtrot,
+ *
+ * Will be compressed to the following before comparison with actual.
+ * alpha,beta,charlie
+ * delta,echo,
+ * foxtrot, ,
+ */
+ public void setTableEmptyCellCompression(boolean bool) {
+ this.tableEmptyCellCompression = bool;
+ }
}
\ No newline at end of file
Index: WebTestCase.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTestCase.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** WebTestCase.java 29 Aug 2004 19:04:26 -0000 1.47
--- WebTestCase.java 16 Sep 2004 16:41:38 -0000 1.48
***************
*** 461,464 ****
--- 461,470 ----
tester.dumpTable(tableNameOrId, table);
}
+
+ //Settings
+
+ public void setTableEmptyCellCompression(boolean bool) {
+ tester.setTableEmptyCellCompression(bool);
+ }
}
\ No newline at end of file
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jwebunit-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development