Source Code Cross Referenced for FitClientTest.java in  » Testing » StoryTestIQ » fitnesse » components » 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 » Testing » StoryTestIQ » fitnesse.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002:        // Released under the terms of the GNU General Public License version 2 or later.
003:        package fitnesse.components;
004:
005:        import java.util.*;
006:        import fitnesse.testutil.*;
007:        import fitnesse.responders.run.SocketDealer;
008:        import fit.Counts;
009:
010:        public class FitClientTest extends AbstractRegex implements 
011:                FitClientListener {
012:            private List outputs = new ArrayList();
013:
014:            private List counts = new ArrayList();
015:
016:            public CommandRunningFitClient client;
017:
018:            private boolean exceptionOccurred = false;
019:
020:            private int port = 9080;
021:
022:            private FitSocketReceiver receiver;
023:
024:            SimpleSocketDoner doner;
025:
026:            public void setUp() throws Exception {
027:                CommandRunningFitClient.TIMEOUT = 5000;
028:                client = new CommandRunningFitClient(this ,
029:                        "java -cp classes fit.FitServer -v", port,
030:                        new SocketDealer());
031:                receiver = new CustomFitSocketReceiver(port);
032:            }
033:
034:            private class CustomFitSocketReceiver extends FitSocketReceiver {
035:                public CustomFitSocketReceiver(int port) {
036:                    super (port, null);
037:                }
038:
039:                protected void dealSocket(int ticket) throws Exception {
040:                    doner = new SimpleSocketDoner(socket);
041:                    client.acceptSocketFrom(doner);
042:                }
043:            }
044:
045:            public void tearDown() throws Exception {
046:                receiver.close();
047:            }
048:
049:            public void acceptOutput(String output) {
050:                outputs.add(output);
051:            }
052:
053:            public void acceptResults(Counts counts) {
054:                this .counts.add(counts);
055:            }
056:
057:            public void exceptionOccurred(Exception e) {
058:                exceptionOccurred = true;
059:                try {
060:                    client.kill();
061:                } catch (Exception e1) {
062:                    e1.printStackTrace();
063:                }
064:            }
065:
066:            public void XtestOneRunUsage() throws Exception {
067:                // FIXME is an integration test and expects something to be running
068:                // already
069:
070:                doSimpleRun();
071:                assertFalse(exceptionOccurred);
072:                assertEquals(1, outputs.size());
073:                assertEquals(1, counts.size());
074:                assertSubString("class", (String) outputs.get(0));
075:                assertEquals(1, ((Counts) counts.get(0)).right);
076:            }
077:
078:            private void doSimpleRun() throws Exception {
079:                receiver.receiveSocket();
080:                client.start();
081:                client
082:                        .send("<html><table><tr><td>fitnesse.testutil.PassFixture</td></tr></table></html>");
083:                client.done();
084:                client.join();
085:            }
086:
087:            public void testStandardError() throws Exception {
088:                client = new CommandRunningFitClient(this , "java blah", port,
089:                        new SocketDealer());
090:                client.start();
091:                client.join();
092:                assertTrue(exceptionOccurred);
093:                //		I have commented this out because the exception being thrown is "java.lang.NoClassDefFoundError: blah", and not an Exception.
094:                //		This may be because I'm building on JRockit jre1.5.0_06 instead of whatever the other developers are building against.
095:                //		assertSubString("Exception", client.commandRunner.getError());
096:            }
097:
098:            public void testDosntwaitForTimeoutOnBadCommand() throws Exception {
099:                CommandRunningFitClient.TIMEOUT = 5000;
100:                long startTime = System.currentTimeMillis();
101:                client = new CommandRunningFitClient(this , "java blah", port,
102:                        new SocketDealer());
103:                client.start();
104:                client.join();
105:                assertTrue(exceptionOccurred);
106:                assertTrue(System.currentTimeMillis() - startTime < CommandRunningFitClient.TIMEOUT);
107:
108:            }
109:
110:            public void XtestOneRunWithManyTables() throws Exception {
111:                // FIXME is an integration test and expects something to be running
112:                // already
113:
114:                receiver.receiveSocket();
115:                client.start();
116:                client
117:                        .send("<html><table><tr><td>fitnesse.testutil.PassFixture</td></tr></table>"
118:                                + "<table><tr><td>fitnesse.testutil.FailFixture</td></tr></table>"
119:                                + "<table><tr><td>fitnesse.testutil.ErrorFixture</td></tr></table></html>");
120:                client.done();
121:                client.join();
122:                assertFalse(exceptionOccurred);
123:                assertEquals(3, outputs.size());
124:                assertEquals(1, counts.size());
125:                Counts count = (Counts) counts.get(0);
126:                assertEquals(1, count.right);
127:                assertEquals(1, count.wrong);
128:                assertEquals(1, count.exceptions);
129:            }
130:
131:            public void XtestManyRuns() throws Exception {
132:                // FIXME is an integration test and expects something to be running
133:                // already
134:
135:                receiver.receiveSocket();
136:                client.start();
137:                client
138:                        .send("<html><table><tr><td>fitnesse.testutil.PassFixture</td></tr></table></html>");
139:                client
140:                        .send("<html><table><tr><td>fitnesse.testutil.FailFixture</td></tr></table></html>");
141:                client
142:                        .send("<html><table><tr><td>fitnesse.testutil.ErrorFixture</td></tr></table></html>");
143:                client.done();
144:                client.join();
145:
146:                assertFalse(exceptionOccurred);
147:                assertEquals(3, outputs.size());
148:                assertEquals(3, counts.size());
149:                assertEquals(1, ((Counts) counts.get(0)).right);
150:                assertEquals(1, ((Counts) counts.get(1)).wrong);
151:                assertEquals(1, ((Counts) counts.get(2)).exceptions);
152:            }
153:
154:            public void XtestDonerIsNotifiedWhenFinished_success()
155:                    throws Exception {
156:                // FIXME is an integration test and expects something to be running
157:                // already
158:
159:                doSimpleRun();
160:                assertTrue(doner.finished);
161:            }
162:
163:            public void XtestReadyForSending() throws Exception {
164:                // FIXME is an integration test and expects something to be running
165:                // already
166:
167:                CommandRunningFitClient.TIMEOUT = 5000;
168:                Thread startThread = new Thread() {
169:                    public void run() {
170:                        try {
171:                            client.start();
172:                        } catch (InterruptedException ie) {
173:                        } catch (Exception e) {
174:                            e.printStackTrace();
175:                        }
176:                    }
177:                };
178:                startThread.start();
179:                Thread.sleep(100);
180:                assertFalse(client.isSuccessfullyStarted());
181:
182:                client.acceptSocketFrom(new SimpleSocketDoner(
183:                        new MockSocket("")));
184:                Thread.sleep(100);
185:                assertTrue(client.isSuccessfullyStarted());
186:
187:                startThread.interrupt();
188:            }
189:
190:            public void XtestUnicodeCharacters() throws Exception {
191:                // FIXME is an integration test and expects something to be running
192:                // already
193:
194:                receiver.receiveSocket();
195:                client.start();
196:                client
197:                        .send("<html><table><tr><td>fitnesse.testutil.EchoFixture</td><td>\uba80\uba81\uba82\uba83</td></tr></table></html>");
198:                client.done();
199:                client.join();
200:
201:                assertFalse(exceptionOccurred);
202:                StringBuffer buffer = new StringBuffer();
203:                for (Iterator iterator = outputs.iterator(); iterator.hasNext();)
204:                    buffer.append(iterator.next());
205:
206:                assertSubString("\uba80\uba81\uba82\uba83", buffer.toString());
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.