File: DefaultStaticTestData.java

package info (click to toggle)
openjdk-11 11.0.4%2B11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 757,028 kB
  • sloc: java: 5,016,041; xml: 1,191,974; cpp: 934,731; ansic: 555,697; sh: 24,299; objc: 12,703; python: 3,602; asm: 3,415; makefile: 2,772; awk: 351; sed: 172; perl: 114; jsp: 24; csh: 3
file content (449 lines) | stat: -rw-r--r-- 13,780 bytes parent folder | download | duplicates (16)
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/*
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code 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
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

/*
 * Test Data used for testing default/static method
 *
 * @author Yong Lu
 */

import java.util.Arrays;
import java.util.List;

import org.testng.annotations.DataProvider;
import org.testng.collections.Lists;

import static helper.Mod.*;
import static helper.Declared.*;
import helper.Mod;
import helper.Declared;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = YES)
interface TestIF1 {

    default String defaultMethod() {
        return "TestIF1.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass1 implements TestIF1 {
}

@MethodDesc(name = "staticMethod", retval = "TestIF2.staticMethod", mod = STATIC, declared = YES)
interface TestIF2 {

    static String staticMethod() {
        return "TestIF2.staticMethod";
    }
}

@MethodDesc(name = "method", retval = "TestIF2.staticMethod", mod = REGULAR, declared = YES)
class TestClass2 implements TestIF2 {

    public String method() {
        return TestIF2.staticMethod();
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF3.defaultMethod", mod = DEFAULT, declared = YES)
@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)
interface TestIF3 {

    String method();

    default String defaultMethod() {
        return "TestIF3.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF3.defaultMethod", mod = DEFAULT, declared = NO)
@MethodDesc(name = "method", retval = "TestClass3.method", mod = REGULAR, declared = YES)
class TestClass3 implements TestIF3 {

    public String method() {
        return "TestClass3.method";
    }
}

@MethodDesc(name = "staticMethod", retval = "TestIF4.staticMethod", mod = STATIC, declared = YES)
@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)
interface TestIF4 {

    String method();

    static String staticMethod() {
        return "TestIF4.staticMethod";
    }
}

@MethodDesc(name = "method", retval = "TestClass4.method", mod = REGULAR, declared = YES)
class TestClass4 implements TestIF4 {

