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
|
/*******************************************************************************
* Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Samrat Dhillon <samrat.dhillon@gmail.com> - [introduce factory] Introduce Factory on an abstract class adds a statement to create an instance of that class - https://bugs.eclipse.org/bugs/show_bug.cgi?id=395016
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
import org.junit.Test;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d6Setup;
/**
* @author rfuhrer@watson.ibm.com
*/
public class IntroduceFactoryTests extends IntroduceFactoryTestsBase{
private static final String REFACTORING_PATH= "IntroduceFactory/";
public IntroduceFactoryTests() {
rts= new Java1d6Setup();
}
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
//--- TESTS
@Test
public void testStaticContext_FFF() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
@Test
public void testInstanceContext_FFF() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
static final String[] k_Names = { "createThing", "ThingFactory", "IThingFactory" };
@Test
public void testNames_FFF() throws Exception {
namesHelper(k_Names[0], null);
}
//
// ================================================================================
//
@Test
public void testMultipleCallers_FFF() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
@Test
public void testSelectConstructor() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
@Test
public void testDifferentSigs() throws Exception {
singleUnitHelper(false);
}
@Test
public void testDifferentArgs1() throws Exception {
singleUnitHelper(false);
}
@Test
public void testDifferentArgs2() throws Exception {
singleUnitHelper(false);
}
@Test
public void testDifferentArgs3() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
@Test
public void testUnmovableArg1() throws Exception {
singleUnitHelper(false);
}
@Test
public void testUnmovableArg2() throws Exception {
singleUnitHelper(false);
}
@Test
public void testDontMoveArgs1() throws Exception {
singleUnitHelper(false);
}
@Test
public void testDontMoveArgs2() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
@Test
public void testProtectConstructor1() throws Exception {
singleUnitHelper(true);
}
@Test
public void testProtectConstructor2() throws Exception {
singleUnitHelper(true);
}
//
// ================================================================================
//
@Test
public void testStaticInstance() throws Exception {
singleUnitHelper(false);
}
//
// ================================================================================
//
@Test
public void testCtorThrows() throws Exception {
singleUnitHelper(true);
}
//
// ================================================================================
//
@Test
public void testJavadocRef() throws Exception {
singleUnitHelper(true);
}
//
// ================================================================================
//
@Test
public void testNestedClass() throws Exception {
failHelper(RefactoringStatus.FATAL);
}
//
// ================================================================================
// Generics-related tests
@Test
public void testTypeParam() throws Exception {
singleUnitHelper(true);
}
@Test
public void testTwoTypeParams() throws Exception {
singleUnitHelper(true);
}
@Test
public void testBoundedTypeParam() throws Exception {
singleUnitHelper(true);
}
@Test
public void testTwoBoundedTypeParams() throws Exception {
singleUnitHelper(true);
}
@Test
public void testWildcardParam() throws Exception {
singleUnitHelper(true);
}
@Test
public void testTypeParam2() throws Exception {
namesHelper(null, "p.Factory");
}
//
// ================================================================================
// Other J2SE 5.0 tests
@Test
public void testEnum() throws Exception {
failHelper(RefactoringStatus.FATAL);
}
@Test
public void testAnnotation1() throws Exception {
singleUnitHelper(true);
}
@Test
public void testAnnotation2() throws Exception {
singleUnitHelper(true);
}
@Test
public void testAnnotation3() throws Exception {
singleUnitHelper(true);
}
@Test
public void testVarArgsCtor() throws Exception {
// RMF - As of I20050202, search engine doesn't reliably find call sites to varargs methods
singleUnitHelper(true);
}
//
// ================================================================================
//
@Test
public void testMultipleUnits_FFF() throws Exception {
multiUnitHelper(false, new String[] { "MultiUnit1A", "MultiUnit1B", "MultiUnit1C" });
}
//
// ================================================================================
// Bugzilla bug regression tests
// ================================================================================
//
@Test
public void test45942() throws Exception {
multiUnitBugHelper(true, new String[] { "TestClass", "UseTestClass" }, null);
}
@Test
public void test46189() throws Exception {
singleUnitBugHelper("TestClass", true);
}
@Test
public void test46189B() throws Exception {
singleUnitBugHelper("TestClass", true);
}
@Test
public void test46373() throws Exception {
singleUnitBugHelper("ImplicitCtor", false);
}
@Test
public void test46374() throws Exception {
singleUnitBugHelper("QualifiedName", false);
}
@Test
public void test46608() throws Exception {
multiUnitBugHelper(true, new String[] { "p1/TT", "p2/TT" }, null);
}
@Test
public void test59284() throws Exception {
singleUnitBugHelper("ArgTypeImport", true);
}
@Test
public void test59280() throws Exception {
singleUnitBugHelper("ExplicitSuperCtorCall", true);
}
@Test
public void test48504() throws Exception {
multiUnitBugHelper(true, new String[] { "p1/A", "p1/B" }, "p1.B");
}
@Test
public void test58293() throws Exception {
singleUnitBugHelper("ImplicitSuperCtorCall", true);
}
@Test
public void test59283() throws Exception {
multiProjectBugHelper(new String[] { "proj1/pA/A", "proj2/pB/B" },
new String[] { "proj2:proj1" });
}
@Test
public void test84807() throws Exception {
singleUnitBugHelper("CtorOfParamType", true);
}
@Test
public void test85465() throws Exception {
singleUnitBugHelper("Varargs1", true);
}
@Test
public void test97507() throws Exception {
singleUnitBugHelper("CtorTypeArgBounds", true);
}
@Test
public void test250660() throws Exception {
singleUnitBugHelper("HasAnonymous", true);
}
@Test
public void test74759() throws Exception {
singleUnitBugHelper("Test", true);
}
@Test
public void test298281() throws Exception {
singleUnitBugHelper("Thing", true);
}
@Test
public void test395016_1() throws Exception {
singleUnitBugHelperWithWarning("AbstractClass", true);
}
@Test
public void test395016_2() throws Exception {
singleUnitBugHelperWithWarning("AbstractMethod", true);
}
@Test
public void testFactoryClash() throws Exception {
failHelper(RefactoringStatus.ERROR);
}
}
|