Source Code Cross Referenced for StoreDataActionTest.java in  » Testing » mockrunner-0.4 » com » mockrunner » example » struts » 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 » mockrunner 0.4 » com.mockrunner.example.struts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package com.mockrunner.example.struts;
02:
03:        import com.mockrunner.mock.web.ActionMockObjectFactory;
04:        import com.mockrunner.struts.ActionTestModule;
05:        import com.mockrunner.struts.BasicActionTestCaseAdapter;
06:
07:        /**
08:         * Example test for {@link StoreDataAction}. 
09:         * Demonstrates multithread testing. The use of an inner thread 
10:         * class and  a single test method is a standard pattern that can 
11:         * be used in any multithreading test for Servlets and actions.
12:         * Please note that each thread has to call the action with
13:         * different sessions and requests but with one 
14:         * <code>ServletContext</code> in order to simulate the real
15:         * container behaviour. See the constructor of the thread how
16:         * to deal with the test module and factory.
17:         * Remove the <code>synchronized</code> keyword in
18:         * {@link StoreDataAction} and the test
19:         * will fail.
20:         * {@link com.mockrunner.base.MultiThreadTestSuite} is meant to
21:         * make multithread testing much easier, but it is not working
22:         * properly yet, so we do not use it here.
23:         */
24:        public class StoreDataActionTest extends BasicActionTestCaseAdapter {
25:            private volatile int numberSuccess;
26:
27:            protected void setUp() throws Exception {
28:                super .setUp();
29:                numberSuccess = 0;
30:            }
31:
32:            public void testStoreDataAction() throws Exception {
33:                StoreTestThread thread1 = new StoreTestThread("thread1");
34:                StoreTestThread thread2 = new StoreTestThread("thread2");
35:                StoreTestThread thread3 = new StoreTestThread("thread3");
36:                StoreTestThread thread4 = new StoreTestThread("thread4");
37:                StoreTestThread thread5 = new StoreTestThread("thread5");
38:                thread1.start();
39:                thread2.start();
40:                thread3.start();
41:                thread4.start();
42:                thread5.start();
43:                thread1.join();
44:                thread2.join();
45:                thread3.join();
46:                thread4.join();
47:                thread5.join();
48:                assertTrue(numberSuccess == 1);
49:            }
50:
51:            public class StoreTestThread extends Thread {
52:                private ActionMockObjectFactory mockFactory;
53:                private ActionTestModule module;
54:
55:                public StoreTestThread(String name) {
56:                    super (name);
57:                    mockFactory = createActionMockObjectFactory(getActionMockObjectFactory());
58:                    module = createActionTestModule(mockFactory);
59:                }
60:
61:                public void run() {
62:                    module.addRequestParameter("id", "id");
63:                    module.addRequestParameter("data", getName());
64:                    module.actionPerform(StoreDataAction.class);
65:                    if (module.getActionForward().getPath().equals("success")) {
66:                        numberSuccess++;
67:                    }
68:                }
69:            }
70:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.