Source Code Cross Referenced for FixtureTest.java in  » Wiki-Engine » fitnesse » fit » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
002:        // Copyright (c) 2002 Cunningham & Cunningham, Inc.
003:        // Released under the terms of the GNU General Public License version 2 or later.
004:        package fit;
005:
006:        import java.text.ParseException;
007:        import java.util.Date;
008:        import java.util.Locale;
009:
010:        import fitnesse.testutil.RegexTest;
011:
012:        public class FixtureTest extends RegexTest {
013:            private Locale saveLocale;
014:
015:            static class HasParseMethod {
016:                public static Object parse(String s) {
017:                    return s + " found";
018:                }
019:            }
020:
021:            static class HasNoParseMethod {
022:            }
023:
024:            @Override
025:            protected void setUp() throws Exception {
026:                super .setUp();
027:                saveLocale = Locale.getDefault();
028:                Locale.setDefault(Locale.US);
029:            }
030:
031:            @Override
032:            protected void tearDown() throws Exception {
033:                super .tearDown();
034:                Locale.setDefault(saveLocale);
035:            }
036:
037:            public void testHasParseMethod() throws Exception {
038:                assertTrue(Fixture.hasParseMethod(HasParseMethod.class));
039:                assertFalse(Fixture.hasParseMethod(HasNoParseMethod.class));
040:            }
041:
042:            public void testCallParseMethod() throws Exception {
043:                Object o = Fixture.callParseMethod(HasParseMethod.class,
044:                        "target");
045:                assertTrue(o instanceof  String);
046:                String s = (String) o;
047:                assertEquals("target found", s);
048:            }
049:
050:            public void testObjectWithParseMethod() throws Exception {
051:                Fixture f = new Fixture();
052:                Object o = f.parse("target", HasParseMethod.class);
053:                assertTrue(o instanceof  String);
054:                assertEquals("target found", (String) o);
055:
056:                try {
057:                    f.parse("target", HasNoParseMethod.class);
058:                    fail();
059:                } catch (Exception e) {
060:                    assertTrue(e.getMessage().startsWith("Could not parse"));
061:                }
062:            }
063:
064:            public void testScientificDouble() throws Exception {
065:                Fixture f = new Fixture();
066:                Object o = f.parse("13.4", ScientificDouble.class);
067:                assertTrue(o instanceof  ScientificDouble);
068:                assertEquals(new ScientificDouble(13.4), o);
069:            }
070:
071:            public void testRelationalMatching() throws Exception {
072:                final String[][] table = {
073:                        { "fitnesse.fixtures.ColumnFixtureTestFixture" },
074:                        { "input", "output?" }, { "1", "_>0" } };
075:                Parse page = executeFixture(table);
076:                String colTwoResult = page.at(0, 2, 1).body;
077:                assertTrue(colTwoResult.indexOf("<b>1</b>>0") != -1);
078:                String colTwoTag = page.at(0, 2, 1).tag;
079:                assertTrue(colTwoTag.indexOf("pass") != -1);
080:            }
081:
082:            public void testNullAndBlankStrings() throws Exception {
083:                Fixture fixture = new Fixture();
084:                assertNull(fixture.parse("null", String.class));
085:                assertEquals("", fixture.parse("blank", String.class));
086:
087:                TypeAdapter adapter = new TypeAdapter();
088:                assertEquals("null", adapter.toString((String) null));
089:                assertEquals("blank", adapter.toString(""));
090:            }
091:
092:            public void testEscape() {
093:                String junk = "!@#$%^*()_-+={}|[]\\:\";',./?`";
094:                assertEquals(junk, Fixture.escape(junk));
095:                assertEquals("", Fixture.escape(""));
096:                assertEquals("&lt;", Fixture.escape("<"));
097:                assertEquals("&lt;&lt;", Fixture.escape("<<"));
098:                assertEquals("x&lt;", Fixture.escape("x<"));
099:                assertEquals("&amp;", Fixture.escape("&"));
100:                assertEquals("&lt;&amp;&lt;", Fixture.escape("<&<"));
101:                assertEquals("&amp;&lt;&amp;", Fixture.escape("&<&"));
102:                assertEquals("a &lt; b &amp;&amp; c &lt; d", Fixture
103:                        .escape("a < b && c < d"));
104:            }
105:
106:            public void testFixtureArguments() throws Exception {
107:                String prefix = "<table><tr><td>fit.Fixture</td>";
108:                String suffix = "</tr></table>";
109:                Fixture f = new Fixture();
110:
111:                Parse table = new Parse(prefix + "<td>1</td>" + suffix);
112:                f.getArgsForTable(table);
113:                String[] args = f.getArgs();
114:                assertEquals(1, args.length);
115:                assertEquals("1", args[0]);
116:
117:                table = new Parse(prefix + "" + suffix);
118:                f.getArgsForTable(table);
119:                args = f.getArgs();
120:                assertEquals(0, args.length);
121:
122:                table = new Parse(prefix + "<td>1</td><td>2</td>" + suffix);
123:                f.getArgsForTable(table);
124:                args = f.getArgs();
125:                assertEquals(2, args.length);
126:                assertEquals("1", args[0]);
127:                assertEquals("2", args[1]);
128:            }
129:
130:            public void testParseDate() throws Exception {
131:                Fixture f = new Fixture();
132:                Object o = f.parse("1/2/2004", Date.class);
133:                assertEquals(java.util.Date.class, o.getClass());
134:            }
135:
136:            public static Parse executeFixture(String[][] table)
137:                    throws ParseException {
138:                String pageString = makeFixtureTable(table);
139:                Parse page = new Parse(pageString);
140:                Fixture fixture = new Fixture();
141:                fixture.doTables(page);
142:                return page;
143:            }
144:
145:            public void testCanChangeFriendlyExceptions() throws Exception {
146:                Fixture fixture = new Fixture() {
147:                    public boolean isFriendlyException(Throwable exception) {
148:                        return true;
149:                    }
150:                };
151:
152:                Parse cell = new Parse("td", "", null, null);
153:                fixture.exception(cell, new NullPointerException(
154:                        "gobble gobble"));
155:                assertSubString("gobble gobble", cell.body);
156:                assertNotSubString("Exception", cell.body);
157:            }
158:
159:            public void testClearingSymbols() throws Exception {
160:                Fixture.setSymbol("blah", "blah");
161:                assertEquals("blah", Fixture.getSymbol("blah"));
162:
163:                Fixture.ClearSymbols();
164:                assertEquals(null, Fixture.getSymbol("blah"));
165:            }
166:
167:            private static String makeFixtureTable(String table[][]) {
168:                StringBuffer buf = new StringBuffer();
169:                buf.append("<table>\n");
170:                for (int ri = 0; ri < table.length; ri++) {
171:                    buf.append("  <tr>");
172:                    String[] row = table[ri];
173:                    for (int ci = 0; ci < row.length; ci++) {
174:                        String cell = row[ci];
175:                        buf.append("<td>").append(cell).append("</td>");
176:                    }
177:                    buf.append("</tr>\n");
178:                }
179:                buf.append("</table>\n");
180:                return buf.toString();
181:            }
182:        }
183:
184:        class FixtureOne extends Fixture {
185:        }
186:
187:        class FixtureTwo extends Fixture {
188:        }
189:
190:        class TheThirdFixture extends Fixture {
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.