Source Code Cross Referenced for FieldNotificationTestWithOutput.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 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:
018:        /**
019:         * FieldNotificationTestWithOutput. This is almost the same as
020:         * <code>FieldNotificationTest</code>, but this one produces output
021:         * rather than doing some assertion tests to allow the user to see how
022:         * the field access and modification mechanism actually works.
023:         *
024:         * @version	$Revision: 1.2 $
025:         * @author Gerard Roos
026:         */
027:        public class FieldNotificationTestWithOutput extends TestCase {
028:
029:            static class TestClass {
030:                int initial = 1;
031:                int inConstr;
032:                int undefined;
033:
034:                int[] array;
035:
036:                Object o = null;
037:
038:                public TestClass() {
039:                    inConstr = 2;
040:                }
041:
042:            }
043:
044:            public static class TestExtension extends DefaultAspect {
045:
046:                public Crosscut c1 = new GetCut() {
047:                    public void GET_ARGS() {
048:                        FieldAccessJoinPoint theEv = (FieldAccessJoinPoint) this JoinPoint();
049:                        Field f = theEv.getField();
050:
051:                        Object owner = theEv.getTarget();
052:
053:                        try {
054:                            System.out.println("READ ACCESS");
055:                            System.out.println("class: "
056:                                    + owner.getClass().getName());
057:                            System.out.println("owner: " + owner);
058:                            System.out.println("fieldname: " + f.getName());
059:                            System.out.println("value: " + f.get(owner));
060:                            System.out.println();
061:                        } catch (Exception e) {
062:                            e.printStackTrace();
063:                        }
064:                    }
065:
066:                    protected PointCutter pointCutter() {
067:                        return null;
068:                    }
069:
070:                };
071:
072:                public Crosscut c = new SetCut() {
073:                    public void SET_ARGS() {
074:                        try {
075:                            FieldModificationJoinPoint fme = (FieldModificationJoinPoint) this JoinPoint();
076:
077:                            System.out.println("MODIFICATION ACCESS");
078:                            System.out.println("class: "
079:                                    + fme.getTarget().getClass().getName());
080:                            System.out.println("owner: " + fme.getTarget());
081:                            System.out.println("fieldname: "
082:                                    + fme.getField().getName());
083:                            System.out.println("old value: "
084:                                    + fme.getField().get(fme.getTarget()));
085:                            System.out.println("new value: "
086:                                    + fme.getNewValue());
087:                            System.out.println();
088:                        } catch (Exception e) {
089:                            e.printStackTrace();
090:                        }
091:                    }
092:
093:                    protected PointCutter pointCutter() {
094:                        return null;
095:                    }
096:
097:                    // restrict to TestClass
098:                    protected Class[] potentialCrosscutClasses() {
099:                        Class[] result = { TestClass.class };
100:                        return result;
101:                    }
102:                };
103:            };
104:
105:            TestClass test;
106:
107:            /**
108:             * Construct test with given name.
109:             * @param name test name
110:             */
111:            public FieldNotificationTestWithOutput(String name) {
112:                super (name);
113:            }
114:
115:            /**
116:             * Set up fixture.
117:             */
118:            protected void setUp() {
119:                try {
120:                    ProseSystem.startup();
121:                } catch (Exception e) {
122:                    Assert.fail("ProseSystem.startup() failed.");
123:                }
124:            }
125:
126:            protected void tearDown() throws SystemTeardownException {
127:                try {
128:                    ProseSystem.teardown();
129:                } catch (Exception e) {
130:                    Assert.fail("ProseSystem.teardown() failed.");
131:                }
132:            }
133:
134:            public void testInstantiation() throws Exception {
135:
136:                int[] arr = { 1, 2, 3, 4, 5 };
137:
138:                System.out.println("\n\ncreate new instance...\n");
139:                ProseSystem.getAspectManager().insert(new TestExtension());
140:                test = new TestClass();
141:
142:                System.out.println("\naccess the fields...\n");
143:                test.undefined = -5;
144:                test.o = new Object();
145:                test.array = arr;
146:                arr[0] = 0;
147:                test.array = arr;
148:                test.array[1] = 9;
149:                test.array[3] = 1;
150:                test.array[4] = 10;
151:            }
152:
153:            /**
154:             * Test suite.
155:             * @return test instance
156:             */
157:            public static Test suite() {
158:                return new TestSuite(FieldNotificationTestWithOutput.class);
159:            }
160:
161:        }
162:
163:        //======================================================================
164:        //
165:        // $Log: FieldNotificationTestWithOutput.java,v $
166:        // Revision 1.2  2004/05/12 17:26:51  anicoara
167:        // Adapt Junit tests to 3.8.1 version and the new package structure
168:        //
169:        // Revision 1.1.1.1  2003/07/02 15:30:42  apopovic
170:        // Imported from ETH Zurich
171:        //
172:        // Revision 1.1  2003/05/05 14:02:30  popovici
173:        // renaming from runes to prose
174:        //
175:        // Revision 1.12  2003/04/27 13:08:40  popovici
176:        // Specializers renamed to PointCutter
177:        //
178:        // Revision 1.11  2003/04/17 15:15:02  popovici
179:        // Extension->Aspect renaming
180:        //
181:        // Revision 1.10  2003/04/17 12:49:39  popovici
182:        // Refactoring of the crosscut package
183:        //  ExceptionCut renamed to ThrowCut
184:        //  McutSignature is now SignaturePattern
185:        //
186:        // Revision 1.9  2003/04/17 08:46:44  popovici
187:        // Important functionality additions
188:        //  - Cflow specializers
189:        //  - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
190:        //  - Transactional capabilities
191:        //  - Total refactoring of Specializer evaluation, which permits fine-grained distinction
192:        //    between static and dynamic specializers.
193:        //  - Functionality pulled up in abstract classes
194:        //  - Uniformization of advice methods patterns and names
195:        //
196:        // Revision 1.8  2003/03/04 18:36:09  popovici
197:        // Organization of imprts
198:        //
199:        // Revision 1.7  2003/03/04 11:25:57  popovici
200:        // Important refactorization step (march):
201:        // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
202:        // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
203:        //   structures
204:        //
205:        // Revision 1.6  2002/11/26 17:15:31  pschoch
206:        // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
207:        // ProseSystem now owns and starts the Aspect interface.
208:        // ProseSystem now containes  a 'test' AspectManager
209:        // AspectManager now owns the JoinPointManager.
210:        // ExtensionManger can be 'connected' to the JVM, or disconnected. The
211:        // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
212:        // JoinPointManger of a disconnected Ext.Mgr never enables join-points
213:        // Documentation updated accordingly.
214:        //
215:        // Revision 1.5  2002/06/06 14:39:53  popovici
216:        // Renamings: FunctionalCrosscut->MethodCut
217:        // AllFields->SetCut
218:        // SetCu.fieldModiticationAdvice -> SetCut.setAdvice
219:        //
220:        // Revision 1.4  2002/06/06 12:01:47  popovici
221:        // fieldAccessAdvice removed from AllFields; tests and usage of AllFields's
222:        // ability to intercept gets moved to 'GetCut'
223:        // Minor bug fixes;
224:        //
225:        // Revision 1.3  2002/06/05 12:03:49  popovici
226:        // thisJoinPoint() updated everywhere. The 'fieldModificationAdvice is now parameterless'; older implemnentations now
227:        // use 'thisJoinPoint()'
228:        //
229:        // Revision 1.2  2002/02/05 11:20:43  smarkwal
230:        // modifications to test JVMAI-based implementation
231:        //
232:        // Revision 1.1.1.1  2001/11/29 18:13:30  popovici
233:        // Sources from runes
234:        //
235:        // Revision 1.1.2.2  2001/02/22 16:52:23  popovici
236:        // ProseSystem.setup replaced with startup; teardown introduced
237:        //
238:        // Revision 1.1.2.1  2001/01/17 21:25:47  groos
239:        // initial revision.
240:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.