Source Code Cross Referenced for FieldNotificationTest.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: FieldNotificationTest.java,v 1.3 2004/05/12 17:26:51 anicoara Exp $
002:        // =====================================================================
003:        //
004:        // (history at end)
005:        //
006:
007:        package ch.ethz.prose;
008:
009:        //used packages
010:        import java.lang.reflect.Field;
011:
012:        import junit.framework.*;
013:        import ch.ethz.jvmai.FieldAccessJoinPoint;
014:        import ch.ethz.jvmai.FieldModificationJoinPoint;
015:        import ch.ethz.prose.crosscut.*;
016:        import ch.ethz.prose.filter.PointCutter;
017:        import ch.ethz.prose.filter.Within;
018:
019:        /**
020:         * FieldNotificationTest. Used to find out if fields also get
021:         * accessed during instantion time, even if not set to default value.
022:         *
023:         * @version	$Revision: 1.3 $
024:         * @author Gerard Roos
025:         */
026:        public class FieldNotificationTest extends TestCase {
027:
028:            static final boolean WRITE = false;
029:            static final boolean READ = true;
030:
031:            static class TestClass {
032:                int initial;
033:                int undefined;
034:
035:                int[] array;
036:
037:                Object o;
038:
039:                public TestClass() {
040:                    fieldName = "o";
041:                    o = null;
042:                }
043:            }
044:
045:            public static class TestExtension extends DefaultAspect {
046:
047:                public Crosscut c1 = new GetCut() {
048:                    public void GET_ARGS() {
049:                        try {
050:                            Field f = ((FieldAccessJoinPoint) this JoinPoint())
051:                                    .getField();
052:                            assertTrue(
053:                                    "unexpected read access to watched field "
054:                                            + f, f.getName().equals(fieldName));
055:                            assertTrue(
056:                                    "unexpected read access to watched field "
057:                                            + f + ", write access expected.",
058:                                    readwriteAccess == READ);
059:                        } catch (Exception e) {
060:                            e.printStackTrace();
061:                        }
062:                    }
063:
064:                    protected PointCutter pointCutter() {
065:                        return Within.type(TestClass.class);
066:                    }
067:
068:                    // restrict to TestClass
069:                    protected Class[] potentialCrosscutClasses() {
070:                        Class[] result = { TestClass.class };
071:                        return result;
072:                    }
073:                };
074:
075:                public Crosscut c = new SetCut() {
076:                    public void SET_ARGS() {
077:                        Field f = ((FieldModificationJoinPoint) this JoinPoint())
078:                                .getField();
079:                        try {
080:                            assertTrue(
081:                                    "unexpected write access to watched field "
082:                                            + f, f.getName().equals(fieldName));
083:                            assertTrue(
084:                                    "unexpected write access to watched field "
085:                                            + f + ", read access expected.",
086:                                    readwriteAccess == WRITE);
087:                        } catch (Exception e) {
088:                            e.printStackTrace();
089:                        }
090:                    }
091:
092:                    // restrict to TestClass
093:                    protected Class[] potentialCrosscutClasses() {
094:                        Class[] result = { TestClass.class };
095:                        return result;
096:                    }
097:
098:                    protected PointCutter pointCutter() {
099:                        return Within.type(TestClass.class);
100:                    }
101:                };
102:            }
103:
104:            TestClass test;
105:
106:            static String fieldName;
107:            static boolean readwriteAccess;
108:
109:            /**
110:             * Construct test with given name.
111:             * @param name test name
112:             */
113:            public FieldNotificationTest(String name) {
114:                super (name);
115:            }
116:
117:            /**
118:             * Set up fixture.
119:             */
120:            protected void setUp() {
121:                try {
122:                    ProseSystem.startup();
123:                } catch (Exception e) {
124:                    Assert.fail("ProseSystem.startup() failed.");
125:                }
126:            }
127:
128:            protected void tearDown() {
129:                try {
130:                    ProseSystem.teardown();
131:                } catch (Exception e) {
132:                    Assert.fail("ProseSystem.teardown() failed.");
133:                }
134:            }
135:
136:            public void testInstantiation() throws Exception {
137:
138:                try {
139:                    ProseSystem.getAspectManager().insert(new TestExtension());
140:
141:                    runTestInstantiation();
142:                } catch (RuntimeException e) {
143:                    e.printStackTrace();
144:                    throw e;
145:                }
146:            }
147:
148:            protected void runTestInstantiation() {
149:                int[] arr = { 1, 2, 3, 4, 5 };
150:
151:                readwriteAccess = WRITE;
152:                fieldName = "initial";
153:                test = new TestClass();
154:
155:                fieldName = "undefined";
156:                test.undefined = -5;
157:
158:                fieldName = "o";
159:                test.o = new Object();
160:
161:                fieldName = "array";
162:                test.array = arr;
163:
164:                readwriteAccess = READ;
165:                arr[0] = 0;
166:
167:                readwriteAccess = WRITE;
168:                test.array = arr;
169:
170:                readwriteAccess = READ;
171:                test.array[1] = 9;
172:                test.array[3] = 1;
173:                test.array[4] = 10;
174:            }
175:
176:            /**
177:             * Test suite.
178:             * @return test instance
179:             */
180:            public static Test suite() {
181:                return new TestSuite(FieldNotificationTest.class);
182:            }
183:
184:        }
185:
186:        //======================================================================
187:        //
188:        // $Log: FieldNotificationTest.java,v $
189:        // Revision 1.3  2004/05/12 17:26:51  anicoara
190:        // Adapt Junit tests to 3.8.1 version and the new package structure
191:        //
192:        // Revision 1.1.1.1  2003/07/02 15:30:42  apopovic
193:        // Imported from ETH Zurich
194:        //
195:        // Revision 1.1  2003/05/05 14:02:28  popovici
196:        // renaming from runes to prose
197:        //
198:        // Revision 1.13  2003/04/27 13:08:40  popovici
199:        // Specializers renamed to PointCutter
200:        //
201:        // Revision 1.12  2003/04/17 15:15:03  popovici
202:        // Extension->Aspect renaming
203:        //
204:        // Revision 1.11  2003/04/17 12:49:39  popovici
205:        // Refactoring of the crosscut package
206:        //  ExceptionCut renamed to ThrowCut
207:        //  McutSignature is now SignaturePattern
208:        //
209:        // Revision 1.10  2003/04/17 08:46:43  popovici
210:        // Important functionality additions
211:        //  - Cflow specializers
212:        //  - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
213:        //  - Transactional capabilities
214:        //  - Total refactoring of Specializer evaluation, which permits fine-grained distinction
215:        //    between static and dynamic specializers.
216:        //  - Functionality pulled up in abstract classes
217:        //  - Uniformization of advice methods patterns and names
218:        //
219:        // Revision 1.9  2003/03/04 18:36:10  popovici
220:        // Organization of imprts
221:        //
222:        // Revision 1.8  2003/03/04 11:25:56  popovici
223:        // Important refactorization step (march):
224:        // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
225:        // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
226:        //   structures
227:        //
228:        // Revision 1.7  2002/11/26 17:15:30  pschoch
229:        // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
230:        // ProseSystem now owns and starts the Aspect interface.
231:        // ProseSystem now containes  a 'test' AspectManager
232:        // AspectManager now owns the JoinPointManager.
233:        // ExtensionManger can be 'connected' to the JVM, or disconnected. The
234:        // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
235:        // JoinPointManger of a disconnected Ext.Mgr never enables join-points
236:        // Documentation updated accordingly.
237:        //
238:        // Revision 1.6  2002/06/06 14:39:54  popovici
239:        // Renamings: FunctionalCrosscut->MethodCut
240:        // AllFields->SetCut
241:        // SetCu.fieldModiticationAdvice -> SetCut.setAdvice
242:        //
243:        // Revision 1.5  2002/06/06 12:01:46  popovici
244:        // fieldAccessAdvice removed from AllFields; tests and usage of AllFields's
245:        // ability to intercept gets moved to 'GetCut'
246:        // Minor bug fixes;
247:        //
248:        // Revision 1.4  2002/06/05 12:03:49  popovici
249:        // thisJoinPoint() updated everywhere. The 'fieldModificationAdvice is now parameterless'; older implemnentations now
250:        // use 'thisJoinPoint()'
251:        //
252:        // Revision 1.3  2002/02/21 13:03:05  popovici
253:        // Updated to new performance-optimized design: Crosscuts receive joinpoints, no Event notification, etc
254:        //
255:        // Revision 1.2  2002/02/05 11:20:36  smarkwal
256:        // modifications to test JVMAI-based implementation
257:        //
258:        // Revision 1.1.1.1  2001/11/29 18:13:30  popovici
259:        // Sources from runes
260:        //
261:        // Revision 1.1.2.2  2001/02/22 16:51:56  popovici
262:        // ProseSystem.setup replaced with startup; teardown introduced
263:        //
264:        // Revision 1.1.2.1  2001/01/17 21:25:17  groos
265:        // initial revision.
266:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.