Source Code Cross Referenced for StackTraceElementTest.java in  » Apache-Harmony-Java-SE » java-package » java » lang » 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 » Apache Harmony Java SE » java package » java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Dmitry B. Yershov
020:         * @version $Revision$
021:         */package java.lang;
022:
023:        import junit.framework.TestCase;
024:
025:        public class StackTraceElementTest extends TestCase {
026:
027:            /**
028:             * Constructor under test StackTraceElement(String, int, String,
029:             * String, boolean)
030:             */
031:            public void testStackTraceElement() {
032:                String[] fileName = new String[] { null, "", "file" };
033:                int[] lineNumber = new int[] { -10, 0, 10 };
034:                String declaringClass = "class";
035:                String methodName = "method";
036:                try {
037:                    for (int i = 0; i < 3; i++)
038:                        for (int j = 0; j < 3; j++)
039:                            new StackTraceElement(declaringClass, methodName,
040:                                    fileName[i], lineNumber[j]);
041:                } catch (Throwable th) {
042:                    fail("Constructor should work with all types of data");
043:                }
044:            }
045:
046:            /**
047:             * Method under test boolean Equals(Object)
048:             */
049:            public void testEquals() {
050:                StackTraceElement ste = new StackTraceElement("class",
051:                        "method", "file", 2);
052:                StackTraceElement ste1 = new StackTraceElement("class",
053:                        "method", "file", -2);
054:                StackTraceElement ste2 = new StackTraceElement("class1",
055:                        "method", "file", 2);
056:                StackTraceElement ste3 = new StackTraceElement("class",
057:                        "method1", "file", 2);
058:                StackTraceElement ste4 = new StackTraceElement("class",
059:                        "method", "file1", 2);
060:                StackTraceElement ste5 = new StackTraceElement("class",
061:                        "method", "file", 2);
062:                assertFalse("Assert 0: objects should differ", ste
063:                        .equals(new Object()));
064:                assertFalse("Assert 1: objects should differ", ste.equals(ste1));
065:                assertFalse("Assert 2: objects should differ", ste.equals(ste2));
066:                assertFalse("Assert 3: objects should differ", ste.equals(ste3));
067:                assertFalse("Assert 4: objects should differ", ste.equals(ste4));
068:                assertTrue("Assert 5: objects should equal", ste.equals(ste5));
069:            }
070:
071:            /**
072:             * Method under test String getClassName()
073:             */
074:            public void testGetClassName() {
075:                StackTraceElement ste = new StackTraceElement("class",
076:                        "method", "file", 1);
077:                assertEquals("incorrect class name", "class", ste
078:                        .getClassName());
079:            }
080:
081:            /**
082:             * Method under test String getFileName()
083:             */
084:            public void testGetFileName() {
085:                StackTraceElement ste = new StackTraceElement("class",
086:                        "method", "file", 1);
087:                assertEquals("incorrect file name", "file", ste.getFileName());
088:            }
089:
090:            /**
091:             * Method under test int getLineNumber()
092:             */
093:            public void testGetLineNumber() {
094:                StackTraceElement ste = new StackTraceElement("class",
095:                        "method", "file", 1);
096:                assertEquals("incorrect line number", 1, ste.getLineNumber());
097:            }
098:
099:            /**
100:             * Method under test String getMethodName()
101:             */
102:            public void testGetMethodName() {
103:                StackTraceElement ste = new StackTraceElement("class",
104:                        "method", "file", 1);
105:                assertEquals("incorrect file name", "method", ste
106:                        .getMethodName());
107:            }
108:
109:            /**
110:             * Method under test int hashCode()
111:             */
112:            public void testHashCode() {
113:                StackTraceElement ste = new StackTraceElement("class",
114:                        "method", "file", 1);
115:                StackTraceElement ste1 = new StackTraceElement("class",
116:                        "method", "file", 1);
117:                assertEquals("hash codes should equal", ste.hashCode(), ste1
118:                        .hashCode());
119:            }
120:
121:            /**
122:             * Method under test boolean isNativeMethod()
123:             * when file name is null
124:             */
125:            public void testIsNativeMethod() {
126:                StackTraceElement ste = new StackTraceElement("class",
127:                        "method", null, -2);
128:                assertTrue("method should be native", ste.isNativeMethod());
129:                ste = new StackTraceElement("class", "method", "file", 1);
130:                assertFalse("method should not be native", ste.isNativeMethod());
131:            }
132:
133:            /**
134:             * Method under test boolean isNativeMethod()
135:             * when file name is not null
136:             */
137:            public void testIsNativeMethod_FileNotNull() {
138:                StackTraceElement ste = new StackTraceElement("class",
139:                        "method", "file", -2);
140:                assertTrue("method should be native", ste.isNativeMethod());
141:                ste = new StackTraceElement("class", "method", "file", 1);
142:                assertFalse("method should not be native", ste.isNativeMethod());
143:            }
144:
145:            /**
146:             * Method under test String toString()
147:             */
148:            public void testToString() {
149:                StackTraceElement ste = new StackTraceElement("class",
150:                        "method", "file", 1);
151:                assertEquals("Assert 0: incorrect output",
152:                        "class.method(file:1)", ste.toString());
153:                ste = new StackTraceElement("class", "method", "file", -1);
154:                assertEquals("Assert 0: incorrect output",
155:                        "class.method(file)", ste.toString());
156:                ste = new StackTraceElement("class", "method", null, 1);
157:                assertEquals("Assert 0: incorrect output",
158:                        "class.method(Unknown Source)", ste.toString());
159:                ste = new StackTraceElement("class", "method", null, -1);
160:                assertEquals("Assert 0: incorrect output",
161:                        "class.method(Unknown Source)", ste.toString());
162:                ste = new StackTraceElement("class", "method", null, -2);
163:                assertEquals("Assert 0: incorrect output",
164:                        "class.method(Native Method)", ste.toString());
165:            }
166:
167:            /**
168:             * Method under test String toString()
169:             * when file name is null and line number is -2
170:             */
171:            public void testToString_FileNotNullLineMinus2() {
172:                StackTraceElement ste = new StackTraceElement("class",
173:                        "method", "file", -2);
174:                assertEquals("incorrect output", "class.method(file)", ste
175:                        .toString());
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.