Source Code Cross Referenced for OnLoadTestApp.java in  » Net » Terracotta » com » tctest » 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 » Net » Terracotta » com.tctest 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tctest;
005:
006:        import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
007:
008:        import com.tc.object.config.ConfigVisitor;
009:        import com.tc.object.config.DSOClientConfigHelper;
010:        import com.tc.object.config.TransparencyClassSpec;
011:        import com.tc.object.config.spec.CyclicBarrierSpec;
012:        import com.tc.simulator.app.ApplicationConfig;
013:        import com.tc.simulator.listener.ListenerProvider;
014:        import com.tc.util.Assert;
015:        import com.tctest.runner.AbstractErrorCatchingTransparentApp;
016:
017:        import java.util.ArrayList;
018:        import java.util.List;
019:
020:        public class OnLoadTestApp extends AbstractErrorCatchingTransparentApp {
021:            private final CyclicBarrier barrier;
022:
023:            private MyObject root;
024:            private MyObject1 root1;
025:            private MyObject2 root2;
026:            private MyObject3 root3;
027:
028:            public OnLoadTestApp(String appId, ApplicationConfig cfg,
029:                    ListenerProvider listenerProvider) {
030:                super (appId, cfg, listenerProvider);
031:                this .barrier = new CyclicBarrier(getParticipantCount());
032:            }
033:
034:            protected void runTest() throws Throwable {
035:                // force the outcome of the race to create (as opposed to faulting) the roots
036:                boolean creator = (barrier.barrier() == 0);
037:
038:                if (creator) {
039:                    createRoots();
040:                }
041:
042:                barrier.barrier();
043:
044:                synchronized (root) {
045:                    Assert.eval(root.getSize() == 0);
046:                    Assert.eval(root.ok);
047:
048:                    Assert.eval(root1.getSize() == 0);
049:
050:                    try {
051:                        root2.getSize();
052:                        Assert.eval(creator);
053:                    } catch (NullPointerException npe) {
054:                        Assert.eval(!creator);
055:                        // success
056:                        System.out.println("YEAH! GOT NPE");
057:                    }
058:                }
059:
060:                // Test case to test for error in OnLoad script.
061:                synchronized (root3) {
062:                    try {
063:                        root3.getSize();
064:                        Assert.eval(creator);
065:                    } catch (NullPointerException npe) {
066:                        Assert.eval(!creator);
067:                        // success
068:                        System.out.println("YEAH! GOT NPE");
069:                    }
070:                }
071:            }
072:
073:            private void createRoots() {
074:                root = new MyObject(null);
075:                root1 = new MyObject1(null);
076:                root2 = new MyObject2(null);
077:                root3 = new MyObject3();
078:            }
079:
080:            public static void visitL1DSOConfig(ConfigVisitor visitor,
081:                    DSOClientConfigHelper config) {
082:                new CyclicBarrierSpec().visit(visitor, config);
083:
084:                String testClass = OnLoadTestApp.class.getName();
085:                TransparencyClassSpec spec = config
086:                        .getOrCreateSpec(MyObject.class.getName());
087:                spec.setHonorTransient(true);
088:                // We want to make sure that all objects are resolved.
089:                spec
090:                        .setExecuteScriptOnLoad("if(self.mine == null){self.ok = false;}else{self.ok = true;} self.list = new ArrayList();");
091:
092:                spec = config.getOrCreateSpec(MyObject1.class.getName());
093:                spec.setHonorTransient(true);
094:                spec.setCallMethodOnLoad("initialize");
095:
096:                spec = config.getOrCreateSpec(MyObject2.class.getName());
097:                spec.setHonorTransient(true);
098:
099:                spec = config.getOrCreateSpec(MyObject3.class.getName());
100:                spec.setHonorTransient(true);
101:                spec.setExecuteScriptOnLoad("<![CDATA[***********;]]>");
102:
103:                spec = config.getOrCreateSpec(testClass);
104:
105:                String methodExpression = "* " + testClass + "*.*(..)";
106:                config.addWriteAutolock(methodExpression);
107:                spec.addRoot("root", "root");
108:                spec.addRoot("root1", "root1");
109:                spec.addRoot("root2", "root2");
110:                spec.addRoot("root3", "root3");
111:                spec.addRoot("barrier", "barrier");
112:            }
113:
114:            private static class MyObject {
115:                private transient List list = new ArrayList();
116:                private MyObject1 mine = new MyObject1(null);
117:                public volatile transient boolean ok = true;
118:
119:                public MyObject(Object o) {
120:                    // I don't want a null constructor to exist so I created this.
121:                    System.out.println(mine);
122:                }
123:
124:                public int getSize() {
125:                    return list.size();
126:                }
127:
128:            }
129:
130:            private static class MyObject1 {
131:                private transient List list;
132:
133:                public MyObject1(Object o) {
134:                    initialize();
135:                }
136:
137:                public void initialize() {
138:                    list = new ArrayList();
139:                }
140:
141:                public int getSize() {
142:                    return list.size();
143:                }
144:            }
145:
146:            private static class MyObject2 {
147:                private transient List list = new ArrayList();
148:
149:                public MyObject2(Object o) {
150:                    //
151:                }
152:
153:                public int getSize() {
154:                    return list.size();
155:                }
156:            }
157:
158:            /**
159:             * This class is used for testing onLoad script with parsing error.
160:             */
161:            private static class MyObject3 {
162:                private transient List list = new ArrayList();
163:                public volatile transient boolean ok = true;
164:
165:                public MyObject3() {
166:                    super ();
167:                }
168:
169:                public int getSize() {
170:                    return list.size();
171:                }
172:
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.