    public String method() {
        return "TestClass4.method";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF5.defaultMethod", mod = DEFAULT, declared = YES)
@MethodDesc(name = "staticMethod", retval = "TestIF5.staticMethod", mod = STATIC, declared = YES)
interface TestIF5 {

    default String defaultMethod() {
        return "TestIF5.defaultMethod";
    }

    static String staticMethod() {
        return "TestIF5.staticMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF5.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass5 implements TestIF5 {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF6.defaultMethod", mod = DEFAULT, declared = YES)
@MethodDesc(name = "staticMethod", retval = "TestIF6.staticMethod", mod = STATIC, declared = YES)
@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)
interface TestIF6 {

    String method();

    default String defaultMethod() {
        return "TestIF6.defaultMethod";
    }

    static String staticMethod() {
        return "TestIF6.staticMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF6.defaultMethod", mod = DEFAULT, declared = NO)
@MethodDesc(name = "method", retval = "TestClass6.method", mod = REGULAR, declared = YES)
class TestClass6 implements TestIF6 {

    public String method() {
        return "TestClass6.method";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF7.TestClass7", mod = DEFAULT, declared = YES)
interface TestIF7<T> {

    default T defaultMethod(T t) {
        return t;
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF7.TestClass7", mod = DEFAULT, declared = NO)
class TestClass7<T> implements TestIF7<T> {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF8.TestClass8", mod = DEFAULT, declared = YES)
interface TestIF8<E> {

    default <E> E defaultMethod(E e) {
        return e;
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF8.TestClass8", mod = DEFAULT, declared = NO)
class TestClass8<T> implements TestIF8<T> {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = YES)
interface TestIF9 extends TestIF1 {

    default String defaultMethod() {
        return "TestIF9.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass9 implements TestIF9 {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = NO)
@MethodDesc(name = "method", retval = "TestIF9.defaultMethod", mod = REGULAR, declared = YES)
class TestClass91 implements TestIF9, TestIF1 {

    public String method() {
        return defaultMethod();
    }
}

@MethodDesc(name = "staticMethod", retval = "TestIF10.staticMethod", mod = STATIC, declared = YES)
interface TestIF10 extends TestIF2 {

    static String staticMethod() {

        return "TestIF10.staticMethod";
    }
}

@MethodDesc(name = "staticMethod", retval = "TestIF11.staticMethod", mod = STATIC, declared = YES)
@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)
interface TestIF11 extends TestIF1 {

    static String staticMethod() {
        return "TestIF11.staticMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass11 implements TestIF11 {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = YES)
interface TestIF12 extends TestIF2 {

    default String defaultMethod() {
        return "TestIF12.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass12 implements TestIF12 {
}

//Diamond Case
@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)
interface TestIF1A extends TestIF1 {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)
interface TestIF1B extends TestIF1 {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass13 implements TestIF1A, TestIF1B {
}

//Diamond Override Case
@MethodDesc(name = "defaultMethod", retval = "TestIF1C.defaultMethod", mod = DEFAULT, declared = YES)
interface TestIF1C extends TestIF1 {

    default String defaultMethod() {
        return "TestIF1C.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF1D.defaultMethod", mod = DEFAULT, declared = YES)
interface TestIF1D extends TestIF1 {

    default String defaultMethod() {
        return "TestIF1D.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestClass14.defaultMethod", mod = REGULAR, declared = YES)
class TestClass14 implements TestIF1C, TestIF1D {

    public String defaultMethod() {
        return "TestClass14.defaultMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "", mod = ABSTRACT, declared = YES)
interface TestIF15 extends TestIF1 {

    String defaultMethod();
}

@MethodDesc(name = "defaultMethod", retval = "TestClass15.defaultMethod", mod = REGULAR, declared = YES)
class TestClass15 implements TestIF15 {

    public String defaultMethod() {
        return "TestClass15.defaultMethod";
    }
}

interface FuncInterface<T> {

    String test(T t);
}

@MethodDesc(name = "defaultMethod", retval = "TestIF16.defaultMethod", mod = DEFAULT, declared = YES)
interface TestIF16 {

    default String defaultMethod() {
        FuncInterface<Object> fi = o -> o.toString();
        Object o = "TestIF16.defaultMethod";
        return fi.test(o);
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF16.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass16 implements TestIF16 {
}

@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = YES)
@MethodDesc(name = "staticMethod", retval = "TestIF17.staticMethod", mod = STATIC, declared = YES)
interface TestIF17 {

    default String defaultMethod() {
        return staticMethod().replace("staticMethod", "defaultMethod");
    }

    public static String staticMethod() {
        return "TestIF17.staticMethod";
    }
}

@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass17 implements TestIF17 {
}


@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = NO)
class TestClass18 extends TestClass17 {
}


@Retention(RetentionPolicy.RUNTIME)
@Repeatable(MethodDescs.class)
@interface MethodDesc {
    String name();
    String retval();
    Mod mod();
    Declared declared();
}

@Retention(RetentionPolicy.RUNTIME)
@interface MethodDescs {
    MethodDesc[] value();
}

//Diamond Case for static method
@MethodDesc(name = "staticMethod", retval = "TestIF2A.staticMethod", mod = STATIC, declared = YES)
interface TestIF2A extends TestIF2 {
    static String staticMethod() {
        return "TestIF2A.staticMethod";
    }
}

@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)
interface TestIF2B extends TestIF2 {
    String method();
}

@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES)
interface TestIF18 extends TestIF10, TestIF2A {
    String method();
}

@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = NO)
@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO)
interface TestIF19 extends TestIF12, TestIF2B {
}

@MethodDesc(name = "staticMethod", retval = "TestIF20.staticMethod", mod = STATIC, declared = YES)
@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO)
interface TestIF20 extends TestIF12, TestIF2A {
    static String staticMethod() {
        return "TestIF20.staticMethod";
    }
}

@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = NO)
interface TestIF21 extends TestIF2A, TestIF2B {
}

public class DefaultStaticTestData {

    /**
     * Test data for DefaultStaticInvokeTest The format of inner array is: First
     * data is the name of the class under test Second data used in test as the
     * arguments used for the method call.
     */
    @DataProvider
    static Object[][] testClasses() {
        return new Object[][]{
            {"TestClass1", null},
            {"TestClass2", null},
            {"TestClass3", null},
            {"TestClass4", null},
            {"TestClass5", null},
            {"TestClass6", null},
            {"TestClass7", "TestIF7.TestClass7"},
            {"TestClass8", "TestIF8.TestClass8"},
            {"TestClass9", null},
            {"TestClass91", null},
            {"TestClass11", null},
            {"TestClass12", null},
            {"TestClass13", null},
            {"TestClass14", null},
            {"TestClass15", null},
            {"TestClass16", null},
            {"TestClass17", null},
            {"TestClass18", null},
        };
    }

    /**
     * Test data for DefaultStaticInvokeTest The format of inner array is: First
     * data is the name of the interface under test Second data used in test as
     * the arguments used for the method call.
     */
    @DataProvider
    static Object[][] testInterfaces() {
        return new Object[][]{
            {"TestIF1", null},
            {"TestIF2", null},
            {"TestIF2A", null},
            {"TestIF2B", null},
            {"TestIF3", null},
            {"TestIF4", null},
            {"TestIF5", null},
            {"TestIF6", null},
            {"TestIF7", "TestIF7.TestClass7"},
            {"TestIF8", "TestIF8.TestClass8"},
            {"TestIF9", null},
            {"TestIF10", null},
            {"TestIF11", null},
            {"TestIF12", null},
            {"TestIF1A", null},
            {"TestIF1B", null},
            {"TestIF1C", null},
            {"TestIF1D", null},
            {"TestIF15", null},
            {"TestIF16", null},
            {"TestIF17", null},
            {"TestIF18", null},
            {"TestIF19", null},
            {"TestIF20", null},
            {"TestIF21", null},
        };
    }

    @DataProvider
    static Object[][] testCasesAll() {
        List<Object[]> result = Lists.newArrayList();
        result.addAll(Arrays.asList(testClasses()));
        result.addAll(Arrays.asList(testInterfaces()));
        return result.toArray(new Object[result.size()][]);
    }
}