Source Code Cross Referenced for LineNumberTest.java in  » Aspect-oriented » aspectwerkz-2.0 » test » 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 
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;
008:
009:        import junit.framework.TestCase;
010:        import org.codehaus.aspectwerkz.annotation.Before;
011:        import org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor;
012:        import org.codehaus.aspectwerkz.transform.inlining.EmittedJoinPoint;
013:
014:        import java.io.ByteArrayOutputStream;
015:        import java.io.InputStream;
016:
017:        /**
018:         * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
019:         */
020:        public class LineNumberTest extends TestCase {
021:
022:            int m_field;
023:
024:            int s_field;
025:
026:            public LineNumberTest() {//ctor exe
027:                m_field = 1;//field set
028:                int mget = m_field;//field get
029:                s_field = 2;//field set
030:                int sget = s_field;//field get
031:            }
032:
033:            public void exec() {//method exe
034:                called();//method call
035:            }
036:
037:            public void called() {//method exe
038:                LineNumberTest t = new LineNumberTest();//ctor call
039:                try {
040:                    throw new RuntimeException("fake");//ctor call
041:                } catch (RuntimeException e) {//handler
042:                    ;
043:                }
044:            }
045:
046:            public void testLineNumbers() throws Throwable {
047:                AspectWerkzPreProcessor aw = new AspectWerkzPreProcessor();
048:                aw.initialize();
049:                String name = LineNumberTest.class.getName().replace('/', '.');
050:                InputStream in = LineNumberTest.class.getClassLoader()
051:                        .getResourceAsStream(name.replace('.', '/') + ".class");
052:                ByteArrayOutputStream bos = new ByteArrayOutputStream();
053:                byte[] buffer = new byte[1024];
054:                while (in.available() > 0) {
055:                    int length = in.read(buffer);
056:                    if (length == -1) {
057:                        break;
058:                    }
059:                    bos.write(buffer, 0, length);
060:                }
061:                in.close();
062:
063:                byte[] inBytes = bos.toByteArray();
064:                AspectWerkzPreProcessor.Output output = aw
065:                        .preProcessWithOutput(name, inBytes,
066:                                LineNumberTest.class.getClassLoader());
067:
068:                // we have 11 joinpoints
069:                assertEquals(11, output.emittedJoinPoints.length);
070:
071:                //Note: this test depends upon visitor order
072:                // adapt the output when needed
073:                StringBuffer emitted = new StringBuffer();
074:                for (int i = 0; i < output.emittedJoinPoints.length; i++) {
075:                    EmittedJoinPoint emittedJoinPoint = output.emittedJoinPoints[i];
076:                    //System.out.println(emittedJoinPoint);
077:                    emitted.append(emittedJoinPoint.toString());
078:                    emitted.append("\n");
079:                }
080:                String allJps = "ConstructorExecution , caller test/LineNumberTest.<init>()V , callee test/LineNumberTest.<init> ()V , line 0\n"
081:                        + "FieldSet , caller test/LineNumberTest.<init>()V , callee test/LineNumberTest.m_field I , line 28\n"
082:                        + "FieldGet , caller test/LineNumberTest.<init>()V , callee test/LineNumberTest.m_field I , line 29\n"
083:                        + "FieldSet , caller test/LineNumberTest.<init>()V , callee test/LineNumberTest.s_field I , line 30\n"
084:                        + "FieldGet , caller test/LineNumberTest.<init>()V , callee test/LineNumberTest.s_field I , line 31\n"
085:                        + "MethodExecution , caller test/LineNumberTest.exec()V , callee test/LineNumberTest.exec ()V , line 0\n"
086:                        + "MethodCall , caller test/LineNumberTest.exec()V , callee test/LineNumberTest.called ()V , line 35\n"
087:                        + "MethodExecution , caller test/LineNumberTest.called()V , callee test/LineNumberTest.called ()V , line 0\n"
088:                        + "ConstructorCall , caller test/LineNumberTest.called()V , callee test/LineNumberTest.<init> ()V , line 39\n"
089:                        + "ConstructorCall , caller test/LineNumberTest.called()V , callee java/lang/RuntimeException.<init> (Ljava/lang/String;)V , line 41\n"
090:                        + "Handler , caller test/LineNumberTest.called()V , callee java/lang/RuntimeException. Ljava/lang/RuntimeException; , line 42\n"
091:                        + "";
092:                assertEquals(allJps, emitted.toString());
093:            }
094:
095:            public static void main(String[] args) {
096:                junit.textui.TestRunner.run(suite());
097:            }
098:
099:            public static junit.framework.Test suite() {
100:                return new junit.framework.TestSuite(LineNumberTest.class);
101:            }
102:
103:            public static class Aspect {
104:
105:                @Before("within(test.LineNumberTest) && !withincode(* test*(..)) && !withincode(* main(..)) && !withincode(* suite())")
106:                void before() {
107:                }
108:            }
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.