Source Code Cross Referenced for APITests.java in  » Web-Services » xins » com » mycompany » myproject » tests » 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 » Web Services » xins » com.mycompany.myproject.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id$
003:         */
004:        package com.mycompany.myproject.tests;
005:
006:        import java.io.File;
007:
008:        import junit.framework.Test;
009:        import junit.framework.TestCase;
010:        import junit.framework.TestSuite;
011:
012:        import org.xins.common.servlet.container.HTTPServletHandler;
013:
014:        /**
015:         * Testcase that includes all the tests for the myproject API.
016:         *
017:         * @version $Revision$ $Date$
018:         */
019:        public class APITests extends TestCase {
020:
021:            /**
022:             * The Servlet server running the API. The value is <code>null</code> if the server is not started.
023:             */
024:            private static HTTPServletHandler API_SERVER;
025:
026:            /**
027:             * Flag that indicates that the API has been started.
028:             */
029:            private static boolean API_STARTED = false;
030:
031:            /**
032:             * Constructs a new <code>APITests</code> test suite with
033:             * the specified name. The name will be passed to the superconstructor.
034:             *
035:             * @param name
036:             *      the name for this test suite.
037:             */
038:            public APITests(String name) {
039:                super (name);
040:            }
041:
042:            /**
043:             * Returns a test suite with all test cases defined by this class.
044:             *
045:             * @return
046:             *     the test suite, never <code>null</code>.
047:             */
048:            public static Test suite() {
049:
050:                TestSuite suite = new TestSuite();
051:
052:                if ("true".equals(System.getProperty("test.start.server"))) {
053:                    suite.addTestSuite(StartServer.class);
054:                }
055:                // Add all tests
056:                suite.addTestSuite(MyFunctionTests.class);
057:                if ("true".equals(System.getProperty("test.start.server"))) {
058:                    suite.addTestSuite(StopServer.class);
059:                }
060:
061:                return suite;
062:            }
063:
064:            /**
065:             * Starts the web server.
066:             */
067:            public static class StartServer extends TestCase {
068:
069:                /**
070:                 * Constructs a new <code>StartServer</code> test suite with
071:                 * the specified name. The name will be passed to the superconstructor.
072:                 *
073:                 * @param name
074:                 *     the name for this test suite.
075:                 */
076:                public StartServer(String name) {
077:                    super (name);
078:                }
079:
080:                /**
081:                 * Returns a test suite with all test cases defined by this class.
082:                 *
083:                 * @return
084:                 *     the test suite, never <code>null</code>.
085:                 */
086:                public static Test suite() {
087:                    return new TestSuite(StartServer.class);
088:                }
089:
090:                /**
091:                 * Unit test that is only used to start the Servlet API if the 
092:                 * test.start.server build properties is set to true.
093:                 *
094:                 * @throws Exception
095:                 *    if the internal Servlet container cannot be started for any reasons.
096:                 */
097:                public void testStartServer() throws Exception {
098:
099:                    String warLocation = "build/webapps/myproject/myproject.war"
100:                            .replace('/', File.separatorChar);
101:                    File warFile = new File(System.getProperty("user.dir"),
102:                            warLocation);
103:                    int port = 8080;
104:                    if (System.getProperty("servlet.port") != null
105:                            && !System.getProperty("servlet.port").equals("")) {
106:                        port = Integer.parseInt(System
107:                                .getProperty("servlet.port"));
108:                    }
109:
110:                    // Start the web server
111:                    API_SERVER = new HTTPServletHandler(warFile, port, true);
112:                    API_STARTED = true;
113:                }
114:            }
115:
116:            /**
117:             * Stops the web server.
118:             */
119:            public static class StopServer extends TestCase {
120:
121:                /**
122:                 * Constructs a new <code>StopServer</code> test suite with
123:                 * the specified name. The name will be passed to the superconstructor.
124:                 *
125:                 * @param name
126:                 *     the name for this test suite.
127:                 */
128:                public StopServer(String name) {
129:                    super (name);
130:                }
131:
132:                /**
133:                 * Returns a test suite with all test cases defined by this class.
134:                 *
135:                 * @return
136:                 *     the test suite, never <code>null</code>.
137:                 */
138:                public static Test suite() {
139:                    return new TestSuite(StopServer.class);
140:                }
141:
142:                /**
143:                 * Unit test that is only used to stop the Servlet API if the servlet
144:                 * is started.
145:                 *
146:                 * @throws Exception
147:                 *    if the internal Servlet container cannot be stopped for any reasons.
148:                 */
149:                public void testStopServer() throws Exception {
150:
151:                    if (API_STARTED) {
152:                        API_SERVER.close();
153:                    }
154:                }
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.