Source Code Cross Referenced for ExtensionSystemTest.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: ExtensionSystemTest.java,v 1.2 2004/05/12 17:26:50 anicoara Exp $
002:        // =====================================================================
003:        //
004:        // (history at end)
005:        //
006:
007:        package ch.ethz.prose;
008:
009:        // used packages
010:        import java.util.List;
011:        import java.util.Vector;
012:
013:        import junit.framework.*;
014:        import ch.ethz.jvmai.JVMAspectInterface;
015:        import ch.ethz.prose.engine.JoinPointManager;
016:
017:        /**
018:         * JUnit testcase for class ProseSystem.
019:         *
020:         * @version	$Revision: 1.2 $
021:         * @author	Andrei Popovici
022:         */
023:        public class ExtensionSystemTest extends TestCase {
024:
025:            public static class ExampleExtensionSystem {
026:
027:                public static boolean appSetupVisited = false;
028:
029:                public static void startup() throws SystemStartupException {
030:                    appSetupVisited = true;
031:                }
032:
033:                public static void teardown() throws SystemTeardownException {
034:                }
035:            }
036:
037:            public static class ExampleExtensionManager implements 
038:                    AspectManager {
039:
040:                public ExampleExtensionManager(boolean ic, JVMAspectInterface ai) {
041:                }
042:
043:                public List withdrawnExtensions = new Vector();
044:                public List insertedExtensions = new Vector();
045:
046:                public List getAllJoinpoints() {
047:                    return null;
048:                }
049:
050:                public void insert(Aspect ext, Object tx) {
051:                }
052:
053:                public void withdraw(Aspect ext, Object tx) {
054:                }
055:
056:                public void commit(Object tx) {
057:                }
058:
059:                public void abort(Object tx) {
060:                }
061:
062:                public void insert(Aspect ext) {
063:                    insertedExtensions.add(ext);
064:                }
065:
066:                public void withdraw(Aspect ext) {
067:                    withdrawnExtensions.add(ext);
068:                }
069:
070:                public List getAllAspects() {
071:                    return null;
072:                }
073:
074:                public JoinPointManager getJoinPointManager() {
075:                    return null;
076:                }
077:
078:                public void teardown() {
079:                }
080:
081:                public void startup() {
082:                }
083:
084:                public List queryAspects(List aspectList, int selectFields,
085:                        int groupBy) {
086:                    return null;
087:                }
088:
089:                public List queryCrosscuts(List crosscutList, int selectFields,
090:                        int groupBy) {
091:                    return null;
092:                }
093:
094:                public List queryJoinpoints(List joinpointList,
095:                        int selectFields, int groupBy) {
096:                    return null;
097:                }
098:
099:            }
100:
101:            /**
102:             * Construct test with given name.
103:             * @param name test name
104:             */
105:            public ExtensionSystemTest(String name) {
106:                super (name);
107:            }
108:
109:            private String originalExtensionManager;
110:
111:            /**
112:             * Set up fixture.
113:             */
114:            protected void setUp() {
115:                originalExtensionManager = System
116:                        .getProperty("ch.ethz.prose.EXManager");
117:                System
118:                        .setProperty("ch.ethz.prose.EXManager",
119:                                "ch.ethz.prose.ExtensionSystemTest$ExampleExtensionManager");
120:                System
121:                        .setProperty("ch.ethz.prose.ESSystem.1",
122:                                "ch.ethz.prose.ExtensionSystemTest$ExampleExtensionSystem");
123:            }
124:
125:            public void tearDown() {
126:                System.getProperties().remove("ch.ethz.prose.EXManager");
127:                System.getProperties().remove("ch.ethz.prose.ESSystem.1");
128:                if (null != originalExtensionManager)
129:                    System.setProperty("ch.ethz.prose.EXManager",
130:                            originalExtensionManager);
131:            }
132:
133:            /**
134:             * Test suite.
135:             * @return test instance
136:             */
137:            public static Test suite() {
138:                return new TestSuite(ExtensionSystemTest.class);
139:            }
140:
141:            // this test just calls the normal setup procedure
142:            // with no set property values;
143:            public void test1_SimpleSetup() throws Exception {
144:                System.getProperties().remove("ch.ethz.prose.EXManager");
145:                System.getProperties().remove("ch.ethz.prose.ESSystem.1");
146:
147:                ProseSystem.startup();
148:                assertNotNull(ProseSystem.getAspectManager());
149:                assertNotNull(ProseSystem.getTestAspectManager());
150:                ProseSystem.teardown();
151:            }
152:
153:            // this tests tests if the setup works in the presence
154:            // of correct set system properties
155:            public void test2_CustomSetup() throws Exception {
156:                try {
157:                    System.getProperties().remove("ch.ethz.prose.ESSystem.1");
158:
159:                    ProseSystem.startup();
160:                    assertNotNull(ProseSystem.getAspectManager());
161:                    assertNotNull(ProseSystem.getTestAspectManager());
162:                    assertTrue(
163:                            "current extension Manager have the correct type",
164:                            ProseSystem.getAspectManager() instanceof  ExampleExtensionManager);
165:                    assertTrue(
166:                            "test extension Manager have the correct type",
167:                            ProseSystem.getTestAspectManager() instanceof  ExampleExtensionManager);
168:                    ProseSystem.teardown();
169:                } catch (RuntimeException e) {
170:                    e.printStackTrace();
171:                    throw e;
172:                }
173:            }
174:
175:            // this tests if the setup works in the presence of an application-specific
176:            // setup method.
177:            public void test3_FullCustomSetup() throws Exception {
178:                try {
179:                    RootComponent.startup();
180:                    assertTrue(
181:                            " the initialization procedure touched the flag",
182:                            ExampleExtensionSystem.appSetupVisited);
183:                    RootComponent.teardown();
184:                } catch (Exception e) {
185:                    e.printStackTrace();
186:                }
187:            }
188:
189:            // test that the teardown action actually removes all
190:            // extensions and leaves no dangling join-point in the
191:            // virtual machine
192:            public void test4_Teardown() throws Exception {
193:                try {
194:                    System.getProperties().remove("ch.ethz.prose.EXManager");
195:                    System.getProperties().remove("ch.ethz.prose.ESSystem.1");
196:
197:                    // start the extension
198:                    ProseSystem.startup();
199:                    assertNotNull(ProseSystem.getAspectManager());
200:                    assertNotNull(ProseSystem.getTestAspectManager());
201:
202:                    // insert a few extensions
203:                    Aspect x1 = new DefaultAspect() {
204:                    };
205:                    Aspect x2 = new DefaultAspect() {
206:                    };
207:
208:                    ProseSystem.getAspectManager().insert(x1);
209:                    ProseSystem.getAspectManager().insert(x2);
210:
211:                    ProseSystem.getTestAspectManager().insert(x1);
212:                    ProseSystem.getTestAspectManager().insert(x2);
213:
214:                    // teardown the system
215:                    AspectManager currentMgr = ProseSystem.getAspectManager();
216:                    AspectManager testMgr = ProseSystem.getTestAspectManager();
217:                    ProseSystem.teardown();
218:
219:                    // assert that all extensions where withdrawn
220:                    assertTrue("empty extension list in currentMgr", currentMgr
221:                            .getAllAspects().isEmpty());
222:                    assertTrue("empty extension list in testMgr", testMgr
223:                            .getAllAspects().isEmpty());
224:                } catch (Exception e) {
225:                    e.printStackTrace();
226:                    throw e;
227:                }
228:
229:            }
230:
231:        }
232:
233:        //======================================================================
234:        //
235:        // $Log: ExtensionSystemTest.java,v $
236:        // Revision 1.2  2004/05/12 17:26:50  anicoara
237:        // Adapt Junit tests to 3.8.1 version and the new package structure
238:        //
239:        // Revision 1.1.1.1  2003/07/02 15:30:42  apopovic
240:        // Imported from ETH Zurich
241:        //
242:        // Revision 1.2  2003/06/10 12:59:48  popovici
243:        // startup and teardown idempotence used to produce a startup during the teardown;
244:        // flag is now set *after* the teardown has successfully completed
245:        //
246:        // Revision 1.1  2003/05/05 14:02:30  popovici
247:        // renaming from runes to prose
248:        //
249:        // Revision 1.10  2003/04/17 15:15:01  popovici
250:        // Extension->Aspect renaming
251:        //
252:        // Revision 1.9  2003/04/17 12:49:38  popovici
253:        // Refactoring of the crosscut package
254:        //  ExceptionCut renamed to ThrowCut
255:        //  McutSignature is now SignaturePattern
256:        //
257:        // Revision 1.8  2003/04/17 08:46:43  popovici
258:        // Important functionality additions
259:        //  - Cflow specializers
260:        //  - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
261:        //  - Transactional capabilities
262:        //  - Total refactoring of Specializer evaluation, which permits fine-grained distinction
263:        //    between static and dynamic specializers.
264:        //  - Functionality pulled up in abstract classes
265:        //  - Uniformization of advice methods patterns and names
266:        //
267:        // Revision 1.7  2003/03/04 18:36:09  popovici
268:        // Organization of imprts
269:        //
270:        // Revision 1.6  2003/03/04 11:25:56  popovici
271:        // Important refactorization step (march):
272:        // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
273:        // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
274:        //   structures
275:        //
276:        // Revision 1.5  2003/02/17 13:52:52  popovici
277:        // Bug fix: the 'allJoinpoints() methods used to miss
278:        //
279:        // Revision 1.4  2003/01/17 14:44:00  pschoch
280:        // Introduction of 'query' methods in the AspectManager and its
281:        // subclasses.  The result set is given back in form of surrogates; 4 new tests added to ExtensionManagerTest
282:        // ExtensionSystemTest
283:        //
284:        // Revision 1.3  2002/11/26 17:15:29  pschoch
285:        // RootComponent now added (replaces RootComponent now added (replaces old ProseSystem)
286:        // ProseSystem now owns and starts the Aspect interface.
287:        // ProseSystem now containes  a 'test' AspectManager
288:        // AspectManager now owns the JoinPointManager.
289:        // ExtensionManger can be 'connected' to the JVM, or disconnected. The
290:        // JoinPointManager of a connected Ext.Mgr enables joinpoints; the
291:        // JoinPointManger of a disconnected Ext.Mgr never enables join-points
292:        // Documentation updated accordingly.
293:        //
294:        // Revision 1.2  2002/02/05 11:20:11  smarkwal
295:        // modifications to test JVMAI-based implementation
296:        //
297:        // Revision 1.1.1.1  2001/11/29 18:13:30  popovici
298:        // Sources from runes
299:        //
300:        // Revision 1.1.2.6  2001/06/06 10:05:22  popovici
301:        // Methods 'registerListener' and 'unregisterListener' for classLoadListeners
302:        // added.
303:        //
304:        // Revision 1.1.2.5  2001/03/22 17:29:26  popovici
305:        // ExampleExtensionSystem changed to contain the 'suspend/resumeNotificationListener' methods
306:        //
307:        // Revision 1.1.2.4  2001/02/22 16:54:49  popovici
308:        // ProseSystem.setup replaced with startup; teardown introduced
309:        // - bug fixed in properties defintion
310:        // - test 'testTeardown' introduced
311:        //
312:        // Revision 1.1.2.3  2001/02/07 12:04:33  popovici
313:        // ProseSystem test adapted to the new 'startup/teardown' framework.
314:        //
315:        // Revision 1.1.2.2  2000/11/21 14:40:31  groos
316:        // adapted to the modifications of JoinPointManager:
317:        // new abstract methods createFieldAccessRequest(Field f) and createFieldModificationRequest(Field f) must be declared, too.
318:        //
319:        // Revision 1.1.2.1  2000/10/24 17:59:53  popovici
320:        // Initial Revision
321:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.