Source Code Cross Referenced for Ctor5Test.java in  » Apache-Harmony-Java-SE » java-package » java » lang » reflect » 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.reflect 
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:        package java.lang.reflect;
019:
020:        import org.apache.harmony.lang.AnnotatedElementTestFrame.MissingClassValAntn;
021:        import org.apache.harmony.lang.AnnotatedElementTestFrame.MissingTypeAntn;
022:        import org.apache.harmony.lang.AnnotatedElementTestFrame.TagAntn;
023:        import org.apache.harmony.lang.AnnotatedElementTestFrame.ValAntn;
024:
025:        /**
026:         * @author Alexey V. Varlamov
027:         * @version $Revision$
028:         */
029:        public class Ctor5Test extends Method5Test {
030:
031:            public static void main(String[] args) {
032:                junit.textui.TestRunner.run(Ctor5Test.class);
033:            }
034:
035:            protected @Override
036:            AnnotatedElement getElement1() throws Throwable {
037:                return AnnotatedCtor.class.getConstructor();
038:            }
039:
040:            protected @Override
041:            AnnotatedElement getElement2() throws Throwable {
042:                return AnnotatedCtor.class.getConstructor(Object.class);
043:            }
044:
045:            protected @Override
046:            AnnotatedElement getElement3() throws Throwable {
047:                return AnnotatedCtor.class.getConstructor(String.class);
048:            }
049:
050:            /**
051:             * Provides an instance to be tested. The instance must be annotated
052:             * by the notfound.MissingAntn.
053:             */
054:            protected @Override
055:            AnnotatedElement getElement4() throws Throwable {
056:                return AnnotatedCtor.class.getConstructor(int.class);
057:            }
058:
059:            /**
060:             * Provides an instance to be tested. The instance must be annotated
061:             * by the MissingClassValAntn.
062:             */
063:            protected @Override
064:            AnnotatedElement getElement5() throws Throwable {
065:                return AnnotatedCtor.class.getConstructor(long.class);
066:            }
067:
068:            /**
069:             * Provides an instance to be tested. The instance must be annotated
070:             * by the MissingTypeAntn.
071:             */
072:            protected @Override
073:            AnnotatedElement getElement6() throws Throwable {
074:                return AnnotatedCtor.class.getConstructor(char.class);
075:            }
076:
077:            @Override
078:            protected Member getParamElement1() throws Throwable {
079:                return AnnotatedParamCtor.class.getConstructor();
080:            }
081:
082:            @Override
083:            protected Member getParamElement2() throws Throwable {
084:                return AnnotatedParamCtor.class.getConstructor(Object.class,
085:                        Class.class, boolean.class);
086:            }
087:
088:            @Override
089:            protected Member getParamElement3() throws Throwable {
090:                return AnnotatedParamCtor.class.getConstructor(String.class,
091:                        int.class);
092:            }
093:
094:            static class A {
095:                private Object obj;
096:
097:                class InA {
098:                    Object o = obj;
099:                }
100:            }
101:
102:            enum E {
103:                E1, E2, E3
104:            }
105:
106:            static class B {
107:                public B() {
108:                }
109:
110:                public B(Object o) {
111:                }
112:
113:                public B(Object o1, int... i) {
114:                }
115:
116:                public B(Object[] o) {
117:                }
118:            }
119:
120:            /**
121:             * isSynthetic() should return true if and only if
122:             * the target c-tor does not appear in the source code. 
123:             */
124:            public void testIsSynthetic() throws Exception {
125:                assertFalse("case1.1: ordinary ctor", AnnotatedCtor.class
126:                        .getConstructor().isSynthetic());
127:                assertFalse("case1.2: implicit default c-tor", A.class
128:                        .getDeclaredConstructor().isSynthetic());
129:
130:                Constructor[] cs = B.class.getConstructors();
131:                for (Constructor<?> c : cs) {
132:                    assertFalse("case2: " + c, c.isSynthetic());
133:                }
134:                // XXX how to force synthetic c-tor ?
135:            }
136:
137:            /**
138:             * isVarArgs() should return true if and only if
139:             * the target method is declared with varargs. 
140:             */
141:            public void testIsVarargs() throws Exception {
142:                assertFalse("case1: ordinary c-tor", AnnotatedCtor.class
143:                        .getConstructor().isVarArgs());
144:
145:                assertTrue("case2: varargs c-tor", B.class.getConstructor(
146:                        Object.class, int[].class).isVarArgs());
147:
148:                assertFalse("case3: ordinary c-tor", B.class.getConstructor(
149:                        Object[].class).isVarArgs());
150:            }
151:
152:            static abstract strictfp class C {
153:                protected <T extends Throwable & Comparable<Throwable>> C(
154:                        T num, OneParamType<? super  T> l) throws T, Error {
155:                }
156:            }
157:
158:            /**
159:             * toGenericString() should return a string exactly matching
160:             * the API specification.
161:             */
162:            public void testToGenericString() throws Exception {
163:                String s = C.class.getDeclaredConstructor(Throwable.class,
164:                        OneParamType.class).toGenericString();
165:                System.out.println(s);
166:                assertEquals(
167:                // Should constructor type parameter be followed by a type bound? It is unspecified.
168:                        // The known reference implementation doesn't do it as well:
169:                        //"protected <T extends java.lang.Throwable & "
170:                        //+ "java.lang.Comparable<java.lang.Throwable>>"
171:                        "protected strictfp <T>"
172:                                + " java.lang.reflect.Ctor5Test$C(T,java.lang.reflect.OneParamType<? super T>)"
173:                                + " throws T,java.lang.Error", s);
174:            }
175:
176:            /**
177:             * toGenericString() should return a string exactly matching
178:             * the API specification.
179:             */
180:            public void testToGenericString2() throws Exception {
181:                String s = B.class.getConstructor(Object.class, int[].class)
182:                        .toGenericString();
183:                System.out.println(s);
184:                assertEquals("public java.lang.reflect.Ctor5Test$B("
185:                        + "java.lang.Object,int[])", s);
186:            }
187:
188:        }
189:
190:        class AnnotatedCtor {
191:            @TagAntn
192:            public AnnotatedCtor() {
193:            }
194:
195:            @TagAntn
196:            @ValAntn
197:            public AnnotatedCtor(Object param) {
198:            }
199:
200:            public AnnotatedCtor(@P1Antn
201:            String s) {
202:            }
203:
204:            @notfound.MissingAntn
205:            public AnnotatedCtor(int i) {
206:            }
207:
208:            @MissingClassValAntn
209:            public AnnotatedCtor(long l) {
210:            }
211:
212:            @MissingTypeAntn
213:            public AnnotatedCtor(char ch) {
214:            }
215:        }
216:
217:        class AnnotatedParamCtor {
218:            @TagAntn
219:            public AnnotatedParamCtor() {
220:            }
221:
222:            @ValAntn("abc")
223:            public AnnotatedParamCtor(@P1Antn
224:            Object p1, @P2Antn(123)
225:            Class p2, @P3Antn
226:            @ValAntn("xyz")
227:            boolean p3) {
228:            }
229:
230:            public AnnotatedParamCtor(String s, @TagAntn
231:            int i) {
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.