Source Code Cross Referenced for ExceptionCutUserDefinedTest.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: ExceptionCutUserDefinedTest.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.crosscut;
008:
009:        //used packages
010:        import java.io.IOException;
011:
012:        import junit.framework.*;
013:        import ch.ethz.prose.DefaultAspect;
014:        import ch.ethz.prose.ProseSystem;
015:        import ch.ethz.prose.filter.PointCutter;
016:
017:        /**
018:         * JUnit testcase for class XXX.
019:         *
020:         * @version	$Revision: 1.3 $
021:         * @author	Andrei Popovici
022:         */
023:        public class ExceptionCutUserDefinedTest extends TestCase {
024:
025:            public static class MyRuntimeException extends RuntimeException {
026:            };
027:
028:            public static class MyException extends IOException {
029:            };
030:
031:            public static class MyError extends Error {
032:            };
033:
034:            // Jikes RVM doesn't allow to watch exceptions which are in the boot image.
035:            // And the most common ones are...
036:            public static class MySubRuntimeException extends
037:                    MyRuntimeException {
038:            };
039:
040:            public static class MySubException extends MyException {
041:            };
042:
043:            public static class MySubError extends MyError {
044:            };
045:
046:            public static class MyNullPointerException extends
047:                    NullPointerException {
048:            };
049:
050:            public static class TestExtension extends DefaultAspect {
051:                int c1cnt = 0;
052:                int c2cnt = 0;
053:                int c3cnt = 0;
054:                int c4cnt = 0;
055:
056:                public Crosscut c1 = new ThrowCut() {
057:                    public void THROW_ARGS(ANY x) {
058:                        c1cnt++;
059:                    }
060:
061:                    protected PointCutter pointCutter() {
062:                        return null;
063:                    }
064:                };
065:
066:                public Crosscut c2 = new ThrowCut() {
067:                    public void THROW_ARGS(RuntimeException e) {
068:                        c2cnt++;
069:                    }
070:
071:                    protected PointCutter pointCutter() {
072:                        return null;
073:                    }
074:
075:                };
076:
077:                public Crosscut c3 = new ThrowCut() {
078:                    public void THROW_ARGS(IOException e) {
079:                        c3cnt++;
080:                    }
081:
082:                    protected PointCutter pointCutter() {
083:                        return null;
084:                    }
085:
086:                };
087:
088:                public Crosscut c4 = new ThrowCut() {
089:                    public void THROW_ARGS(Throwable e) {
090:                        c4cnt++;
091:                    }
092:
093:                    protected PointCutter pointCutter() {
094:                        return null;
095:                    }
096:
097:                };
098:            }
099:
100:            /**
101:             * Construct test with given name.
102:             * @param name test name
103:             */
104:            public ExceptionCutUserDefinedTest(String name) {
105:                super (name);
106:            }
107:
108:            /**
109:             * Set up fixture.
110:             */
111:            protected void setUp() throws Exception {
112:                ProseSystem.startup();
113:            }
114:
115:            protected void tearDown() throws Exception {
116:                ProseSystem.teardown();
117:            }
118:
119:            public void testCustomExtensionCut() throws Exception {
120:                // FIXME: w/o the follwing line problems: classes loaded dynamically are not returned by
121:                Class c = MyRuntimeException.class;
122:                c = MyException.class;
123:                c = MyError.class;
124:                c = MySubRuntimeException.class;
125:                c = MySubException.class;
126:                c = MySubError.class;
127:                c = MyNullPointerException.class;
128:                TestExtension x = new TestExtension();
129:                ProseSystem.getAspectManager().insert(x);
130:
131:                try {
132:                    throw new MySubRuntimeException();
133:                } catch (MySubRuntimeException e) {
134:                } // cnt1,4,2
135:                try {
136:                    throw new MyRuntimeException();
137:                } catch (MyRuntimeException e) {
138:                } // cnt1,4,2
139:                try {
140:                    throw new MyNullPointerException();
141:                } catch (MyNullPointerException e) {
142:                } // cnt1,4,2
143:                try {
144:                    throw new MyException();
145:                } catch (MyException e) {
146:                } // cnt1,4,3
147:                try {
148:                    throw new MySubException();
149:                } catch (MySubException e) {
150:                } // cnt1,4,3
151:                try {
152:                    throw new MyError();
153:                } catch (MyError e) {
154:                } // cnt1,4
155:                try {
156:                    throw new MySubError();
157:                } catch (MySubError e) {
158:                } // cnt1,4
159:
160:                ProseSystem.getAspectManager().withdraw(x);
161:
162:                assertEquals("exception captured by ANY:", 7, x.c1cnt);
163:                assertEquals("exception captured by Runtime:", 3, x.c2cnt);
164:                assertEquals("exception captured by IO:", 2, x.c3cnt);
165:                assertEquals("exception captured by Throwable:", 7, x.c4cnt);
166:            }
167:
168:            /**
169:             * Test suite.
170:             * @return test instance
171:             */
172:            public static Test suite() {
173:                return new TestSuite(ExceptionCutUserDefinedTest.class);
174:            }
175:        }
176:
177:        //======================================================================
178:        //
179:        // $Log: ExceptionCutUserDefinedTest.java,v $
180:        // Revision 1.3  2004/05/12 17:26:51  anicoara
181:        // Adapt Junit tests to 3.8.1 version and the new package structure
182:        //
183:        // Revision 1.1.1.1  2003/07/02 15:30:43  apopovic
184:        // Imported from ETH Zurich
185:        //
186:        // Revision 1.1  2003/05/05 14:03:29  popovici
187:        // renaming from runes to prose
188:        //
189:        // Revision 1.4  2003/04/27 13:08:55  popovici
190:        // Specializers renamed to PointCutter
191:        //
192:        // Revision 1.3  2003/04/17 15:15:17  popovici
193:        // Extension->Aspect renaming
194:        //
195:        // Revision 1.2  2003/04/17 12:49:43  popovici
196:        // Refactoring of the crosscut package
197:        //  ExceptionCut renamed to ThrowCut
198:        //  McutSignature is now SignaturePattern
199:        //
200:        // Revision 1.1  2003/04/17 08:46:47  popovici
201:        // Important functionality additions
202:        //  - Cflow specializers
203:        //  - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
204:        //  - Transactional capabilities
205:        //  - Total refactoring of Specializer evaluation, which permits fine-grained distinction
206:        //    between static and dynamic specializers.
207:        //  - Functionality pulled up in abstract classes
208:        //  - Uniformization of advice methods patterns and names
209:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.