Source Code Cross Referenced for TableTest.java in  » Wiki-Engine » fitnesse » fit » decorator » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » fitnesse » fit.decorator.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package fit.decorator.util;
002:
003:        import fit.Parse;
004:        import fit.decorator.exceptions.InvalidInputException;
005:        import junit.framework.TestCase;
006:
007:        public class TableTest extends TestCase {
008:            private String fitPage = "<table><tr><td>eg.Division</td></tr>"
009:                    + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
010:                    + "<tr><td>10</td><td>2</td><td>5</td></tr></table>";
011:            private Table table;
012:
013:            protected void setUp() throws Exception {
014:                super .setUp();
015:                table = new Table(fitPage);
016:            }
017:
018:            public void testToStringShouldParseTableWithMultipleRowsAndColumns()
019:                    throws Exception {
020:                assertTable(fitPage);
021:            }
022:
023:            public void testConstructorShouldBuildTableFromParseObject()
024:                    throws Exception {
025:                String expectedTableContents = "<tr><td>fit.decorator.MaxTime</td><td>10</td></tr>";
026:                Parse parse = new Parse(expectedTableContents, new String[] {
027:                        "tr", "td" });
028:                table = new Table(parse);
029:                assertTable(expectedTableContents);
030:            }
031:
032:            public void testCopyAndAppendLastRow() throws Exception {
033:                table.copyAndAppendLastRow(1);
034:                String expectedTableContents = "<table><tr><td>eg.Division</td></tr>"
035:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
036:                        + "<tr><td>10</td><td>2</td><td>5</td></tr>"
037:                        + "<tr><td>10</td><td>2</td><td>5</td></tr></table>";
038:                assertTable(expectedTableContents);
039:            }
040:
041:            public void testCopyAndAppendLastRowMultipleTimes()
042:                    throws Exception {
043:                table.copyAndAppendLastRow(3);
044:                String expectedTableContents = "<table><tr><td>eg.Division</td></tr>"
045:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
046:                        + "<tr><td>10</td><td>2</td><td>5</td></tr><tr><td>10</td><td>2</td><td>5</td></tr>"
047:                        + "<tr><td>10</td><td>2</td><td>5</td></tr>"
048:                        + "<tr><td>10</td><td>2</td><td>5</td></tr></table>";
049:                assertTable(expectedTableContents);
050:            }
051:
052:            public void testCopyAndAppendLastRowZeroTime() throws Exception {
053:                table.copyAndAppendLastRow(0);
054:                assertTable(fitPage);
055:            }
056:
057:            public void testIncrementColumnValueThrowsInvalidInputExceptionIfColumnNameIsNotFound()
058:                    throws Exception {
059:                try {
060:                    table.incrementColumnValues(1, "invalidColumnName", null);
061:                } catch (InvalidInputException e) {
062:                    assertEquals(
063:                            "'invalidColumnName' was not found in the table "
064:                                    + fitPage, e.getMessage());
065:                }
066:            }
067:
068:            public void testIncrementColumnValueShouldAddTheGivenDeltaToAllRowsOfTheGivenColumn()
069:                    throws Exception {
070:                table.incrementColumnValues("denominator",
071:                        new Delta("int", "1"), 1);
072:                assertTable(fitPage);
073:            }
074:
075:            public void testIncrementColumnValueShouldIncrementallyAddTheGivenDeltaMultipleTimes()
076:                    throws Exception {
077:                table.incrementColumnValues(3, "denominator", new Delta("int",
078:                        "1"));
079:                String expectedFitPage = "<table><tr><td>eg.Division</td></tr>"
080:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
081:                        + "<tr><td>10</td><td>2</td><td>5</td></tr><tr><td>10</td><td>3</td><td>5</td></tr>"
082:                        + "<tr><td>10</td><td>4</td><td>5</td></tr></table>";
083:                assertTable(expectedFitPage);
084:            }
085:
086:            public void testInsertAsFirstRow() throws Exception {
087:                Parse firstRow = new Parse("<tr><td>first row</td></tr>",
088:                        new String[] { "tr", "td" });
089:                table.insertAsFirstRow(firstRow);
090:                String expectedTableContents = "<table><tr><td>first row</td></tr><tr><td>eg.Division</td></tr>"
091:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
092:                        + "<tr><td>10</td><td>2</td><td>5</td></tr></table>";
093:                assertTable(expectedTableContents);
094:            }
095:
096:            public void testStripFirstRow() throws Exception {
097:                table.stripFirstRow();
098:                String expectedTableContents = "<table>"
099:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
100:                        + "<tr><td>10</td><td>2</td><td>5</td></tr></table>";
101:                assertTable(expectedTableContents);
102:            }
103:
104:            public void testColumnNumberShouldReturnColumnNumberForTheGivenColumnName()
105:                    throws Exception {
106:                assertEquals(0, table
107:                        .columnNumberContainingText("numerator", 1));
108:                assertEquals(1, table.columnNumberContainingText("denominator",
109:                        1));
110:                assertEquals(2, table.columnNumberContainingText("quotient()",
111:                        1));
112:            }
113:
114:            public void testColumnNumberShouldThrowsInvalidInputExceptionIfColumnNameIsNotFound()
115:                    throws Exception {
116:                try {
117:                    table.columnNumberContainingText("invalidColumnName", 1);
118:                } catch (InvalidInputException e) {
119:                    assertEquals(
120:                            "'invalidColumnName' was not found in the table "
121:                                    + fitPage, e.getMessage());
122:                }
123:            }
124:
125:            public void testColumnValueShouldReturnColumnValueForTheGivenColumnNumber()
126:                    throws Exception {
127:                assertEquals("10", table.columnValue(2, 0));
128:                assertEquals("2", table.columnValue(2, 1));
129:                assertEquals("5", table.columnValue(2, 2));
130:            }
131:
132:            public void testGetLastRow() throws Exception {
133:                Parse lastRow = table.lastRow();
134:                String expectedLastRow = "<tr><td>10</td><td>2</td><td>5</td></tr>";
135:                assertParseObject(expectedLastRow, lastRow);
136:            }
137:
138:            public void testGetSecondLastRow() throws Exception {
139:                String fitPage = "<table><tr><td>eg.Division</td></tr>"
140:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
141:                        + "<tr><td>10</td><td>2</td><td>5</td></tr>"
142:                        + "<tr><td>5</td><td>1</td><td>5</td></tr></table>";
143:                table = new Table(fitPage);
144:                Parse secondLastRow = table.secondLastRow(table.lastRow());
145:                String expectedSecondLastRow = "<tr><td>10</td><td>2</td><td>5</td></tr>";
146:                assertParseObject(expectedSecondLastRow, secondLastRow);
147:            }
148:
149:            public void testRowNumberContainingTextShouldReturnIndexOfTheRowContainingTheText()
150:                    throws Exception {
151:                assertEquals(0, table.rowNumberContainingText("eg.Division"));
152:                assertEquals(1, table.rowNumberContainingText("numerator"));
153:                assertEquals(1, table.rowNumberContainingText("denominator"));
154:            }
155:
156:            public void testRowNumberContainingTextShouldThrowInvalidInputExceptionIfSearchTextIsNotFound()
157:                    throws Exception {
158:                try {
159:                    table.rowNumberContainingText("invalidColumnName");
160:                } catch (InvalidInputException e) {
161:                    assertEquals(
162:                            "'invalidColumnName' was not found in the table "
163:                                    + fitPage, e.getMessage());
164:                }
165:            }
166:
167:            public void testCopyAndAppendLastRowShouldLeaveTheTableAsItIsIfTotalRowsAreLessThanThree()
168:                    throws Exception {
169:                String fitPage = "<table><tr><td>eg.Division</td></tr>"
170:                        + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr></table>";
171:                table = new Table(fitPage);
172:                table.copyAndAppendLastRow(4);
173:                assertTable(fitPage);
174:            }
175:
176:            private void assertTable(String expectedTableContents) {
177:                assertEquals(expectedTableContents, table.toString());
178:            }
179:
180:            private void assertParseObject(String expectedTableContents,
181:                    Parse parse) {
182:                assertEquals(expectedTableContents, new Table(parse).toString());
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.