Source Code Cross Referenced for AppletviewerTest.java in  » Testing » abbot-1.0.1 » abbot » script » 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 » abbot 1.0.1 » abbot.script 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package abbot.script;
002:
003:        import java.awt.*;
004:        import java.applet.*;
005:        import java.util.*;
006:
007:        import junit.extensions.abbot.*;
008:        import abbot.finder.matchers.*;
009:
010:        public class AppletviewerTest extends ResolverFixture {
011:
012:            private static boolean manual;
013:            private TestAppletviewer viewer;
014:
015:            public static class TestApplet extends Applet {
016:                public static volatile Applet instance = null;
017:
018:                public void init() {
019:                    setBackground(java.awt.Color.green);
020:                    instance = this ;
021:                }
022:
023:                public void destroy() {
024:                    instance = null;
025:                }
026:            }
027:
028:            // Until applet disposal is worked out, only run these tests manually
029:            public void runBare() throws Throwable {
030:                if (manual) {
031:                    super .runBare();
032:                }
033:            }
034:
035:            protected void tearDown() throws Exception {
036:                // ensure appletviewer instances get disposed of properly
037:                if (viewer != null) {
038:                    viewer.dispose();
039:                }
040:                viewer = null;
041:            }
042:
043:            public void testLaunch() throws Throwable {
044:                viewer = new TestAppletviewer(new HashMap());
045:                viewer.run();
046:                // Step should not return until the applet is visible
047:                assertTrue("Test applet should be instantiated after step run",
048:                        TestApplet.instance != null);
049:                assertTrue("Test applet should be visible", TestApplet.instance
050:                        .isShowing());
051:            }
052:
053:            public void testGeneratedHTML() {
054:                HashMap map = new HashMap();
055:                map.put("name", "value");
056:                viewer = new TestAppletviewer(map);
057:
058:                String html = viewer.generateHTML();
059:                assertTrue("Missing html tag: " + html, html
060:                        .startsWith("<html>"));
061:                assertTrue("Missing applet tag: " + html, html
062:                        .indexOf("<applet") != -1);
063:                assertTrue("Code param missing: " + html, html
064:                        .indexOf("code=\"" + TestApplet.class.getName()) != -1);
065:                assertTrue("Params missing: " + html, html
066:                        .indexOf("><param name=\"name\" value=\"value\"") != -1);
067:            }
068:
069:            public void testClassLoader() throws Throwable {
070:                viewer = new TestAppletviewer(new HashMap());
071:                viewer.run();
072:                Component c = getFinder().find(
073:                        new ClassMatcher(Applet.class, true));
074:                assertEquals(
075:                        "Appletviewer should provide the Applet's class loader",
076:                        c.getClass().getClassLoader(), viewer
077:                                .getContextClassLoader());
078:            }
079:
080:            public void testDocumentBase() throws Throwable {
081:                viewer = new TestAppletviewer(new HashMap());
082:                viewer.run();
083:                Applet applet = (Applet) getFinder().find(
084:                        new ClassMatcher(Applet.class, true));
085:
086:                assertNotNull("Document base should not be null", applet
087:                        .getDocumentBase());
088:            }
089:
090:            public void testThreadsDisposed() throws Throwable {
091:                viewer = new TestAppletviewer(new HashMap());
092:                viewer.run();
093:                viewer.run();
094:                viewer.run();
095:                Iterator iter = getHierarchy().getRoots().iterator();
096:                while (iter.hasNext()) {
097:                    getHierarchy().dispose((Window) iter.next());
098:                }
099:
100:                ThreadGroup group = Thread.currentThread().getThreadGroup();
101:                while (group.getParent() != null) {
102:                    group = group.getParent();
103:                }
104:                int count = group.activeCount();
105:                Thread[] list = new Thread[count];
106:                count = group.enumerate(list);
107:
108:                for (int i = 0; i < list.length; i++) {
109:                    Thread thread = list[i];
110:                    if (thread != null) {
111:                        String name = thread.getName();
112:                        if (name != null && name.indexOf("EventQueue") != -1
113:                                && name.indexOf("(abbot)") != -1) {
114:                            //Log.debug("Thread " + thread + " still running");
115:                            assertFalse("Event dispatch thread " + thread
116:                                    + " should not still be running", thread
117:                                    .isAlive());
118:                        }
119:                    }
120:                }
121:            }
122:
123:            private class TestAppletviewer extends Appletviewer {
124:                public TestAppletviewer(Map map) {
125:                    this (map, "CODEBASE", "ARCHIVE");
126:                }
127:
128:                public TestAppletviewer(Map map, String codebase, String archive) {
129:                    super (AppletviewerTest.this .getResolver(), getName(),
130:                            TestApplet.class.getName(), map, codebase, archive,
131:                            null);
132:                }
133:
134:                public void runStep() throws Throwable {
135:                    super .runStep();
136:                    getFrame().setName(getName());
137:                    getFrame().setTitle(getName());
138:                }
139:
140:                public String generateHTML() {
141:                    return super .generateHTML();
142:                }
143:
144:                protected boolean removeSMOnExit() {
145:                    return true;
146:                }
147:
148:                public void dispose() {
149:                    terminate();
150:                }
151:            }
152:
153:            public static void main(String[] args) {
154:                manual = true;
155:                TestHelper.runTests(args, AppletviewerTest.class);
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.