Source Code Cross Referenced for ClassAdapterTestTarget.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
003:         * notice. All rights reserved.
004:         */
005:        package com.tctest;
006:
007:        import com.tc.object.TestClientObjectManager;
008:
009:        import java.io.ObjectStreamField;
010:        import java.util.ArrayList;
011:        import java.util.List;
012:
013:        /**
014:         * Adaptation target for ClassAdapterTest
015:         */
016:        public class ClassAdapterTestTarget {
017:            private static final String C = ClassAdapterTestTarget.class
018:                    .getName()
019:                    + ".";
020:
021:            public static final String KEY = C + "key";
022:            public static final String CSTR_THROW_EXCEPTION = C
023:                    + "cstr-throw-exception";
024:            public static final String CSTR_AUTOLOCK_NO_EXCEPTION = C
025:                    + "cstr-autolock-noexception";
026:            public static final String CSTR_AUTOLOCK_THROW_EXCEPTION_INSIDE = C
027:                    + "cstr-autolock-throw-exception-inside";
028:
029:            // This isn't a real serialVersionUID, but it needs to be here for tests
030:            private static final long serialVersionUID = 42L;
031:
032:            // Again, this isn't really for serialization, but it needs to be here for tests
033:            private static final ObjectStreamField[] serialPersistentFields = { new java.io.ObjectStreamField(
034:                    "foo", char[].class) };
035:
036:            private static TestClientObjectManager testClientObjectManager;
037:
038:            List myRoot = new ArrayList();
039:
040:            public synchronized static void setTestClientObjectManager(
041:                    TestClientObjectManager clientObjectManager) {
042:                testClientObjectManager = clientObjectManager;
043:            }
044:
045:            public ClassAdapterTestTarget() {
046:                String s = System.getProperty(KEY);
047:
048:                if (s != null) {
049:                    if (CSTR_THROW_EXCEPTION.equals(s)) {
050:                        throw new RuntimeException(s);
051:                    }
052:
053:                    // This funny looking code is here to create mulitple exit paths from this constructor
054:                    // It is also here to get some autolocking going on
055:                    testClientObjectManager.sharedIfManaged(s);
056:                    synchronized (s) {
057:                        if (CSTR_AUTOLOCK_THROW_EXCEPTION_INSIDE.equals(s)) {
058:                            throw new RuntimeException(s);
059:                        }
060:
061:                        if (!CSTR_AUTOLOCK_NO_EXCEPTION.equals(s)) {
062:                            throw new AssertionError(s);
063:                        }
064:
065:                        if (hashCode() != hashCode()) {
066:                            return;
067:                        }
068:                    }
069:                }
070:            }
071:
072:            public void doStuff() {
073:                myRoot.add(this );
074:            }
075:
076:            public synchronized void synchronizedInstanceMethodWithWideArgs(
077:                    double d, long l) {
078:                System.out
079:                        .println("You called synchronizedInstanceMethodWithWideArgs(double, long)!");
080:            }
081:
082:            /**
083:             * This is a method that should be called to test a lock.
084:             */
085:            public void instanceMethod() {
086:                System.out.println("You called instanceMethod()!");
087:            }
088:
089:            public void instanceMethodThrowsException()
090:                    throws LockTestThrowsExceptionException {
091:                System.out
092:                        .println("You called lockTestThrowsException()!  About to throw an exception...");
093:                throw new LockTestThrowsExceptionException();
094:            }
095:
096:            public void instanceMethodWithArguments(int i) {
097:                System.out.println("You called instanceMethodWithArguments("
098:                        + i + ")");
099:            }
100:
101:            public void instanceMethodWithArguments(int i, String s) {
102:                System.out.println("You called instanceMethodWithArguments("
103:                        + i + ", " + s + ")");
104:            }
105:
106:            public void instanceMethodWithArgumentsThrowsException(int i,
107:                    String s) throws LockTestThrowsExceptionException {
108:                System.out
109:                        .println("You called instanceMethodWithArgumentsThrowsException");
110:                throwException();
111:            }
112:
113:            public synchronized void synchronizedInstanceMethod() {
114:                System.out.println("You called synchronizedInstanceMethod()");
115:            }
116:
117:            public synchronized void synchronizedInstanceMethodThrowsException()
118:                    throws LockTestThrowsExceptionException {
119:                System.out
120:                        .println("You called synchronizedInstanceMethodThrowsException()!  About to throw an exception...");
121:                throw new LockTestThrowsExceptionException();
122:            }
123:
124:            public synchronized void synchronizedInstanceMethodWithArguments(
125:                    int i, String s) {
126:                System.out
127:                        .println("You called synchronizedInstanceMethodWithArguments");
128:            }
129:
130:            public synchronized void synchronizedInstanceMethodWithArgumentsThrowsException(
131:                    int i, String s) throws LockTestThrowsExceptionException {
132:                System.out
133:                        .println("You called synchronizedInstanceMethodWithArgumentsThrowsException(int, String)");
134:                throwException();
135:            }
136:
137:            public void internalSynchronizedInstanceMethod() {
138:                synchronized (this ) {
139:                    System.out
140:                            .println("You called synchronizedInstanceMethod()!");
141:                }
142:            }
143:
144:            public void internalSynchronizedInstanceMethodThrowsException()
145:                    throws LockTestThrowsExceptionException {
146:
147:                synchronized (this ) {
148:                    System.out
149:                            .println("You called internalSynchronizedInstanceMethodThrowsException");
150:                    throwException();
151:                }
152:            }
153:
154:            public void internalSynchronizedInstanceMethodWithArguments(int i,
155:                    String s) {
156:                synchronized (this ) {
157:                    System.out
158:                            .println("You called internalSynchronizedInstanceMethodWithArguments(int, String)");
159:                }
160:            }
161:
162:            public void internalSynchronizedInstanceMethodWithArgumentsThrowsException(
163:                    int i, String s) throws LockTestThrowsExceptionException {
164:                synchronized (this ) {
165:                    System.out
166:                            .println("You called internalSynchronizedInstanceMethodWithArgumentsThrowsException(int, String)");
167:                    throwException();
168:                }
169:            }
170:
171:            public static void staticMethod() {
172:                System.out.println("You called staticMethod()!");
173:            }
174:
175:            public static void staticMethodThrowsException() throws Exception {
176:                throwException();
177:            }
178:
179:            public static void staticMethodWithArguments(int i, String s) {
180:                System.out.println("You called staticMethodWithArguments(" + i
181:                        + ", " + s + ")");
182:            }
183:
184:            public static void staticMethodWithArgumentsThrowsException(int i,
185:                    String s) throws Exception {
186:                System.out
187:                        .println("You called staticMethodWithArgumentsThrowsException("
188:                                + i + ", " + s + ")");
189:                if (System.currentTimeMillis() > 0) {
190:                    throw new LockTestThrowsExceptionException();
191:                }
192:            }
193:
194:            public static synchronized void synchronizedStaticMethod() {
195:                System.out.println("You called synchronizedStaticMethod()");
196:            }
197:
198:            public static synchronized void synchronizedStaticMethodThrowsException()
199:                    throws LockTestThrowsExceptionException {
200:                System.out
201:                        .println("You called synchronizedStaticMethodThrowsException()");
202:                throwException();
203:            }
204:
205:            public static synchronized void synchronizedStaticMethodWithArguments(
206:                    int i, String s) {
207:                System.out
208:                        .println("You called synchronizedStaticMethodWithArguments");
209:            }
210:
211:            public static synchronized void synchronizedStaticMethodWithArgumentsThrowsException(
212:                    int i, String s) throws LockTestThrowsExceptionException {
213:                System.out
214:                        .println("You called synchronizedStaticMethodWithArgumentsThrowsException(int, String)");
215:                throwException();
216:            }
217:
218:            public static void internalSynchronizedStaticMethod() {
219:                Object o = new Object();
220:                System.out
221:                        .println("internalSynchronizedStaticMethod(): About to synchronized on "
222:                                + o + "...");
223:                testClientObjectManager.sharedIfManaged(o);
224:                synchronized (o) {
225:                    System.out
226:                            .println("You called internalSynchronizedStaticMethod()");
227:                }
228:            }
229:
230:            public static void internalSynchronizedStaticMethodThrowsException()
231:                    throws LockTestThrowsExceptionException {
232:                Object o = new Object();
233:                testClientObjectManager.sharedIfManaged(o);
234:                synchronized (o) {
235:                    System.out
236:                            .println("You called internalSynchronizedStaticMethodThrowsException()");
237:                    throwException();
238:                }
239:            }
240:
241:            public static void internalSynchronizedStaticMethodWithArguments(
242:                    int i, String s) {
243:                Object o = new Object();
244:                testClientObjectManager.sharedIfManaged(o);
245:                synchronized (o) {
246:                    System.out
247:                            .println("You called internalSynchronizedStaticMethodWithArguments(int, String)");
248:                }
249:            }
250:
251:            public static void internalSynchronizedStaticMethodWithArgumentsThrowsException(
252:                    int i, String s) throws LockTestThrowsExceptionException {
253:                Object o = new Object();
254:                testClientObjectManager.sharedIfManaged(o);
255:                synchronized (o) {
256:                    System.out
257:                            .println("You called internalSynchronizedStaticMethodWithArgumentsThrowsException(int, String)");
258:                    throwException();
259:                }
260:            }
261:
262:            public String instanceMethodReturnsAValue() {
263:                String rv = "some return value";
264:                System.out
265:                        .println("You called instanceMethodReturnsAValue().  Returning: "
266:                                + rv);
267:                return rv;
268:            }
269:
270:            public String instanceMethodReturnsAValueThrowsException()
271:                    throws LockTestThrowsExceptionException {
272:                String rv = "You called instanceMethodReturnsAValueThrowsException()";
273:                System.out.println(rv);
274:                throwException();
275:                return rv;
276:            }
277:
278:            public String instanceMethodWithArgumentsReturnsAValue(int i,
279:                    String s) {
280:                String rv = "You called instanceMethodWithArgumentsReturnsAValue(int, String)";
281:                System.out.println(rv);
282:                return rv;
283:            }
284:
285:            public String instanceMethodWithArgumentsReturnsAValueThrowsException(
286:                    int i, String s) throws LockTestThrowsExceptionException {
287:                String rv = "You called instanceMethodWithArgumentsReturnsAValueThrowsException(int, String)";
288:                System.out.println(rv);
289:                throwException();
290:                return rv;
291:            }
292:
293:            public synchronized String synchronizedInstanceMethodReturnsAValue() {
294:                String rv = "some return value";
295:                System.out
296:                        .println("You called synchronizedInstanceMethodReturnsAValue().  Returning "
297:                                + rv);
298:                return rv;
299:            }
300:
301:            public synchronized String synchronizedInstanceMethodReturnsAValueThrowsException()
302:                    throws LockTestThrowsExceptionException {
303:                String rv = "You called synchronizedInstanceMethodReturnsAValueThrowsException()";
304:                System.out.println(rv);
305:                throwException();
306:                return rv;
307:            }
308:
309:            public synchronized String synchronizedInstanceMethodWithArgumentsReturnsAValue(
310:                    int i, String s) {
311:                String rv = "You called synchronizedInstanceMethodWithArgumentsReturnsAValue(int, String)";
312:                System.out.println(rv);
313:                return rv;
314:            }
315:
316:            public synchronized String synchronizedInstanceMethodWithArgumentsReturnsAValueThrowsException(
317:                    int i, String s) throws LockTestThrowsExceptionException {
318:                String rv = "You called synchronizedInstanceMethodWithArgumentsReturnsAValueThrowsException(int, String)";
319:                System.out.println("rv");
320:                throwException();
321:                return rv;
322:            }
323:
324:            public String internalSynchronizedInstanceMethodReturnsAValue() {
325:                String rv = "You called internalSynchronizedInstanceMethodReturnsAValue()";
326:                synchronized (this ) {
327:                    System.out.println(rv);
328:                }
329:                return rv;
330:            }
331:
332:            public String internalSynchronizedInstanceMethodReturnsAValueThrowsException()
333:                    throws LockTestThrowsExceptionException {
334:                String rv = "You called internalSynchronizedInstanceMethodReturnsAValueThrowsException()";
335:                synchronized (this ) {
336:                    System.out.println(rv);
337:                    throwException();
338:                }
339:                return rv;
340:            }
341:
342:            public String internalSynchronizedInstanceMethodWithArgumentsReturnsAValue(
343:                    int i, String s) {
344:                String rv = "You called internalSynchronizedInstanceMethodWithArgumentsReturnsAValue(int, String)";
345:                synchronized (this ) {
346:                    System.out.println(rv);
347:                }
348:                return rv;
349:            }
350:
351:            public String internalSynchronizedInstanceMethodWithArgumentsReturnsAValueThrowsException(
352:                    int i, String s) throws LockTestThrowsExceptionException {
353:                String rv = "You called internalSynchronizedInstanceMethodWithArgumentsReturnsAValueThrowsException";
354:                synchronized (this ) {
355:                    System.out.println(rv);
356:                    throwException();
357:                }
358:                return rv;
359:            }
360:
361:            public static String staticMethodReturnsAValue() {
362:                String rv = "You called staticMethodReturnsAValue";
363:                System.out.println(rv);
364:                return rv;
365:            }
366:
367:            public static String staticMethodReturnsAValueThrowsException()
368:                    throws Exception {
369:                String rv = "You called staticMethodReturnsAValueThrowsException()";
370:                System.out.println(rv);
371:                throwException();
372:                return rv;
373:            }
374:
375:            public static String staticMethodWithArgumentsReturnsAValue(int i,
376:                    String s) {
377:                String rv = "You called staticMethodWithArgumentsReturnsAValue(int, String)";
378:                System.out.println(rv);
379:                return rv;
380:            }
381:
382:            public static String staticMethodWithArgumentsReturnsAValueThrowsException(
383:                    int i, String s) throws Exception {
384:                String rv = "You called staticMethodWithArgumentsReturnsAValueThrowsException(int, String)";
385:                throwException();
386:                return rv;
387:            }
388:
389:            public static synchronized String synchronizedStaticMethodReturnsAValue() {
390:                String rv = "You called synchronizedStaticMethodReturnsAValue()";
391:                System.out.println(rv);
392:                return rv;
393:            }
394:
395:            public static synchronized String synchronizedStaticMethodReturnsAValueThrowsException()
396:                    throws LockTestThrowsExceptionException {
397:                String rv = "You called synchronizedStaticMethodReturnsAValueThrowsException()";
398:                System.out.println(rv);
399:                throwException();
400:                return rv;
401:            }
402:
403:            public static synchronized String synchronizedStaticMethodWithArgumentsReturnsAValue(
404:                    int i, String s) {
405:                String rv = "You called synchronizedStaticMethodWithArgumentsReturnsAValue(int, String)";
406:                System.out.println(rv);
407:                return rv;
408:            }
409:
410:            public static synchronized String synchronizedStaticMethodWithArgumentsReturnsAValueThrowsException(
411:                    int i, String s) throws LockTestThrowsExceptionException {
412:                String rv = "You called synchronizedStaticMethodWithArgumentsReturnsAValueThrowsException(int i, String s)";
413:                System.out.println(rv);
414:                throwException();
415:                return rv;
416:            }
417:
418:            public static String internalSynchronizedStaticMethodReturnsAValue() {
419:                String rv = "You called internalSynchronizedStaticMethodReturnsAValue()";
420:                Object o = new Object();
421:                testClientObjectManager.sharedIfManaged(o);
422:                synchronized (o) {
423:                    System.out.println(rv);
424:                }
425:                return rv;
426:            }
427:
428:            public static String internalSynchronizedStaticMethodReturnsAValueThrowsException()
429:                    throws LockTestThrowsExceptionException {
430:                String rv = "You called internalSynchronizedStaticMethodReturnsAValueThrowsException()";
431:                Object o = new Object();
432:                testClientObjectManager.sharedIfManaged(o);
433:                synchronized (o) {
434:                    System.out.println(rv);
435:                    throwException();
436:                }
437:                return rv;
438:            }
439:
440:            public static String internalSynchronizedStaticMethodWithArgumentsReturnsAValue(
441:                    int i, String s) {
442:                String rv = "You called internalSynchronizedStaticMethodWithArgumentsReturnsAValue(int, String)";
443:                Object o = new Object();
444:                testClientObjectManager.sharedIfManaged(o);
445:                synchronized (o) {
446:                    System.out.println(rv);
447:                }
448:                return rv;
449:            }
450:
451:            public static String internalSynchronizedStaticMethodWithArgumentsReturnsAValueThrowsException(
452:                    int i, String s) throws LockTestThrowsExceptionException {
453:                String rv = "You called internalSynchronizedStaticMethodWithArgumentsReturnsAValueThrowsException(int, String)";
454:                Object o = new Object();
455:                testClientObjectManager.sharedIfManaged(o);
456:                synchronized (o) {
457:                    System.out.println(rv);
458:                    throwException();
459:                }
460:                return rv;
461:            }
462:
463:            public int nestedInternalSynchronizedInstanceMethod() {
464:                Object obj1 = new Object();
465:                Object obj2 = new Object();
466:                testClientObjectManager.sharedIfManaged(obj1);
467:                testClientObjectManager.sharedIfManaged(obj2);
468:
469:                synchronized (obj1) {
470:                    System.out.println("Synchronized on obj1");
471:                    synchronized (obj2) {
472:                        System.out.println("Synchronized on obj2");
473:                        synchronized (this ) {
474:                            System.out.println("Synchonized on this");
475:                            // return the number of synchronized blocks.
476:                            return 3;
477:                        }
478:                    }
479:                }
480:            }
481:
482:            private static void throwException()
483:                    throws LockTestThrowsExceptionException {
484:                if (System.currentTimeMillis() > 0) {
485:                    throw new LockTestThrowsExceptionException();
486:                }
487:            }
488:
489:            public static void main(String[] args) {
490:                //
491:            }
492:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.