Source Code Cross Referenced for TestDoubleCommand.java in  » Code-Analyzer » JBlanket » csdl » stackmvc » control » command » 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 » Code Analyzer » JBlanket » csdl.stackmvc.control.command 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package csdl.stackmvc.control.command;
002:
003:        import com.meterware.httpunit.WebConversation;
004:        import com.meterware.httpunit.WebForm;
005:        import com.meterware.httpunit.WebRequest;
006:        import com.meterware.httpunit.WebResponse;
007:        import com.meterware.httpunit.WebTable;
008:
009:        import junit.framework.TestCase;
010:        import junit.framework.TestSuite;
011:        import junit.textui.TestRunner;
012:
013:        /**
014:         * Tests operation of the StackMVC Double command.
015:         *
016:         * @author Joy Agustin
017:         */
018:        public class TestDoubleCommand extends TestCase {
019:
020:            /** The stackMVC's single page title. */
021:            private String pageTitle = "Stack MVC";
022:
023:            /** Get the test host. */
024:            private String testHost = System.getProperty("test_host");
025:
026:            /**
027:             * Required for JUnit.
028:             *
029:             * @param name Test case name.
030:             */
031:            public TestDoubleCommand(String name) {
032:                super (name);
033:            }
034:
035:            /**
036:             * Tests the stackMVC double operation under normal situation.
037:             *
038:             * @throws Exception If problems occur during test.
039:             */
040:            public void testLegalDouble() throws Exception {
041:                WebConversation conversation = new WebConversation();
042:
043:                // Get the initialized stack page and check that we got it.
044:                String initStackUrl = testHost
045:                        + "stackmvc/controller?CommandName=Clear";
046:                WebResponse response = conversation.getResponse(initStackUrl);
047:                assertEquals("Checking initialized stack page", pageTitle,
048:                        response.getTitle());
049:
050:                // Push a single value onto the stack.
051:                WebForm pushForm = response.getFormWithID("PushForm");
052:                WebRequest pushRequest = pushForm.getRequest();
053:                response = conversation.getResponse(pushRequest);
054:
055:                // Check that the stack contains a single value
056:                WebTable stackTable = response.getTableWithID("StackTable");
057:                assertEquals("Checking stack size", 1, stackTable.getRowCount());
058:
059:                // Double a single value on the stack.
060:                WebForm doubleForm = response.getFormWithID("DoubleForm");
061:                WebRequest doubleRequest = doubleForm.getRequest();
062:                response = conversation.getResponse(doubleRequest);
063:
064:                // Check that the stack contains two values
065:                stackTable = response.getTableWithID("StackTable");
066:                assertEquals("Checking stack size", 2, stackTable.getRowCount());
067:
068:                // Pop the stack twice and make sure that it's empty.
069:                WebForm popForm = response.getFormWithID("PopForm");
070:                response = conversation.getResponse(popForm.getRequest());
071:
072:                popForm = response.getFormWithID("PopForm");
073:                response = conversation.getResponse(popForm.getRequest());
074:
075:                stackTable = response.getTableWithID("StackTable");
076:                assertEquals("Checking size of popped stack", 0, stackTable
077:                        .getRowCount());
078:            }
079:
080:            /**
081:             * Tests that stackMVC signals an error when an empty stack is doubled.
082:             *
083:             * @throws Exception If problems occur during test.
084:             */
085:            public void testIllegalDouble() throws Exception {
086:                WebConversation conversation = new WebConversation();
087:
088:                // Get the initialized stack page and check that we got it.
089:                String initStackUrl = testHost
090:                        + "stackmvc/controller?CommandName=Clear";
091:                WebResponse response = conversation.getResponse(initStackUrl);
092:
093:                // Push a single value onto the stack.
094:                WebForm pushForm = response.getFormWithID("PushForm");
095:                WebRequest pushRequest = pushForm.getRequest();
096:                response = conversation.getResponse(pushRequest);
097:
098:                // Pop the stack once to clear stack.
099:                WebForm popForm = response.getFormWithID("PopForm");
100:                response = conversation.getResponse(popForm.getRequest());
101:                popForm = response.getFormWithID("PopForm");
102:                response = conversation.getResponse(popForm.getRequest());
103:
104:                // Double the stack once. (First time is illegal).
105:                WebForm doubleForm = response.getFormWithID("DoubleForm");
106:                response = conversation.getResponse(doubleForm.getRequest());
107:
108:                // Now check that "Stack is empty" and error message is displayed.
109:                WebTable stackTopTable = response.getTableWithID("stackTop");
110:                String stackTop = stackTopTable.getCellAsText(0, 0);
111:                assertEquals("Checking stack top message",
112:                        "Top of stack is: The stack is empty.", stackTop);
113:
114:                // Check that the stack is empty.
115:                WebTable stackTable = response.getTableWithID("StackTable");
116:                assertEquals("Checking stack size", 0, stackTable.getRowCount());
117:
118:                WebTable errorMessageTable = response
119:                        .getTableWithID("ErrorMessageTable");
120:                String errorMessage = errorMessageTable.getCellAsText(0, 0);
121:                assertEquals("Checking error message",
122:                        "Attempt to double empty stack.", errorMessage);
123:            }
124:
125:            /**
126:             * Provide stand-alone execution of this test case during initial development.
127:             *
128:             * @param args The command line arguments
129:             */
130:            public static void main(String[] args) {
131:                System.out.println("JUnit testing Double command.");
132:                //Runs all no-arg methods starting with "test".
133:                TestRunner.run(new TestSuite(TestDoubleCommand.class));
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.