Source Code Cross Referenced for InterceptTest.java in  » Aspect-oriented » aspectwerkz-2.0 » test » intercept » get » 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 » Aspect oriented » aspectwerkz 2.0 » test.intercept.get 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************************
002:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
003:         * http://aspectwerkz.codehaus.org                                                    *
004:         * ---------------------------------------------------------------------------------- *
005:         * The software in this package is published under the terms of the LGPL license      *
006:         * a copy of which has been included with this distribution in the license.txt file.  *
007:         **************************************************************************************/package test.intercept.get;
008:
009:        import junit.framework.TestCase;
010:        import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
011:        import org.codehaus.aspectwerkz.intercept.BeforeAdvice;
012:        import org.codehaus.aspectwerkz.intercept.Advisable;
013:        import org.codehaus.aspectwerkz.intercept.AroundAdvice;
014:        import org.codehaus.aspectwerkz.intercept.AfterAdvice;
015:
016:        /**
017:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
018:         */
019:        public class InterceptTest extends TestCase {
020:            private static String LOG = "";
021:
022:            public static void log(String msg) {
023:                LOG += msg;
024:            }
025:
026:            public void testIsAdvisable() {
027:                assertTrue(this  instanceof  Advisable);
028:            }
029:
030:            public void testAddAround() {
031:                LOG = "";
032:                int tmp1 = adviseWithAround;
033:                assertEquals("", LOG);
034:
035:                ((Advisable) this )
036:                        .aw_addAdvice(
037:                                "get(* test.intercept.get.InterceptTest.adviseWithAround)",
038:                                new AroundAdvice() {
039:                                    public Object invoke(JoinPoint jp)
040:                                            throws Throwable {
041:                                        InterceptTest.log("around1_pre ");
042:                                        Object result = jp.proceed();
043:                                        InterceptTest.log("around1_post ");
044:                                        return result;
045:                                    }
046:                                });
047:
048:                LOG = "";
049:                int tmp2 = adviseWithAround;
050:                assertEquals("around1_pre around1_post ", LOG);
051:            }
052:
053:            public void testAddAndRemoveAround() {
054:                LOG = "";
055:                String tmp1 = adviseWithAround2;
056:                assertEquals("", LOG);
057:
058:                ((Advisable) this )
059:                        .aw_addAdvice(
060:                                "get(* test.intercept.get.InterceptTest.adviseWithAround2)",
061:                                new AroundAdvice() {
062:                                    public Object invoke(JoinPoint jp)
063:                                            throws Throwable {
064:                                        InterceptTest.log("around1_pre ");
065:                                        Object result = jp.proceed();
066:                                        InterceptTest.log("around1_post ");
067:                                        return result;
068:                                    }
069:                                });
070:
071:                LOG = "";
072:                String tmp2 = adviseWithAround2;
073:                assertEquals("around1_pre around1_post ", LOG);
074:
075:                ((Advisable) this )
076:                        .aw_removeAdvice(
077:                                "get(* test.intercept.get.InterceptTest.adviseWithAround2)",
078:                                AroundAdvice.class);
079:
080:                LOG = "";
081:                String tmp3 = adviseWithAround2;
082:                assertEquals("", LOG);
083:            }
084:
085:            public void testAddAroundStack() {
086:                LOG = "";
087:                int tmp1 = adviseWithAroundStack;
088:                assertEquals("", LOG);
089:
090:                ((Advisable) this )
091:                        .aw_addAdvice(
092:                                "get(* test.intercept.get.InterceptTest.adviseWithAroundStack)",
093:                                new AroundAdvice() {
094:                                    public Object invoke(JoinPoint jp)
095:                                            throws Throwable {
096:                                        InterceptTest.log("around2_pre ");
097:                                        Object result = jp.proceed();
098:                                        InterceptTest.log("around2_post ");
099:                                        return result;
100:                                    }
101:                                });
102:
103:                LOG = "";
104:                int tmp2 = adviseWithAroundStack;
105:                assertEquals("around2_pre around2_post ", LOG);
106:
107:                ((Advisable) this )
108:                        .aw_addAdvice(
109:                                "get(* test.intercept.get.InterceptTest.adviseWithAroundStack)",
110:                                new AroundAdvice() {
111:                                    public Object invoke(JoinPoint jp)
112:                                            throws Throwable {
113:                                        InterceptTest.log("around3_pre ");
114:                                        Object result = jp.proceed();
115:                                        InterceptTest.log("around3_post ");
116:                                        return result;
117:                                    }
118:                                });
119:
120:                LOG = "";
121:                int tmp3 = adviseWithAroundStack;
122:                assertEquals(
123:                        "around2_pre around3_pre around3_post around2_post ",
124:                        LOG);
125:            }
126:
127:            public void testAddBefore() {
128:                LOG = "";
129:                Object tmp1 = adviseWithBefore;
130:                assertEquals("", LOG);
131:
132:                ((Advisable) this )
133:                        .aw_addAdvice(
134:                                "get(* test.intercept.get.InterceptTest.adviseWithBefore)",
135:                                new BeforeAdvice() {
136:                                    public void invoke(JoinPoint jp)
137:                                            throws Throwable {
138:                                        InterceptTest.log("before ");
139:                                    }
140:                                });
141:
142:                LOG = "";
143:                Object tmp2 = adviseWithBefore;
144:                assertEquals("before ", LOG);
145:            }
146:
147:            public void testAddAfter() {
148:                LOG = "";
149:                boolean tmp1 = adviseWithAfter;
150:                assertEquals("", LOG);
151:
152:                ((Advisable) this )
153:                        .aw_addAdvice(
154:                                "get(* test.intercept.get.InterceptTest.adviseWithAfter)",
155:                                new AfterAdvice() {
156:                                    public void invoke(JoinPoint jp)
157:                                            throws Throwable {
158:                                        InterceptTest.log("afterFinally ");
159:                                    }
160:                                });
161:
162:                LOG = "";
163:                boolean tmp2 = adviseWithAfter;
164:                assertEquals("afterFinally ", LOG);
165:            }
166:
167:            public static void main(String[] args) {
168:                junit.textui.TestRunner.run(suite());
169:            }
170:
171:            public static junit.framework.Test suite() {
172:                return new junit.framework.TestSuite(InterceptTest.class);
173:            }
174:
175:            int adviseWithAround = -1;
176:
177:            String adviseWithAround2 = "lala";
178:
179:            int adviseWithAroundStack = 135;
180:
181:            Object adviseWithBefore = new Boolean(true);
182:
183:            boolean adviseWithAfter = false;
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.