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


001:        /*
002:         * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.util;
006:
007:        import junit.framework.TestCase;
008:
009:        public class ReflectiveProxyTest extends TestCase {
010:
011:            interface Test1Interface {
012:                void foo();
013:
014:                void foo(int i);
015:
016:                void foo(Object o);
017:            }
018:
019:            private static class Test1Class {
020:
021:                int foo0 = 0;
022:                int foo1 = 0;
023:                Object foo2 = null;
024:
025:                public void foo() {
026:                    foo0++;
027:                }
028:
029:                public void foo(int i) {
030:                    foo1 = i;
031:                }
032:
033:                public void foo(Object o) {
034:                    foo2 = o;
035:                }
036:            }
037:
038:            public void test1() throws Exception {
039:                Test1Class o = new Test1Class();
040:                Test1Interface proxy = (Test1Interface) ReflectiveProxy
041:                        .createProxyIfPossible(Test1Interface.class, o);
042:                assertNotNull(proxy);
043:
044:                assertEquals(0, o.foo0);
045:                proxy.foo();
046:                assertEquals(1, o.foo0);
047:
048:                assertEquals(0, o.foo1);
049:                proxy.foo(42);
050:                assertEquals(42, o.foo1);
051:
052:                assertEquals(null, o.foo2);
053:                proxy.foo(this );
054:                assertEquals(this , o.foo2);
055:            }
056:
057:            /*
058:             * a differing return type disallows proxy
059:             */
060:            interface Test2Interface {
061:                void foo();
062:            }
063:
064:            static class Test2Class {
065:                public Test2Class foo() {
066:                    return this ;
067:                }
068:            }
069:
070:            public void test2() throws Exception {
071:                Object o = new Test2Class();
072:                Test2Interface proxy = (Test2Interface) ReflectiveProxy
073:                        .createProxyIfPossible(Test2Interface.class, o);
074:                assertNull(proxy);
075:            }
076:
077:            /*
078:             * a differing arg list disallows proxy
079:             */
080:            interface Test3Interface {
081:                void foo(int o);
082:            }
083:
084:            static class Test3Class {
085:                public void foo() {
086:                    //
087:                }
088:            }
089:
090:            public void test3() throws Exception {
091:                Object o = new Test3Class();
092:                Test3Interface proxy = (Test3Interface) ReflectiveProxy
093:                        .createProxyIfPossible(Test3Interface.class, o);
094:                assertNull(proxy);
095:            }
096:
097:            /*
098:             * non-public (but matching method) disallows proxy
099:             */
100:            interface Test4Interface {
101:                void foo();
102:            }
103:
104:            static class Test4Class {
105:                void foo() {
106:                    //
107:                }
108:            }
109:
110:            public void test4() throws Exception {
111:                Object o = new Test4Class();
112:                Test4Interface proxy = (Test4Interface) ReflectiveProxy
113:                        .createProxyIfPossible(Test4Interface.class, o);
114:                assertNull(proxy);
115:            }
116:
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.