Source Code Cross Referenced for LocalExtensionManagerTest.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.Method;
011:        import java.util.*;
012:
013:        import junit.framework.*;
014:        import ch.ethz.jvmai.ExceptionJoinPoint;
015:        import ch.ethz.prose.crosscut.*;
016:        import ch.ethz.prose.engine.ExceptionThrowRequest;
017:        import ch.ethz.prose.engine.JoinPointManager;
018:        import ch.ethz.prose.filter.*;
019:        import ch.ethz.prose.query.*;
020:
021:        /**
022:         * JUnit testcase for class tests the correctness of the 
023:         * <code>Local Aspect Manager</code> implementation.
024:         *
025:         * @version	$Revision$
026:         * @author	Andrei Popovici
027:         */
028:        public class LocalExtensionManagerTest extends TestCase {
029:
030:            public boolean visited = false;
031:            public boolean visited1 = false;
032:            public boolean visited2 = false;
033:
034:            public void myTestMethod() {
035:            }
036:
037:            class TestExtension1 extends DefaultAspect {
038:                public void insertionAction(boolean flag) {
039:                    LocalExtensionManagerTest.this .myTestMethod();
040:                }
041:
042:                public Crosscut c1 = new MethodCut() {
043:                    public void METHOD_ARGS(LocalExtensionManagerTest x) {
044:                        visited1 = true;
045:                        visited = true;
046:                    }
047:
048:                    protected PointCutter pointCutter() {
049:                        return Within.method("myTestMethod");
050:                    }
051:                };
052:            };
053:
054:            class TestExtension2 extends DefaultAspect {
055:                public void insertionAction(boolean flag) {
056:                    LocalExtensionManagerTest.this .myTestMethod();
057:                }
058:
059:                public Crosscut c1 = new MethodCut() {
060:                    public void METHOD_ARGS(LocalExtensionManagerTest x) {
061:                        visited2 = true;
062:                    }
063:
064:                    protected PointCutter pointCutter() {
065:                        return Within.method("myTestMethod");
066:                    }
067:                };
068:            }
069:
070:            Aspect tstExtension = null;
071:            Aspect tstExtension2 = null;
072:
073:            // fixture for queryMethods
074:            int ASP = QueryManager.SELECT_ASPECT;
075:            int CRO = QueryManager.SELECT_CROSSCUT;
076:            int JOI = QueryManager.SELECT_JOINPOINT;
077:            int ASP_CRO = ASP + CRO;
078:            int ASP_JOI = ASP + JOI;
079:            int CRO_JOI = CRO + JOI;
080:            int ASP_CRO_JOI = ASP + CRO + JOI;
081:            int GROUP_ASP = QueryManager.GROUP_BY_ASPECT;
082:            int GROUP_CRO = QueryManager.GROUP_BY_CROSSCUT;
083:            int GROUP_JOI = QueryManager.GROUP_BY_JOINPOINT;
084:
085:            JoinPointManager jpm = null;
086:            AspectManager exMngr = null;
087:
088:            public static class Extension1 extends DefaultAspect {
089:                public Crosscut c1a = new ThrowCut() {
090:                    public void THROW_ARGS() {
091:                    }
092:
093:                    public Class[] potentialCrosscutClasses() {
094:                        Class[] result = { LinkageError.class,
095:                                IllegalStateException.class,
096:                                InstantiationError.class,
097:                                NullPointerException.class,
098:                                RuntimeException.class, ClassFormatError.class,
099:                                UnknownError.class };
100:                        return result;
101:                    }
102:
103:                    protected PointCutter pointCutter() {
104:                        return (Exceptions.type("LinkageError")).OR(Exceptions
105:                                .type("IllegalStateException"));
106:                    }
107:                };
108:            };
109:
110:            public static class Extension2 extends DefaultAspect {
111:                //2 excceptions
112:                public Crosscut c2a = new ThrowCut() {
113:                    public void THROW_ARGS() {
114:                    }
115:
116:                    public Class[] potentialCrosscutClasses() {
117:                        Class[] result = { LinkageError.class,
118:                                IllegalStateException.class,
119:                                InstantiationError.class,
120:                                NullPointerException.class,
121:                                RuntimeException.class, ClassFormatError.class,
122:                                UnknownError.class };
123:                        return result;
124:                    }
125:
126:                    protected PointCutter pointCutter() {
127:                        return (Exceptions.type("InstantiationError"))
128:                                .OR(Exceptions.type("UnknownError"));
129:                    }
130:                };
131:
132:                public Crosscut c2b = new ThrowCut() {
133:                    // 2 exceptions
134:                    public void THROW_ARGS() {
135:                    }
136:
137:                    public Class[] potentialCrosscutClasses() {
138:                        Class[] result = { LinkageError.class,
139:                                IllegalStateException.class,
140:                                InstantiationError.class,
141:                                NullPointerException.class,
142:                                RuntimeException.class, ClassFormatError.class,
143:                                UnknownError.class };
144:                        return result;
145:                    }
146:
147:                    protected PointCutter pointCutter() {
148:                        return (Exceptions.type("NullPointerException"))
149:                                .OR(Exceptions.type("RuntimeException"));
150:                    }
151:                };
152:
153:                // 2 exceptions
154:                public Crosscut c2c = new ThrowCut() {
155:                    public void THROW_ARGS() {
156:                    }
157:
158:                    public Class[] potentialCrosscutClasses() {
159:                        Class[] result = { LinkageError.class,
160:                                IllegalStateException.class,
161:                                InstantiationError.class,
162:                                NullPointerException.class,
163:                                RuntimeException.class, ClassFormatError.class,
164:                                UnknownError.class };
165:                        return result;
166:                    }
167:
168:                    protected PointCutter pointCutter() {
169:                        return (Exceptions.type("ClassFormatError"))
170:                                .OR(Exceptions.type("UnknownError"));
171:                    }
172:                };
173:            };
174:
175:            // This Aspect don't have a joinpoint!
176:            public static class Extension3 extends DefaultAspect {
177:                public Crosscut c3a = new ThrowCut() {
178:                    public void THROW_ARGS() {
179:                    }
180:
181:                    protected PointCutter pointCutter() {
182:                        return (Exceptions.type("thisIsSurelyNotAnException"));
183:                    }
184:                };
185:            };
186:
187:            /**
188:             * Construct test with given name.
189:             * @param name test name
190:             */
191:            public LocalExtensionManagerTest(String name) {
192:                super (name);
193:            }
194:
195:            /**
196:             * Set up fixture.
197:             */
198:            public void setUp() {
199:                tstExtension = new TestExtension1();
200:                tstExtension2 = new TestExtension2();
201:                try {
202:                    ProseSystem.startup();
203:                    exMngr = ProseSystem.getAspectManager();
204:                    jpm = ProseSystem.getAspectManager().getJoinPointManager();
205:                } catch (SystemStartupException e) {
206:                    Assert.fail("could not start ProseSystem");
207:                }
208:            }
209:
210:            public void tearDown() {
211:                try {
212:                    ProseSystem.teardown();
213:                } catch (SystemTeardownException e) {
214:                    Assert.fail("could not teardown ProseSystem");
215:                }
216:            }
217:
218:            /** This test checks that the call to a breakpointed method
219:             * <em>during</em> <code>insert</code> is not dispatched to
220:             * the extension. <em>THIS TEST FAILES!! FIX!!</em>
221:             *
222:             */
223:            public void test0010_SilenceDuringInsertion() {
224:                visited = false;
225:                ProseSystem.getAspectManager().insert(tstExtension);
226:                assertTrue("not visited during insertion", !visited);
227:                visited = false;
228:                myTestMethod();
229:                assertTrue("visited after insertion", visited);
230:            }
231:
232:            public void test0020_queryAspect() {
233:                List result;
234:                List aspectList = new Vector();
235:                AspectManager exMngr = ProseSystem.getAspectManager();
236:
237:                Aspect aspect1 = new Extension1();
238:                Aspect aspect2 = new Extension2();
239:                Aspect aspect3 = new Extension3();
240:                ProseSystem.getAspectManager().insert(aspect1);
241:                ProseSystem.getAspectManager().insert(aspect2);
242:                ProseSystem.getAspectManager().insert(aspect3);
243:                aspectList.add(new AspectSurrogate(aspect1));
244:                aspectList.add(new AspectSurrogate(aspect2));
245:                aspectList.add(new AspectSurrogate(aspect3));
246:                QueryManager qMgr = new QueryManager(ProseSystem
247:                        .getAspectManager());
248:
249:                // Test every combination of 'select' value in queryAspect
250:                assertTrue("wrong select range", qMgr.queryAspects(aspectList,
251:                        0x00, GROUP_ASP).isEmpty());
252:
253:                // FIXME!!
254:                result = qMgr.queryAspects(aspectList, ASP_CRO_JOI, GROUP_ASP);
255:                assertEquals("select Aspect + Crosscut + Joinpoint", 9, result
256:                        .size());
257:
258:                result = qMgr.queryAspects(aspectList, ASP_CRO, GROUP_ASP);
259:                assertEquals("select Aspect + Crosscut", 5, result.size());
260:
261:                //result = qMgr.queryAspects(aspectList, ASP_JOI, GROUP_ASP);
262:                //assertEquals("select Aspect + Joinpoint", 8, result.size());
263:
264:                result = qMgr.queryAspects(aspectList, CRO_JOI, GROUP_ASP);
265:                assertEquals("select Crosscut + Joinpoint", 9, result.size());
266:
267:                result = qMgr.queryAspects(aspectList, ASP, GROUP_ASP);
268:                assertEquals("select Aspect", 3, result.size());
269:
270:                result = qMgr.queryAspects(aspectList, CRO, GROUP_ASP);
271:                assertEquals("select Crosscut", 5, result.size());
272:
273:                result = qMgr.queryAspects(aspectList, JOI, GROUP_ASP);
274:                assertEquals("select Joinpoint", 8, result.size());
275:            }
276:
277:            public void test0030_queryCrosscut() {
278:                List result;
279:                List crosscutList = new Vector();
280:
281:                LocalExtensionManagerTest.Extension1 aspect1 = new Extension1();
282:                LocalExtensionManagerTest.Extension2 aspect2 = new Extension2();
283:                LocalExtensionManagerTest.Extension3 aspect3 = new Extension3();
284:                ProseSystem.getAspectManager().insert(aspect1);
285:                ProseSystem.getAspectManager().insert(aspect2);
286:                ProseSystem.getAspectManager().insert(aspect3);
287:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
288:                        aspect1), aspect1.c1a));
289:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
290:                        aspect2), aspect2.c2a));
291:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
292:                        aspect2), aspect2.c2b));
293:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
294:                        aspect2), aspect2.c2c));
295:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
296:                        aspect3), aspect3.c3a));
297:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
298:                        aspect1), aspect1.c1a));
299:                crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
300:                        aspect1), aspect1.c1a));
301:                QueryManager qMgr = new QueryManager(ProseSystem
302:                        .getAspectManager());
303:
304:                // Test every combination of 'select' value in queryCrosscuts
305:                assertTrue("wrong select range", qMgr.queryCrosscuts(
306:                        crosscutList, 0x00, GROUP_ASP).isEmpty());
307:
308:                result = qMgr.queryCrosscuts(crosscutList, ASP_CRO_JOI,
309:                        GROUP_ASP);
310:                assertEquals("select Aspect + Crosscut + Joinpoint", 9, result
311:                        .size());
312:
313:                result = qMgr.queryCrosscuts(crosscutList, ASP_CRO, GROUP_ASP);
314:                assertEquals("select Aspect + Crosscut", 5, result.size());
315:
316:                result = qMgr.queryCrosscuts(crosscutList, ASP_JOI, GROUP_ASP);
317:                assertEquals("select Aspect + Joinpoint", 8, result.size());
318:
319:                result = qMgr.queryCrosscuts(crosscutList, CRO_JOI, GROUP_ASP);
320:                assertEquals("select Crosscut + Joinpoint", 9, result.size());
321:
322:                result = qMgr.queryCrosscuts(crosscutList, ASP, GROUP_ASP);
323:                assertEquals("select Aspect", 3, result.size());
324:
325:                result = qMgr.queryCrosscuts(crosscutList, CRO, GROUP_ASP);
326:                assertEquals("select Crosscut", 5, result.size());
327:
328:                result = qMgr.queryCrosscuts(crosscutList, JOI, GROUP_ASP);
329:                assertEquals("select Joinpoint", 8, result.size());
330:            }
331:
332:            public void test0040_queryJoinpoint() {
333:                List result;
334:                List joinpointList = new Vector();
335:                try {
336:                    Aspect aspect1 = new Extension1();
337:                    Aspect aspect2 = new Extension2();
338:                    Aspect aspect3 = new Extension3();
339:                    QueryManager qMgr = new QueryManager(ProseSystem
340:                            .getAspectManager());
341:
342:                    ProseSystem.getAspectManager().insert(aspect1);
343:                    ProseSystem.getAspectManager().insert(aspect2);
344:                    ProseSystem.getAspectManager().insert(aspect3);
345:
346:                    joinpointList.add(new JoinPointRequestSurrogate(
347:                            (ExceptionThrowRequest) jpm
348:                                    .createJoinPointRequest(
349:                                            ExceptionJoinPoint.KIND,
350:                                            LinkageError.class)));
351:                    joinpointList.add(new JoinPointRequestSurrogate(
352:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
353:                                    ExceptionJoinPoint.KIND,
354:                                    IllegalStateException.class)));
355:                    joinpointList.add(new JoinPointRequestSurrogate(
356:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
357:                                    ExceptionJoinPoint.KIND,
358:                                    InstantiationError.class)));
359:                    joinpointList.add(new JoinPointRequestSurrogate(
360:                            (ExceptionThrowRequest) jpm
361:                                    .createJoinPointRequest(
362:                                            ExceptionJoinPoint.KIND,
363:                                            UnknownError.class)));
364:                    joinpointList.add(new JoinPointRequestSurrogate(
365:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
366:                                    ExceptionJoinPoint.KIND,
367:                                    NullPointerException.class)));
368:                    joinpointList.add(new JoinPointRequestSurrogate(
369:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
370:                                    ExceptionJoinPoint.KIND,
371:                                    RuntimeException.class)));
372:                    joinpointList.add(new JoinPointRequestSurrogate(
373:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
374:                                    ExceptionJoinPoint.KIND,
375:                                    ClassFormatError.class)));
376:                    // one joinpoint that is not member to an inserted aspect
377:                    joinpointList.add(new JoinPointRequestSurrogate(
378:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
379:                                    ExceptionJoinPoint.KIND,
380:                                    SystemStartupException.class)));
381:                    // two joinpoints added twice (should not have any influence)
382:                    joinpointList.add(new JoinPointRequestSurrogate(
383:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
384:                                    ExceptionJoinPoint.KIND,
385:                                    RuntimeException.class)));
386:                    joinpointList.add(new JoinPointRequestSurrogate(
387:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
388:                                    ExceptionJoinPoint.KIND,
389:                                    ClassFormatError.class)));
390:
391:                    // Test every combination of 'select' value in queryJoinpoints
392:                    assertTrue("wrong select range", qMgr.queryJoinpoints(
393:                            joinpointList, 0x00, GROUP_ASP).isEmpty());
394:
395:                    result = qMgr.queryJoinpoints(joinpointList, ASP_CRO_JOI,
396:                            GROUP_ASP);
397:                    assertEquals("select Aspect + Crosscut + Joinpoint", 8,
398:                            result.size());
399:
400:                    result = qMgr.queryJoinpoints(joinpointList, ASP_CRO,
401:                            GROUP_ASP);
402:                    assertEquals("select Aspect + Crosscut", 4, result.size());
403:
404:                    result = qMgr.queryJoinpoints(joinpointList, ASP_JOI,
405:                            GROUP_ASP);
406:                    assertEquals("select Aspect + Joinpoint", 7, result.size());
407:
408:                    result = qMgr.queryJoinpoints(joinpointList, CRO_JOI,
409:                            GROUP_ASP);
410:                    assertEquals("select Crosscut + Joinpoint", 8, result
411:                            .size());
412:
413:                    result = qMgr
414:                            .queryJoinpoints(joinpointList, ASP, GROUP_ASP);
415:                    assertEquals("select Aspect", 2, result.size());
416:
417:                    result = qMgr
418:                            .queryJoinpoints(joinpointList, CRO, GROUP_ASP);
419:                    assertEquals("select Crosscut", 4, result.size());
420:
421:                    result = qMgr
422:                            .queryJoinpoints(joinpointList, JOI, GROUP_ASP);
423:                    assertEquals("select Joinpoint", 7, result.size());
424:                } catch (Exception e) {
425:                    e.printStackTrace();
426:                }
427:            }
428:
429:            // Test the 3 GROUP_BY combinations in all 3 'query'-methods (where all columns are selected)
430:            public void test0050_queryGroupBy() {
431:                try {
432:                    List result;
433:                    List aspectList = new Vector();
434:                    List crosscutList = new Vector();
435:                    List joinpointList = new Vector();
436:
437:                    LocalExtensionManagerTest.Extension1 aspect1 = new Extension1();
438:                    LocalExtensionManagerTest.Extension2 aspect2 = new Extension2();
439:                    LocalExtensionManagerTest.Extension3 aspect3 = new Extension3();
440:                    ProseSystem.getAspectManager().insert(aspect1);
441:                    ProseSystem.getAspectManager().insert(aspect2);
442:                    ProseSystem.getAspectManager().insert(aspect3);
443:                    aspectList.add(new AspectSurrogate(aspect1));
444:                    aspectList.add(new AspectSurrogate(aspect2));
445:                    aspectList.add(new AspectSurrogate(aspect3));
446:                    crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
447:                            aspect1), aspect1.c1a));
448:                    crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
449:                            aspect2), aspect2.c2a));
450:                    crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
451:                            aspect2), aspect2.c2b));
452:                    crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
453:                            aspect2), aspect2.c2c));
454:                    crosscutList.add(new CrosscutSurrogate(new AspectSurrogate(
455:                            aspect3), aspect3.c3a));
456:                    joinpointList.add(new JoinPointRequestSurrogate(
457:                            (ExceptionThrowRequest) jpm
458:                                    .createJoinPointRequest(
459:                                            ExceptionJoinPoint.KIND,
460:                                            LinkageError.class)));
461:                    joinpointList.add(new JoinPointRequestSurrogate(
462:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
463:                                    ExceptionJoinPoint.KIND,
464:                                    IllegalStateException.class)));
465:                    joinpointList.add(new JoinPointRequestSurrogate(
466:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
467:                                    ExceptionJoinPoint.KIND,
468:                                    InstantiationError.class)));
469:                    joinpointList.add(new JoinPointRequestSurrogate(
470:                            (ExceptionThrowRequest) jpm
471:                                    .createJoinPointRequest(
472:                                            ExceptionJoinPoint.KIND,
473:                                            UnknownError.class)));
474:                    joinpointList.add(new JoinPointRequestSurrogate(
475:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
476:                                    ExceptionJoinPoint.KIND,
477:                                    NullPointerException.class)));
478:                    joinpointList.add(new JoinPointRequestSurrogate(
479:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
480:                                    ExceptionJoinPoint.KIND,
481:                                    RuntimeException.class)));
482:                    joinpointList.add(new JoinPointRequestSurrogate(
483:                            (ExceptionThrowRequest) jpm.createJoinPointRequest(
484:                                    ExceptionJoinPoint.KIND,
485:                                    ClassFormatError.class)));
486:
487:                    QueryManager qMngr = new QueryManager(ProseSystem
488:                            .getAspectManager());
489:
490:                    result = qMngr.queryAspects(aspectList, ASP_CRO_JOI,
491:                            GROUP_ASP);
492:                    assertEquals("queryAspects with groupBy Aspects", 2,
493:                            computeTransitions(result, "getAspectSurrogate"));
494:                    result = qMngr.queryAspects(aspectList, ASP_CRO_JOI,
495:                            GROUP_CRO);
496:
497:                    assertEquals("queryAspects with groupBy Crosscuts", 4,
498:                            computeTransitions(result, "getCrosscutSurrogate"));
499:                    result = qMngr.queryAspects(aspectList, ASP_CRO_JOI,
500:                            GROUP_JOI);
501:                    assertEquals("queryAspects with groupBy Joinpoints", 7,
502:                            computeTransitions(result, "getRequestSurrogate"));
503:
504:                    result = qMngr.queryCrosscuts(crosscutList, ASP_CRO_JOI,
505:                            GROUP_ASP);
506:                    assertEquals("queryCrosscuts with groupBy Aspects", 2,
507:                            computeTransitions(result, "getAspectSurrogate"));
508:                    result = qMngr.queryCrosscuts(crosscutList, ASP_CRO_JOI,
509:                            GROUP_CRO);
510:                    assertEquals("queryCrosscuts with groupBy Crosscuts", 4,
511:                            computeTransitions(result, "getCrosscutSurrogate"));
512:                    result = qMngr.queryCrosscuts(crosscutList, ASP_CRO_JOI,
513:                            GROUP_JOI);
514:                    assertEquals("queryCrosscuts with groupBy Joinpoints", 7,
515:                            computeTransitions(result, "getRequestSurrogate"));
516:
517:                    result = qMngr.queryJoinpoints(joinpointList, ASP_CRO_JOI,
518:                            GROUP_ASP);
519:                    assertEquals("queryJoinpoints with groupBy Aspects", 1,
520:                            computeTransitions(result, "getAspectSurrogate"));
521:                    result = qMngr.queryJoinpoints(joinpointList, ASP_CRO_JOI,
522:                            GROUP_CRO);
523:                    assertEquals("queryJoinpoints with groupBy Crosscuts", 3,
524:                            computeTransitions(result, "getCrosscutSurrogate"));
525:                    result = qMngr.queryJoinpoints(joinpointList, ASP_CRO_JOI,
526:                            GROUP_JOI);
527:                    assertEquals("queryJoinpoints with groupBy Joinpoints", 6,
528:                            computeTransitions(result, "getRequestSurrogate"));
529:                } catch (Exception e) {
530:                    e.printStackTrace();
531:                    throw new RuntimeException(e.toString());
532:                }
533:            }
534:
535:            // compute the transitions in the ordered collection. it should be the minimum.
536:            // for multiple use of this method, the  method invokation in the comparing is parameterized.
537:            private int computeTransitions(List resultList, String queryMethod) {
538:                try {
539:                    Object o = null;
540:                    int code = 0, codeOld = 0;
541:                    boolean start = true;
542:                    int transition = 0;
543:                    Method m = Tuple.class.getDeclaredMethod(queryMethod,
544:                            new Class[] {});
545:                    Object[] emptyArray = new Object[] {};
546:
547:                    Iterator i = resultList.listIterator();
548:                    while (i.hasNext()) {
549:                        Tuple crtTuple = (Tuple) i.next();
550:
551:                        o = m.invoke(crtTuple, emptyArray);
552:
553:                        if (o == null)
554:                            code = 0;
555:                        else {
556:                            code = o.hashCode();
557:                        }
558:
559:                        if (start) {
560:                            start = false;
561:                            codeOld = code;
562:                            continue;
563:                        }
564:                        if (code != codeOld)
565:                            transition++;
566:
567:                        codeOld = code;
568:                    }
569:                    return transition;
570:                } catch (Exception e) {
571:                    throw new RuntimeException(e.getMessage());
572:                }
573:            }
574:
575:            public void test0060_testCommit() {
576:                Object txId = new Object();
577:
578:                visited1 = false;
579:                visited2 = false;
580:                ProseSystem.getAspectManager().insert(tstExtension, txId);
581:                myTestMethod();
582:                assertTrue("[1] not visited before commit", !visited1);
583:                assertTrue("[2] not visited before commit", !visited2);
584:                ProseSystem.getAspectManager().insert(tstExtension2, txId);
585:                myTestMethod();
586:                assertTrue("[3] not visited before commit", !visited1);
587:                assertTrue("[4] not visited before commit", !visited2);
588:                ProseSystem.getAspectManager().commit(txId);
589:                myTestMethod();
590:                assertTrue("[5] visited after commit", visited1);
591:                assertTrue("[6] visited after commit", visited2);
592:            }
593:
594:            public void test0070_testAbort() {
595:                Object txId = new Object();
596:
597:                visited1 = false;
598:                visited2 = false;
599:                ProseSystem.getAspectManager().insert(tstExtension, txId);
600:                myTestMethod();
601:                assertTrue("[1] not visited before commit", !visited1);
602:                assertTrue("[2] not visited before commit", !visited2);
603:                ProseSystem.getAspectManager().insert(tstExtension2, txId);
604:                myTestMethod();
605:                assertTrue("[3] not visited before commit", !visited1);
606:                assertTrue("[4] not visited before commit", !visited2);
607:                ProseSystem.getAspectManager().abort(txId);
608:                myTestMethod();
609:                assertTrue("[5] visited after commit", !visited1);
610:                assertTrue("[6] visited after commit", !visited2);
611:                assertEquals("no extension inserted", ProseSystem
612:                        .getAspectManager().getAllAspects().size(), 0);
613:            }
614:
615:            /**
616:             * Test suite.
617:             * @return test instance
618:             */
619:            public static Test suite() {
620:                return new TestSuite(LocalExtensionManagerTest.class);
621:            }
622:
623:        }
624:
625:        //======================================================================
626:        //
627:        // $Log$
628:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.