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


01:        /**************************************************************************************
02:         * Copyright (c) Jonas Bon?r, Alexandre Vasseur. All rights reserved.                 *
03:         * http://aspectwerkz.codehaus.org                                                    *
04:         * ---------------------------------------------------------------------------------- *
05:         * The software in this package is published under the terms of the LGPL license      *
06:         * a copy of which has been included with this distribution in the license.txt file.  *
07:         **************************************************************************************/package test.aopc;
08:
09:        import junit.framework.TestCase;
10:
11:        import java.net.URL;
12:        import java.net.URLClassLoader;
13:
14:        /**
15:         *
16:         * TODO rewrite test.aopc.* with ASM or using an already builded jar with the small appp deployed
17:         * several time in difft CL to test system defs and namespaces.
18:         *
19:         * Note: does not work behing WeavingCL. Use a real online mode <p/>
20:         * java -Xrunaspectwerkz -Xdebug -Xbootclasspath/a:lib\aspectwerkz-core-1.0.jar ...
21:         * <p/>
22:         * The CallablePrototype class is renamed and defined as a deployed application class in a child classloader
23:         * with its own META-INF/aop.xml file.
24:         *
25:         * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
26:         */
27:        public class AspectSystemTest extends TestCase {
28:            public void testDoubleHierarchyMethodExecution() {
29:                // VM system classpath level classes
30:                Callable cvm = new CallablePrototype();
31:                cvm.methodAround();
32:                cvm.debug();
33:                assertEquals("methodAround ", cvm.getLogString());
34:
35:                // appserver like classloader, with its own aop.xml file
36:                // the aop.xml file contains one aspect in the VM system classpath
37:                ClassLoader myCL = new URLClassLoader(new URL[] { ClassCreator
38:                        .getPathFor(Callable.class
39:                                .getResource("META-INF/aop.xml")) },
40:                        ClassLoader.getSystemClassLoader());
41:                Callable cas = (Callable) ClassCreator.createInstance(
42:                        "test.aopc.CallableAppServer", CallablePrototype.class,
43:                        myCL);
44:                cas.methodAround();
45:                cas.debug();
46:                assertEquals("system/asCL/test.aopc.BaseAspect.beforeAround "
47:                        + "methodAround "
48:                        + "system/asCL/test.aopc.BaseAspect.afterAround ", cas
49:                        .getLogString());
50:
51:                // deployed app A
52:                // the aop.xml file is REusing VM system classpath aspect and is defining one of its own as well, with 2 systems
53:                // we are defining the aspect on the fly in an intermediate CL without aop.xml
54:                ClassLoader mySubCLAAspect = new URLClassLoader(new URL[] {},
55:                        myCL);
56:                ClassCreator.createClass("test.aopc.a.Aspect",
57:                        BaseAspect.class, mySubCLAAspect);
58:                ClassLoader mySubCLA = new URLClassLoader(
59:                        new URL[] { ClassCreator.getPathFor(Callable.class
60:                                .getResource("a/META-INF/aop.xml")) },
61:                        mySubCLAAspect);
62:                //ClassCreator.createClass("test.aopc.a.Aspect", BaseAspect.class, mySubCLA);
63:                Callable ca = (Callable) ClassCreator
64:                        .createInstance("test.aopc.a.Callee",
65:                                CallablePrototype.class, mySubCLA);
66:                ca.methodAround();
67:                ca.debug();
68:                assertEquals("system/asCL/test.aopc.BaseAspect.beforeAround "
69:                        + "system/subCL/a1/subCLAspect.beforeAround "
70:                        + "system/subCL/a2/subCLAspect.beforeAround "
71:                        + "methodAround "
72:                        + "system/subCL/a2/subCLAspect.afterAround "
73:                        + "system/subCL/a1/subCLAspect.afterAround "
74:                        + "system/asCL/test.aopc.BaseAspect.afterAround ", ca
75:                        .getLogString());
76:
77:                // deployed app B
78:                // no aop.xml
79:                ClassLoader mySubCLB = new URLClassLoader(new URL[] {}, myCL);
80:                Callable cb = (Callable) ClassCreator
81:                        .createInstance("test.aopc.b.Callee",
82:                                CallablePrototype.class, mySubCLB);
83:                cb.methodAround();
84:                cb.debug();
85:                assertEquals("system/asCL/test.aopc.BaseAspect.beforeAround "
86:                        + "methodAround "
87:                        + "system/asCL/test.aopc.BaseAspect.afterAround ", cb
88:                        .getLogString());
89:            }
90:
91:            // ------------------------------------------------
92:            public static void main(String[] args) {
93:                junit.textui.TestRunner.run(suite());
94:            }
95:
96:            public static junit.framework.Test suite() {
97:                return new junit.framework.TestSuite(AspectSystemTest.class);
98:            }
99:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.