Source Code Cross Referenced for HotSwapClassRegisterTest.java in  » Byte-Code » PROSE » ch » ethz » prose » 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 » Byte Code » PROSE » ch.ethz.prose 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // $Id$
002:        // =====================================================================
003:        //
004:        // (history at end)
005:        //
006:
007:        package ch.ethz.prose;
008:
009:        // used packages
010:        import junit.framework.*;
011:        import java.lang.reflect.*;
012:        import java.lang.ref.WeakReference;
013:        import java.util.Collection;
014:
015:        //import ch.ethz.jvmai.MethodWeaver;
016:        //import ch.ethz.jvmai.ClassWeaver;
017:        import ch.ethz.inf.iks.jvmai.jvmdi.HotSwapClassRegister; //import ch.ethz.inf.iks.jvmai.jvmdi.UniqueIdArrayManager;
018:        import ch.ethz.inf.iks.jvmai.jvmdi.HotSwapAspectInterfaceImpl;
019:        import ch.ethz.inf.iks.jvmai.jvmdi.HotSwapFieldWeaver;
020:
021:        /**
022:         * JUnit testcase for class HotSwapClassRegister (HotSwap advice weaving).
023:         *
024:         * @version     $Revision$
025:         * @author      Gerald Linhofer
026:         * @author		Angela Nicoara
027:         */
028:        public class HotSwapClassRegisterTest extends TestCase {
029:
030:            Object dummyField = null;
031:            Object dummyField2 = null;
032:
033:            public Object dummyMethod1() {
034:                return dummyField;
035:            }
036:
037:            public void dummyMethod2(Object newValue) {
038:                dummyField = newValue;
039:            }
040:
041:            HotSwapClassRegister classReg = null;
042:
043:            /**
044:             * Construct test with given name.
045:             * @param name test name
046:             */
047:            public HotSwapClassRegisterTest(String name) {
048:                super (name);
049:            }
050:
051:            /**
052:             * Set up fixture.
053:             */
054:            protected void setUp() {
055:                classReg = HotSwapClassRegister.getInstance();
056:            }
057:
058:            /**
059:             * Clean up.
060:             */
061:            protected void tearDown() {
062:                try {
063:                    classReg.reset();
064:                } catch (Exception e) {
065:                    fail("HotSwapClassRegister.reset()");
066:                }
067:            }
068:
069:            public void test_010_reset() {
070:                // reset when there are no weavers
071:                try {
072:                    classReg.reset();
073:                } catch (Exception e) {
074:                    fail("reset");
075:                }
076:            }
077:
078:            public void test_020_registration() {
079:                // register null
080:                int exceptions = 0;
081:                try {
082:                    classReg.registrationRequest((Class) null);
083:                } catch (NullPointerException e) {
084:                    exceptions++;
085:                } catch (ClassNotFoundException e) {
086:                    fail("register(null) throws ClassNotFoundException");
087:                }
088:                try {
089:                    classReg.registrationRequest((Package) null);
090:                } catch (NullPointerException e) {
091:                    exceptions++;
092:                }
093:                try {
094:                    classReg.registrationRequestSubClasses(null);
095:                } catch (NullPointerException e) {
096:                    exceptions++;
097:                }
098:                assertEquals("Number of exceptions", 3, exceptions);
099:
100:                // register this
101:                try {
102:                    classReg.registrationRequest(this .getClass());
103:                } catch (Exception e) {
104:                    fail("register " + e.getClass().getName());
105:                }
106:                // see if field accesses for dummyField where found
107:                Method method = null;
108:                Class klass = null;
109:                try {
110:                    Collection col = (Collection) HotSwapClassRegister.knownFieldReferences
111:                            .get(this .getClass().getName()
112:                                    + "#dummyField#Ljava/lang/Object;");
113:                    klass = (Class) ((WeakReference) col.iterator().next())
114:                            .get();
115:                } catch (NullPointerException e) {
116:                    fail("field access: field not registered");
117:                } catch (java.util.NoSuchElementException e) {
118:                    fail("field access: method not registered");
119:                }
120:                assertNotNull("get field accessor returned null method", klass);
121:                assertEquals("get field accessor return wrong method", this 
122:                        .getClass(), klass);
123:
124:                // register sub classes
125:                try {
126:                    classReg.registrationRequestSubClasses(Aspect.class);
127:                } catch (Exception e) {
128:                    fail("register sub classes " + e.getClass().getName());
129:                }
130:
131:                // register package
132:                try {
133:                    classReg.registrationRequest(this .getClass().getPackage());
134:                } catch (Exception e) {
135:                    fail("register package " + e.getClass().getName());
136:                }
137:
138:                // registerAll
139:                try {
140:                    classReg.registrationRequestAll();
141:                } catch (Exception e) {
142:                    fail("registerAll " + e.getClass().getName());
143:                }
144:
145:                // unregister
146:                try {
147:                    classReg.removeRequest(this .getClass());
148:                } catch (Exception e) {
149:                    fail("unRegister class " + e.getClass().getName());
150:                }
151:                try {
152:                    classReg.removeRequest(this .getClass().getPackage());
153:                } catch (Exception e) {
154:                    fail("unRegister package " + e.getClass().getName());
155:                }
156:                try {
157:                    classReg.removeRequestSubClass(Aspect.class);
158:                } catch (Exception e) {
159:                    fail("unRegisterSubClass class " + e.getClass().getName());
160:                }
161:                try {
162:                    classReg.removeRequestAll();
163:                } catch (Exception e) {
164:                    fail("unRegisterAll " + e.getClass().getName());
165:                }
166:
167:                // unregister when nothing is registered
168:                try {
169:                    classReg.removeRequest(this .getClass());
170:                } catch (Exception e) {
171:                    fail("unRegister class (nothing registered)"
172:                            + e.getClass().getName());
173:                }
174:                try {
175:                    classReg.removeRequest(this .getClass().getPackage());
176:                } catch (Exception e) {
177:                    fail("unRegister package (nothing registered)"
178:                            + e.getClass().getName());
179:                }
180:                try {
181:                    classReg.removeRequestSubClass(Aspect.class);
182:                } catch (Exception e) {
183:                    fail("unRegisterSubClass class " + e.getClass().getName());
184:                }
185:                try {
186:                    classReg.removeRequestAll();
187:                } catch (Exception e) {
188:                    fail("unRegisterAll (nothing registered)"
189:                            + e.getClass().getName());
190:                }
191:            }
192:
193:            /**
194:             * Test suite.
195:             * @return test instance
196:             */
197:            public static Test suite() {
198:                return new TestSuite(HotSwapClassRegisterTest.class);
199:            }
200:        }
201:
202:        //======================================================================
203:        //
204:        // $Log$
205:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.