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


001:        // $Id: FunctionalCrosscutTest.java,v 1.2 2004/05/12 17:26:51 anicoara Exp $
002:        // =====================================================================
003:        //
004:        // (history at end)
005:        //
006:
007:        package ch.ethz.prose.crosscut;
008:
009:        // used packages
010:        import java.lang.reflect.Method;
011:        import java.util.*;
012:
013:        import junit.framework.*;
014:        import ch.ethz.prose.ProseSystem;
015:        import ch.ethz.prose.filter.PointCutter;
016:        import ch.ethz.prose.filter.Within;
017:
018:        /**
019:         * JUnit testcase for class FunctionalCrosscut.
020:         *
021:         * @version	$Revision: 1.2 $
022:         * @author	Andrei Popovici
023:         */
024:        public class FunctionalCrosscutTest extends TestCase {
025:
026:            class FunctionalCrosscutExample extends MethodCut {
027:                void METHOD_ARGS(ANY this Object, REST params) {
028:                    System.err.println(">>>" + this Object.getObject() + "/"
029:                            + params.getObject());
030:                }
031:
032:                protected PointCutter pointCutter() {
033:                    return null;
034:                }
035:            }
036:
037:            /**
038:             * Construct test with given name.
039:             * @param name test name
040:             */
041:            public FunctionalCrosscutTest(String name) {
042:                super (name);
043:            }
044:
045:            List lastEACall;
046:            MethodCut exampleCrosscut1 = null;
047:            MethodCut exampleCrosscut2 = null;
048:            MethodCut exampleCrosscut3 = null;
049:            MethodCut exampleCrosscut4 = null;
050:            MethodCut exampleCrosscut5 = null;
051:            MethodCut exampleCrosscut6 = null;
052:
053:            /**
054:             * Set up fixture.
055:             */
056:            protected void setUp() {
057:                try {
058:                    exampleCrosscut1 = new FunctionalCrosscutExample();
059:
060:                    exampleCrosscut2 = new MethodCut() {
061:                        protected PointCutter pointCutter() {
062:                            return Within.method("someMethod");
063:                        }
064:
065:                        public void METHOD_ARGS(ANY this Object, REST params) {
066:                        }
067:                    };
068:
069:                    exampleCrosscut4 = new MethodCut() {
070:                        public void METHOD_ARGS(String receiver, REST params) {
071:                        }
072:
073:                        protected PointCutter pointCutter() {
074:                            return Within.method("someOtherMethod");
075:                        }
076:                    };
077:
078:                    exampleCrosscut5 = new MethodCut() {
079:                        public void METHOD_ARGS(Vector receiver, int param) {
080:                        }
081:
082:                        protected PointCutter pointCutter() {
083:                            return null;
084:                        }
085:                    };
086:
087:                    exampleCrosscut6 = new MethodCut() {
088:                        public void METHOD_ARGS(Vector receiver, int param,
089:                                REST theRestArgs) {
090:                        }
091:
092:                        protected PointCutter pointCutter() {
093:                            return null;
094:                        }
095:                    };
096:
097:                    ProseSystem.startup();
098:                } catch (Throwable e) {
099:                    e.printStackTrace();
100:                    Assert.fail("ProseSystem.startup() failed.");
101:                }
102:
103:                try {
104:                    exampleCrosscut1.insertionAction(true);
105:                    exampleCrosscut2.insertionAction(true);
106:                    exampleCrosscut4.insertionAction(true);
107:                    exampleCrosscut5.insertionAction(true);
108:                    exampleCrosscut6.insertionAction(true);
109:                } catch (Exception e) {
110:                    // let exampleCrosscut 1 be initialized properly. We
111:                    // are going to test just a the 'doCreateRequestMethod',
112:                    // thus missing some initialization steps in create request.
113:                }
114:
115:                lastEACall = null;
116:            }
117:
118:            protected void tearDown() {
119:                try {
120:                    ProseSystem.teardown();
121:                } catch (Exception e) {
122:                    Assert.fail("ProseSystem.teardown() failed");
123:                }
124:            }
125:
126:            public void testAdviceMethod() {
127:                Method meth1 = ((MethodCutSignaturePattern) (exampleCrosscut1.adviceSignature)).methodObj;
128:                assertNotNull(meth1);
129:                assertEquals(meth1.getName(), "METHOD_ARGS");
130:                Method meth2 = ((MethodCutSignaturePattern) (exampleCrosscut2.adviceSignature)).methodObj;
131:                assertNotNull(meth2);
132:
133:                Exception thrownException = null;
134:                try {
135:                    exampleCrosscut3 = new MethodCut() {
136:                        protected PointCutter pointCutter() {
137:                            return null;
138:                        }
139:                    };
140:                } catch (MissingInformationException e) {
141:                    thrownException = e;
142:                }
143:
144:                assertNotNull("thrown exception should be non-null",
145:                        thrownException);
146:            }
147:
148:            public void testPotentialCroscutClasses() {
149:                assertTrue("ANY matches at least 100 classes", exampleCrosscut1
150:                        .potentialCrosscutClasses().length > 100);
151:                assertTrue(exampleCrosscut4.potentialCrosscutClasses()[0] == String.class);
152:            }
153:
154:            public void testDoCreateRequest() throws Exception {
155:                try {
156:                    CrosscutRequest cr1 = exampleCrosscut1
157:                            .doCreateRequest(Vector.class);
158:                    assertTrue("list of public method in vector in non-empty",
159:                            cr1.size() > 0);
160:
161:                    CrosscutRequest cr5 = exampleCrosscut5
162:                            .doCreateRequest(Vector.class);
163:
164:                    CrosscutRequest cr6 = exampleCrosscut6
165:                            .doCreateRequest(Vector.class);
166:
167:                    assertTrue("more methods in cr6", cr6.size() > cr5.size());
168:                } catch (Exception e) {
169:                    e.printStackTrace();
170:                    throw e;
171:                }
172:            }
173:
174:            public void exampleAdvice(ANY c, int a, REST params) {
175:                lastEACall = new Vector();
176:                lastEACall.add(c.getObject());
177:                lastEACall.add(new Integer(a));
178:                lastEACall.add(params.getObject());
179:            }
180:
181:            public void exampleLocalCall(int a, String b, Date c) {
182:            }
183:
184:            /** 
185:             * Test whether the actions are ok
186:             */
187:            public void _testDoCreateLocalAction() throws Exception {
188:                try {
189:                    Method eaMethod = getClass()
190:                            .getMethod(
191:                                    "exampleAdvice",
192:                                    new Class[] { ANY.class, Integer.TYPE,
193:                                            REST.class });
194:                    assertNotNull(eaMethod);
195:                    Object[] localParams = new Object[] { "RECEIVER",
196:                            new Integer(5), "hahah", new Date() };
197:
198:                    //exampleCrosscut1.localActionImpl(this,
199:                    //				   eaMethod,
200:                    //				   "RECEIVER",
201:                    //				   localParams);
202:
203:                    assertEquals(lastEACall.get(0), "RECEIVER");
204:                    assertEquals(lastEACall.get(1), new Integer(5));
205:                    assertEquals(((Object[]) (lastEACall.get(2)))[0], "hahah");
206:                } catch (Exception e) {
207:                    e.printStackTrace();
208:                    throw e;
209:                }
210:            }
211:
212:            /**
213:             * Test suite. Die methode
214:             *
215:             * @return test instance
216:             */
217:            public static Test suite() {
218:                return new TestSuite(FunctionalCrosscutTest.class);
219:            }
220:        }
221:
222:        //======================================================================
223:        //
224:        // $Log: FunctionalCrosscutTest.java,v $
225:        // Revision 1.2  2004/05/12 17:26:51  anicoara
226:        // Adapt Junit tests to 3.8.1 version and the new package structure
227:        //
228:        // Revision 1.1.1.1  2003/07/02 15:30:43  apopovic
229:        // Imported from ETH Zurich
230:        //
231:        // Revision 1.1  2003/05/05 14:03:28  popovici
232:        // renaming from runes to prose
233:        //
234:        // Revision 1.17  2003/04/27 13:08:55  popovici
235:        // Specializers renamed to PointCutter
236:        //
237:        // Revision 1.16  2003/04/17 15:15:17  popovici
238:        // Extension->Aspect renaming
239:        //
240:        // Revision 1.15  2003/04/17 13:54:33  popovici
241:        // Refactorization of 'ExecutionS' into 'Within' and 'Executions'.
242:        // Method names refer now to 'types'
243:        //
244:        // Revision 1.14  2003/04/17 12:49:43  popovici
245:        // Refactoring of the crosscut package
246:        //  ExceptionCut renamed to ThrowCut
247:        //  McutSignature is now SignaturePattern
248:        //
249:        // Revision 1.13  2003/04/17 08:46:48  popovici
250:        // Important functionality additions
251:        //  - Cflow specializers
252:        //  - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
253:        //  - Transactional capabilities
254:        //  - Total refactoring of Specializer evaluation, which permits fine-grained distinction
255:        //    between static and dynamic specializers.
256:        //  - Functionality pulled up in abstract classes
257:        //  - Uniformization of advice methods patterns and names
258:        //
259:        // Revision 1.12  2003/03/05 15:26:44  popovici
260:        // Bug fixes after the extraction of 'AdviceMethod' and 'AdviceExcecution' as top level classes:
261:        //  - a new Abstract class is superclassing 'UserDefinedAdvice' and 'DefaultAdvice'
262:        //
263:        // Revision 1.11  2003/03/04 18:36:40  popovici
264:        // Organization of imprts
265:        //
266:        // Revision 1.10  2003/03/04 11:26:00  popovici
267:        // Important refactorization step (march):
268:        // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
269:        // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
270:        //   structures
271:        //
272:        // Revision 1.9  2002/11/26 17:15:36  pschoch
273:        // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
274:        // ProseSystem now owns and starts the Aspect interface.
275:        // ProseSystem now containes  a 'test' AspectManager
276:        // AspectManager now owns the JoinPointManager.
277:        // ExtensionManger can be 'connected' to the JVM, or disconnected. The
278:        // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
279:        // JoinPointManger of a disconnected Ext.Mgr never enables join-points
280:        // Documentation updated accordingly.
281:        //
282:        // Revision 1.8  2002/06/06 18:53:49  popovici
283:        // 1. Bug fix: methodAdvice is now public; the constructor works for all subclasses.
284:        // 2. Feature change/bug fix: ADVICE_NAME is now a protected method
285:        //
286:        // Revision 1.7  2002/06/06 14:39:49  popovici
287:        // Renamings: FunctionalCrosscut->MethodCut
288:        // AllFields->SetCut
289:        // SetCu.fieldModiticationAdvice -> SetCut.setAdvice
290:        //
291:        // Revision 1.6  2002/06/03 13:01:16  popovici
292:        // renaming of the inner classes & objects, elimination of the local action
293:        //
294:        // Revision 1.5  2002/06/03 12:15:13  popovici
295:        //  VisibleCrosscutClass eliminated; test suites adapted for the fact that crosscutsjunit/ch/ethz/inf/runes/crosscut/FunctionalCrosscutTest.java
296:        // now miss information upon creation (not upon insertion)
297:        //
298:        // Revision 1.4  2002/03/06 13:48:50  popovici
299:        // joinPointAction now in 4 flavours, depending on the join point type
300:        //
301:        // Revision 1.3  2002/02/21 13:03:06  popovici
302:        // Updated to new performance-optimized design: Crosscuts receive joinpoints, no Event notification, etc
303:        //
304:        // Revision 1.2  2002/02/05 11:19:29  smarkwal
305:        // modifications to test JVMAI-based implementation
306:        //
307:        // Revision 1.1.1.1  2001/11/29 18:13:31  popovici
308:        // Sources from runes
309:        //
310:        // Revision 1.1.2.3  2001/11/21 11:56:38  popovici
311:        //
312:        // -The sun.tools.agent and ch.ethz.inf.util.JVMDIUtil functionality
313:        // replaced with the iks.jvmdi package. References to this old
314:        // functionality replaced throughout the code.
315:        // -Partial reimplementation of the ch.ethz.inf.iks.runes classes,
316:        // part of their functionality moved to the ch.ethz.prose.reflect
317:        // abstract classes. New classes and functionality added to the
318:        // ch.ethz.prose.reflect package, partially to reflect the
319:        // more stable features taken from the iks.runes packages, partially
320:        // to reflect the structure of the VM (constant pool, etc). Functionality in
321:        // ch.ethz.prose.crosscut and the junit classes adapted to use the
322:        // new form of the ch.ethz.prose.reflect package
323:        //
324:        // Revision 1.1.2.2  2001/01/18 14:28:55  popovici
325:        // Test 'doCreateLocalAction' handles now exceptions verbosely.
326:        //
327:        // Revision 1.1.2.1  2000/10/23 18:50:30  popovici
328:        // Initial Revision
329:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.