File: getMethods.java

package info (click to toggle)
mauve 20161030-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 44,628 kB
  • ctags: 35,425
  • sloc: java: 336,555; sh: 2,834; xml: 208; makefile: 72
file content (278 lines) | stat: -rw-r--r-- 23,416 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
// Test for method java.lang.Character.getClass().getMethods()

// Copyright (C) 2012, 2013, 2014, 2015 Pavel Tisnovsky <ptisnovs@redhat.com>

// This file is part of Mauve.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street,
// Fifth Floor, Boston, MA 02110-1301 USA.

// Tags: JDK1.5

package gnu.testlet.java.lang.Character.classInfo;

import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;

import java.lang.Character;
import java.util.Map;
import java.util.HashMap;



/**
 * Test for method java.lang.Character.getClass().getMethods()
 */
public class getMethods implements Testlet
{

    /**
     * Runs the test using the specified harness.
     *
     * @param harness  the test harness (<code>null</code> not permitted).
     */
    public void test(TestHarness harness)
    {
        // map of methods which should exists
        Map<String, String> testedMethods = null;

        // map of methods for (Open)JDK6
        Map<String, String> testedMethods_jdk6 = new HashMap<String, String>();

        // map of methods for (Open)JDK7
        Map<String, String> testedMethods_jdk7 = new HashMap<String, String>();

        // map for methods declared in (Open)JDK6
        testedMethods_jdk6.put("public static boolean java.lang.Character.isJavaIdentifierStart(int)", "isJavaIdentifierStart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isJavaIdentifierStart(char)", "isJavaIdentifierStart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isJavaIdentifierPart(int)", "isJavaIdentifierPart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isJavaIdentifierPart(char)", "isJavaIdentifierPart");
        testedMethods_jdk6.put("public boolean java.lang.Character.equals(java.lang.Object)", "equals");
        testedMethods_jdk6.put("public static java.lang.String java.lang.Character.toString(char)", "toString");
        testedMethods_jdk6.put("public java.lang.String java.lang.Character.toString()", "toString");
        testedMethods_jdk6.put("public int java.lang.Character.hashCode()", "hashCode");
        testedMethods_jdk6.put("public static char java.lang.Character.reverseBytes(char)", "reverseBytes");
        testedMethods_jdk6.put("public int java.lang.Character.compareTo(java.lang.Object)", "compareTo");
        testedMethods_jdk6.put("public int java.lang.Character.compareTo(java.lang.Character)", "compareTo");
        testedMethods_jdk6.put("public char java.lang.Character.charValue()", "charValue");
        testedMethods_jdk6.put("public static java.lang.Character java.lang.Character.valueOf(char)", "valueOf");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointAt(char[],int,int)", "codePointAt");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointAt(char[],int)", "codePointAt");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointAt(java.lang.CharSequence,int)", "codePointAt");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointBefore(char[],int)", "codePointBefore");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointBefore(char[],int,int)", "codePointBefore");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointBefore(java.lang.CharSequence,int)", "codePointBefore");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointCount(java.lang.CharSequence,int,int)", "codePointCount");
        testedMethods_jdk6.put("public static int java.lang.Character.codePointCount(char[],int,int)", "codePointCount");
        testedMethods_jdk6.put("public static int java.lang.Character.offsetByCodePoints(char[],int,int,int,int)", "offsetByCodePoints");
        testedMethods_jdk6.put("public static int java.lang.Character.offsetByCodePoints(java.lang.CharSequence,int,int)", "offsetByCodePoints");
        testedMethods_jdk6.put("public static char java.lang.Character.toLowerCase(char)", "toLowerCase");
        testedMethods_jdk6.put("public static int java.lang.Character.toLowerCase(int)", "toLowerCase");
        testedMethods_jdk6.put("public static int java.lang.Character.toUpperCase(int)", "toUpperCase");
        testedMethods_jdk6.put("public static char java.lang.Character.toUpperCase(char)", "toUpperCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isSupplementaryCodePoint(int)", "isSupplementaryCodePoint");
        testedMethods_jdk6.put("public static char[] java.lang.Character.toChars(int)", "toChars");
        testedMethods_jdk6.put("public static int java.lang.Character.toChars(int,char[],int)", "toChars");
        testedMethods_jdk6.put("public static int java.lang.Character.charCount(int)", "charCount");
        testedMethods_jdk6.put("public static int java.lang.Character.getType(char)", "getType");
        testedMethods_jdk6.put("public static int java.lang.Character.getType(int)", "getType");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isValidCodePoint(int)", "isValidCodePoint");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLowSurrogate(char)", "isLowSurrogate");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isHighSurrogate(char)", "isHighSurrogate");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isSurrogatePair(char,char)", "isSurrogatePair");
        testedMethods_jdk6.put("public static int java.lang.Character.toCodePoint(char,char)", "toCodePoint");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLowerCase(char)", "isLowerCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLowerCase(int)", "isLowerCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isUpperCase(int)", "isUpperCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isUpperCase(char)", "isUpperCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isTitleCase(int)", "isTitleCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isTitleCase(char)", "isTitleCase");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isDigit(char)", "isDigit");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isDigit(int)", "isDigit");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isDefined(int)", "isDefined");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isDefined(char)", "isDefined");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLetter(int)", "isLetter");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLetter(char)", "isLetter");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLetterOrDigit(char)", "isLetterOrDigit");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isLetterOrDigit(int)", "isLetterOrDigit");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isJavaLetter(char)", "isJavaLetter");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isJavaLetterOrDigit(char)", "isJavaLetterOrDigit");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isUnicodeIdentifierStart(int)", "isUnicodeIdentifierStart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isUnicodeIdentifierStart(char)", "isUnicodeIdentifierStart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isUnicodeIdentifierPart(int)", "isUnicodeIdentifierPart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isUnicodeIdentifierPart(char)", "isUnicodeIdentifierPart");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isIdentifierIgnorable(char)", "isIdentifierIgnorable");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isIdentifierIgnorable(int)", "isIdentifierIgnorable");
        testedMethods_jdk6.put("public static int java.lang.Character.toTitleCase(int)", "toTitleCase");
        testedMethods_jdk6.put("public static char java.lang.Character.toTitleCase(char)", "toTitleCase");
        testedMethods_jdk6.put("public static int java.lang.Character.digit(char,int)", "digit");
        testedMethods_jdk6.put("public static int java.lang.Character.digit(int,int)", "digit");
        testedMethods_jdk6.put("public static int java.lang.Character.getNumericValue(int)", "getNumericValue");
        testedMethods_jdk6.put("public static int java.lang.Character.getNumericValue(char)", "getNumericValue");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isSpace(char)", "isSpace");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isSpaceChar(int)", "isSpaceChar");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isSpaceChar(char)", "isSpaceChar");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isWhitespace(char)", "isWhitespace");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isWhitespace(int)", "isWhitespace");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isISOControl(int)", "isISOControl");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isISOControl(char)", "isISOControl");
        testedMethods_jdk6.put("public static char java.lang.Character.forDigit(int,int)", "forDigit");
        testedMethods_jdk6.put("public static byte java.lang.Character.getDirectionality(int)", "getDirectionality");
        testedMethods_jdk6.put("public static byte java.lang.Character.getDirectionality(char)", "getDirectionality");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isMirrored(char)", "isMirrored");
        testedMethods_jdk6.put("public static boolean java.lang.Character.isMirrored(int)", "isMirrored");
        testedMethods_jdk6.put("public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk6.put("public final void java.lang.Object.wait(long) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk6.put("public final void java.lang.Object.wait() throws java.lang.InterruptedException", "wait");
        testedMethods_jdk6.put("public final java.lang.Class java.lang.Object.getClass()", "getClass");
        testedMethods_jdk6.put("public final void java.lang.Object.notify()", "notify");
        testedMethods_jdk6.put("public final void java.lang.Object.notifyAll()", "notifyAll");

        // map for methods declared in (Open)JDK7
        testedMethods_jdk7.put("public static boolean java.lang.Character.isJavaIdentifierStart(char)", "isJavaIdentifierStart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isJavaIdentifierStart(int)", "isJavaIdentifierStart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isJavaIdentifierPart(int)", "isJavaIdentifierPart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isJavaIdentifierPart(char)", "isJavaIdentifierPart");
        testedMethods_jdk7.put("public boolean java.lang.Character.equals(java.lang.Object)", "equals");
        testedMethods_jdk7.put("public static java.lang.String java.lang.Character.toString(char)", "toString");
        testedMethods_jdk7.put("public java.lang.String java.lang.Character.toString()", "toString");
        testedMethods_jdk7.put("public int java.lang.Character.hashCode()", "hashCode");
        testedMethods_jdk7.put("public static char java.lang.Character.reverseBytes(char)", "reverseBytes");
        testedMethods_jdk7.put("public int java.lang.Character.compareTo(java.lang.Object)", "compareTo");
        testedMethods_jdk7.put("public int java.lang.Character.compareTo(java.lang.Character)", "compareTo");
        testedMethods_jdk7.put("public char java.lang.Character.charValue()", "charValue");
        testedMethods_jdk7.put("public static java.lang.Character java.lang.Character.valueOf(char)", "valueOf");
        testedMethods_jdk7.put("public static java.lang.String java.lang.Character.getName(int)", "getName");
        testedMethods_jdk7.put("public static int java.lang.Character.charCount(int)", "charCount");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointAt(char[],int,int)", "codePointAt");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointAt(java.lang.CharSequence,int)", "codePointAt");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointAt(char[],int)", "codePointAt");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointBefore(char[],int,int)", "codePointBefore");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointBefore(char[],int)", "codePointBefore");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointBefore(java.lang.CharSequence,int)", "codePointBefore");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointCount(char[],int,int)", "codePointCount");
        testedMethods_jdk7.put("public static int java.lang.Character.codePointCount(java.lang.CharSequence,int,int)", "codePointCount");
        testedMethods_jdk7.put("public static int java.lang.Character.compare(char,char)", "compare");
        testedMethods_jdk7.put("public static char java.lang.Character.highSurrogate(int)", "highSurrogate");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isBmpCodePoint(int)", "isBmpCodePoint");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isValidCodePoint(int)", "isValidCodePoint");
        testedMethods_jdk7.put("public static char java.lang.Character.lowSurrogate(int)", "lowSurrogate");
        testedMethods_jdk7.put("public static int java.lang.Character.offsetByCodePoints(char[],int,int,int,int)", "offsetByCodePoints");
        testedMethods_jdk7.put("public static int java.lang.Character.offsetByCodePoints(java.lang.CharSequence,int,int)", "offsetByCodePoints");
        testedMethods_jdk7.put("public static int java.lang.Character.toChars(int,char[],int)", "toChars");
        testedMethods_jdk7.put("public static char[] java.lang.Character.toChars(int)", "toChars");
        testedMethods_jdk7.put("public static int java.lang.Character.toLowerCase(int)", "toLowerCase");
        testedMethods_jdk7.put("public static char java.lang.Character.toLowerCase(char)", "toLowerCase");
        testedMethods_jdk7.put("public static int java.lang.Character.toUpperCase(int)", "toUpperCase");
        testedMethods_jdk7.put("public static char java.lang.Character.toUpperCase(char)", "toUpperCase");
        testedMethods_jdk7.put("public static int java.lang.Character.getType(int)", "getType");
        testedMethods_jdk7.put("public static int java.lang.Character.getType(char)", "getType");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isHighSurrogate(char)", "isHighSurrogate");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLowSurrogate(char)", "isLowSurrogate");
        testedMethods_jdk7.put("public static int java.lang.Character.digit(char,int)", "digit");
        testedMethods_jdk7.put("public static int java.lang.Character.digit(int,int)", "digit");
        testedMethods_jdk7.put("public static char java.lang.Character.forDigit(int,int)", "forDigit");
        testedMethods_jdk7.put("public static byte java.lang.Character.getDirectionality(int)", "getDirectionality");
        testedMethods_jdk7.put("public static byte java.lang.Character.getDirectionality(char)", "getDirectionality");
        testedMethods_jdk7.put("public static int java.lang.Character.getNumericValue(char)", "getNumericValue");
        testedMethods_jdk7.put("public static int java.lang.Character.getNumericValue(int)", "getNumericValue");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isAlphabetic(int)", "isAlphabetic");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isDefined(char)", "isDefined");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isDefined(int)", "isDefined");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isDigit(char)", "isDigit");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isDigit(int)", "isDigit");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isISOControl(int)", "isISOControl");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isISOControl(char)", "isISOControl");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isIdentifierIgnorable(char)", "isIdentifierIgnorable");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isIdentifierIgnorable(int)", "isIdentifierIgnorable");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isIdeographic(int)", "isIdeographic");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isJavaLetter(char)", "isJavaLetter");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isJavaLetterOrDigit(char)", "isJavaLetterOrDigit");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLetter(char)", "isLetter");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLetter(int)", "isLetter");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLetterOrDigit(char)", "isLetterOrDigit");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLetterOrDigit(int)", "isLetterOrDigit");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLowerCase(int)", "isLowerCase");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isLowerCase(char)", "isLowerCase");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isMirrored(char)", "isMirrored");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isMirrored(int)", "isMirrored");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isSpace(char)", "isSpace");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isSpaceChar(char)", "isSpaceChar");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isSpaceChar(int)", "isSpaceChar");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isSupplementaryCodePoint(int)", "isSupplementaryCodePoint");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isSurrogate(char)", "isSurrogate");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isSurrogatePair(char,char)", "isSurrogatePair");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isTitleCase(int)", "isTitleCase");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isTitleCase(char)", "isTitleCase");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isUnicodeIdentifierPart(int)", "isUnicodeIdentifierPart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isUnicodeIdentifierPart(char)", "isUnicodeIdentifierPart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isUnicodeIdentifierStart(char)", "isUnicodeIdentifierStart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isUnicodeIdentifierStart(int)", "isUnicodeIdentifierStart");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isUpperCase(int)", "isUpperCase");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isUpperCase(char)", "isUpperCase");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isWhitespace(int)", "isWhitespace");
        testedMethods_jdk7.put("public static boolean java.lang.Character.isWhitespace(char)", "isWhitespace");
        testedMethods_jdk7.put("public static int java.lang.Character.toCodePoint(char,char)", "toCodePoint");
        testedMethods_jdk7.put("public static char java.lang.Character.toTitleCase(char)", "toTitleCase");
        testedMethods_jdk7.put("public static int java.lang.Character.toTitleCase(int)", "toTitleCase");
        testedMethods_jdk7.put("public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk7.put("public final void java.lang.Object.wait(long) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk7.put("public final void java.lang.Object.wait() throws java.lang.InterruptedException", "wait");
        testedMethods_jdk7.put("public final java.lang.Class java.lang.Object.getClass()", "getClass");
        testedMethods_jdk7.put("public final void java.lang.Object.notify()", "notify");
        testedMethods_jdk7.put("public final void java.lang.Object.notifyAll()", "notifyAll");

        // create instance of a class Character
        final Object o = new Character('!');

        // get a runtime class of an object "o"
        final Class c = o.getClass();

        // get the right map containing method signatures
        testedMethods = getJavaVersion() < 7 ? testedMethods_jdk6 : testedMethods_jdk7;

        // get all methods for this class
        java.lang.reflect.Method[] methods = c.getMethods();

        // expected number of methods
        final int expectedNumberOfMethods = testedMethods.size();

        // basic check for a number of methods
        harness.check(methods.length, expectedNumberOfMethods);

        // check if all methods exist
        for (java.lang.reflect.Method method : methods) {
            // method name should consists of package name + class name
            String methodName = method.getName();
            // modifiers + package + method name + parameter types
            String methodString = method.toString().replaceAll(" native ", " ");
            harness.check(testedMethods.containsKey(methodString));
            harness.check(testedMethods.get(methodString), methodName);
        }
    }

    /**
     * Returns version of Java. The input could have the following form: "1.7.0_06"
     * and we are interested only in "7" in this case.
     * 
     * @return Java version
     */
    protected int getJavaVersion() {
        String javaVersionStr = System.getProperty("java.version");
        String[] parts = javaVersionStr.split("\\.");
        return Integer.parseInt(parts[1]);
    }
}