Source Code Cross Referenced for JumbleTestSuiteTest.java in  » Testing » jumble » com » reeltwo » jumble » fast » 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 » jumble » com.reeltwo.jumble.fast 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.reeltwo.jumble.fast;
002:
003:        import java.io.ByteArrayOutputStream;
004:        import java.io.PrintStream;
005:
006:        import com.reeltwo.jumble.mutation.Mutater;
007:
008:        import junit.framework.Test;
009:        import junit.framework.TestCase;
010:        import junit.framework.TestResult;
011:        import junit.framework.TestSuite;
012:
013:        /**
014:         * Tests the corresponding class.
015:         * 
016:         * @author Sean A. Irvine
017:         * @version $Revision: 500 $
018:         */
019:        public class JumbleTestSuiteTest extends TestCase {
020:
021:            private static final int MED_DELAY = 500;
022:            private static final int LONG_DELAY = 2000;
023:
024:            /**
025:             * <code>TimedTests</code> is a small set of tests that take varying
026:             * times to execute.
027:             */
028:            public static class TimedTests extends TestCase {
029:                // Warning, the declaration order of these tests is important to testGetOrder below
030:                public final void testMedium() throws Exception {
031:                    System.out.println("Medium");
032:                    Thread.sleep(MED_DELAY);
033:                }
034:
035:                public final void testLong() throws Exception {
036:                    System.out.println("Long");
037:                    Thread.sleep(LONG_DELAY);
038:                }
039:
040:                public final void testShort() {
041:                    System.out.println("Short");
042:                }
043:            }
044:
045:            public JumbleTestSuiteTest(String name) {
046:                super (name);
047:            }
048:
049:            public static Test suite() {
050:                TestSuite suite = new TestSuite(JumbleTestSuiteTest.class);
051:                return suite;
052:            }
053:
054:            public static void main(String[] args) {
055:                junit.textui.TestRunner.run(suite());
056:            }
057:
058:            public void testTestClass() {
059:                assertTrue(JumbleTestSuite.run(
060:                        getClass().getClassLoader(),
061:                        new TestOrder(new Class[] { Mutater.class },
062:                                new long[] { 0 }), new FailedTestMap(), null,
063:                        null, 0, false).startsWith("PASS"));
064:            }
065:
066:            public void testX5T() {
067:                assertTrue(JumbleTestSuite.run(
068:                        getClass().getClassLoader(),
069:                        new TestOrder(new Class[] { jumble.X5T.class },
070:                                new long[] { 0 }), null, null, null, 0, false)
071:                        .startsWith("PASS"));
072:            }
073:
074:            public void testX5TF() {
075:                assertEquals("FAIL", JumbleTestSuite.run(getClass()
076:                        .getClassLoader(), new TestOrder(
077:                        new Class[] { jumble.X5TF.class }, new long[] { 0 }),
078:                        null, null, null, 0, false));
079:            }
080:
081:            public void testX5TY() {
082:                assertTrue(JumbleTestSuite.run(
083:                        getClass().getClassLoader(),
084:                        new TestOrder(new Class[] { jumble.X5TY.class },
085:                                new long[] { 0, 1 }), new FailedTestMap(),
086:                        null, null, 0, false).startsWith("PASS"));
087:            }
088:
089:            public void testNULL() {
090:                try {
091:                    JumbleTestSuite.run(getClass().getClassLoader(),
092:                            (TestOrder) null, null, null, null, 0, false);
093:                    fail("Took null");
094:                } catch (NullPointerException e) {
095:                    // ok
096:                }
097:            }
098:
099:            // This test shows a problem with the FlatTestSuite not having deterministic test ordering
100:            // Seems to be in the way JUnit creates suites using reflection.. we should ensure that
101:            // FlatTestSuite creates suites with tests in a known order, otherwise the TestOrder is serving
102:            // no purpose.
103:            //   public void testX5TQ() {
104:            //     assertEquals("FAIL",
105:            //         JumbleTestSuite.run(ClassLoader.getSystemClassLoader(), 
106:            //                             new TestOrder(new Class[] {com.reeltwo.jumble.X5TQ.class },
107:            //                                           new long[] {0, 1, 2}), null, null, null, 0, false));
108:            //   }
109:
110:            public final void testOrder() throws Exception {
111:                PrintStream oldOut = System.out;
112:
113:                // first run the tests to get timing information (throw away output)
114:                TimingTestSuite timingSuite = new TimingTestSuite(getClass()
115:                        .getClassLoader(), new String[] { TimedTests.class
116:                        .getName() });
117:                System.setOut(new PrintStream(new ByteArrayOutputStream()));
118:                try {
119:                    timingSuite.run(new TestResult());
120:                } finally {
121:                    System.setOut(oldOut);
122:                }
123:
124:                // The timed tests write to standard out so the easiest way
125:                // to check the order is to hijack the output and read it
126:                ByteArrayOutputStream ba = new ByteArrayOutputStream();
127:                PrintStream out = new PrintStream(ba);
128:
129:                System.setErr(out);
130:                String s;
131:                try {
132:                    s = JumbleTestSuite.run(getClass().getClassLoader(),
133:                            timingSuite.getOrder(true), null, null, null, 0,
134:                            true);
135:                } finally {
136:                    System.setErr(oldOut);
137:                }
138:                assertTrue(s.startsWith("FAIL"));
139:
140:                String errout = ba.toString();
141:                int si = errout.indexOf("Short");
142:                int mi = errout.indexOf("Medium");
143:                int li = errout.indexOf("Long");
144:                assertTrue(si >= 0);
145:                assertTrue(mi >= 0);
146:                assertTrue(li >= 0);
147:                assertTrue((si < mi) && (mi < li));
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.