1
1
/*******************************************************************************
2
- * Copyright (c) 2000, 2017 IBM Corporation and others.
2
+ * Copyright (c) 2000, 2024 IBM Corporation and others.
3
3
*
4
4
* This program and the accompanying materials
5
5
* are made available under the terms of the Eclipse Public License 2.0
14
14
*******************************************************************************/
15
15
package org .eclipse .ui .tests .api ;
16
16
17
+ import static org .junit .Assert .assertArrayEquals ;
18
+
19
+ import java .util .Arrays ;
20
+
17
21
import org .eclipse .core .resources .IWorkspace ;
18
22
import org .eclipse .core .resources .ResourcesPlugin ;
19
23
import org .eclipse .core .runtime .IAdaptable ;
@@ -161,22 +165,19 @@ public void testAddPropertyChangeListener() throws Throwable {
161
165
public void testAddRecentWorkingSet () throws Throwable {
162
166
fWorkingSetManager .addRecentWorkingSet (fWorkingSet );
163
167
fWorkingSetManager .addWorkingSet (fWorkingSet );
164
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
165
- fWorkingSetManager .getRecentWorkingSets ()));
168
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ());
166
169
167
170
IWorkingSet workingSet2 = fWorkingSetManager .createWorkingSet (
168
171
WORKING_SET_NAME_2 , new IAdaptable [] { fWorkspace .getRoot () });
169
172
fWorkingSetManager .addRecentWorkingSet (workingSet2 );
170
173
fWorkingSetManager .addWorkingSet (workingSet2 );
171
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { workingSet2 ,
172
- fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ()));
174
+ assertArrayEquals (new IWorkingSet [] { workingSet2 , fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ());
173
175
}
174
176
175
177
@ Test
176
178
public void testAddWorkingSet () throws Throwable {
177
179
fWorkingSetManager .addWorkingSet (fWorkingSet );
178
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
179
- fWorkingSetManager .getWorkingSets ()));
180
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getWorkingSets ());
180
181
181
182
boolean exceptionThrown = false ;
182
183
try {
@@ -185,23 +186,20 @@ public void testAddWorkingSet() throws Throwable {
185
186
exceptionThrown = true ;
186
187
}
187
188
assertTrue (exceptionThrown );
188
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
189
- fWorkingSetManager .getWorkingSets ()));
189
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getWorkingSets ());
190
190
}
191
191
192
192
@ Test
193
193
public void testCreateWorkingSet () throws Throwable {
194
194
IWorkingSet workingSet2 = fWorkingSetManager .createWorkingSet (
195
195
WORKING_SET_NAME_2 , new IAdaptable [] { fWorkspace .getRoot () });
196
196
assertEquals (WORKING_SET_NAME_2 , workingSet2 .getName ());
197
- assertTrue (ArrayUtil .equals (new IAdaptable [] { fWorkspace .getRoot () },
198
- workingSet2 .getElements ()));
197
+ assertArrayEquals (new IAdaptable [] { fWorkspace .getRoot () }, workingSet2 .getElements ());
199
198
200
199
workingSet2 = fWorkingSetManager .createWorkingSet ("" ,
201
200
new IAdaptable [] {});
202
201
assertEquals ("" , workingSet2 .getName ());
203
- assertTrue (ArrayUtil .equals (new IAdaptable [] {}, workingSet2
204
- .getElements ()));
202
+ assertArrayEquals (new IAdaptable [] {}, workingSet2 .getElements ());
205
203
}
206
204
207
205
@ Test
@@ -213,8 +211,7 @@ public void testCreateWorkingSetFromMemento() throws Throwable {
213
211
IWorkingSet restoredWorkingSet2 = fWorkingSetManager
214
212
.createWorkingSet (memento );
215
213
assertEquals (WORKING_SET_NAME_2 , restoredWorkingSet2 .getName ());
216
- assertTrue (ArrayUtil .equals (new IAdaptable [] { fWorkspace .getRoot () },
217
- restoredWorkingSet2 .getElements ()));
214
+ assertArrayEquals (new IAdaptable [] { fWorkspace .getRoot () }, restoredWorkingSet2 .getElements ());
218
215
}
219
216
220
217
@ Test
@@ -232,19 +229,16 @@ public void testGetRecentWorkingSets() throws Throwable {
232
229
233
230
fWorkingSetManager .addRecentWorkingSet (fWorkingSet );
234
231
fWorkingSetManager .addWorkingSet (fWorkingSet );
235
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
236
- fWorkingSetManager .getRecentWorkingSets ()));
232
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ());
237
233
238
234
IWorkingSet workingSet2 = fWorkingSetManager .createWorkingSet (
239
235
WORKING_SET_NAME_2 , new IAdaptable [] { fWorkspace .getRoot () });
240
236
fWorkingSetManager .addRecentWorkingSet (workingSet2 );
241
237
fWorkingSetManager .addWorkingSet (workingSet2 );
242
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { workingSet2 ,
243
- fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ()));
238
+ assertArrayEquals (new IWorkingSet [] { workingSet2 , fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ());
244
239
245
240
fWorkingSetManager .removeWorkingSet (workingSet2 );
246
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
247
- fWorkingSetManager .getRecentWorkingSets ()));
241
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getRecentWorkingSets ());
248
242
}
249
243
250
244
@ Test
@@ -261,12 +255,12 @@ public void testRecentWorkingSetsLength() throws Throwable {
261
255
fWorkingSetManager .addWorkingSet (workingSet );
262
256
workingSets [9 - i ] = workingSet ;
263
257
}
264
- assertTrue ( ArrayUtil . equals ( workingSets , fWorkingSetManager .getRecentWorkingSets () ));
258
+ assertArrayEquals ( workingSets , fWorkingSetManager .getRecentWorkingSets ());
265
259
266
260
fWorkingSetManager .setRecentWorkingSetsLength (7 );
267
261
IWorkingSet [] workingSets7 = new IWorkingSet [7 ];
268
262
System .arraycopy (workingSets , 0 , workingSets7 , 0 , 7 );
269
- assertTrue ( ArrayUtil . equals ( workingSets7 , fWorkingSetManager .getRecentWorkingSets () ));
263
+ assertArrayEquals ( workingSets7 , fWorkingSetManager .getRecentWorkingSets ());
270
264
271
265
fWorkingSetManager .setRecentWorkingSetsLength (9 );
272
266
IWorkingSet [] workingSets9 = new IWorkingSet [9 ];
@@ -280,7 +274,7 @@ public void testRecentWorkingSetsLength() throws Throwable {
280
274
workingSets9 [8 - i ] = workingSet ;
281
275
}
282
276
283
- assertTrue ( ArrayUtil . equals ( workingSets9 , fWorkingSetManager .getRecentWorkingSets () ));
277
+ assertArrayEquals ( workingSets9 , fWorkingSetManager .getRecentWorkingSets ());
284
278
} finally {
285
279
if (oldMRULength > 0 ) {
286
280
fWorkingSetManager .setRecentWorkingSetsLength (oldMRULength );
@@ -302,20 +296,17 @@ public void testGetWorkingSet() throws Throwable {
302
296
303
297
@ Test
304
298
public void testGetWorkingSets () throws Throwable {
305
- assertTrue (ArrayUtil .equals (new IWorkingSet [] {}, fWorkingSetManager
306
- .getWorkingSets ()));
299
+ assertArrayEquals (new IWorkingSet [] {}, fWorkingSetManager .getWorkingSets ());
307
300
308
301
fWorkingSetManager .addWorkingSet (fWorkingSet );
309
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
310
- fWorkingSetManager .getWorkingSets ()));
302
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getWorkingSets ());
311
303
312
304
try {
313
305
fWorkingSetManager .addWorkingSet (fWorkingSet );
314
306
fail ("Added the same set twice" );
315
307
} catch (RuntimeException exception ) {
316
308
}
317
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { fWorkingSet },
318
- fWorkingSetManager .getWorkingSets ()));
309
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, fWorkingSetManager .getWorkingSets ());
319
310
320
311
IWorkingSet workingSet2 = fWorkingSetManager .createWorkingSet (
321
312
WORKING_SET_NAME_2 , new IAdaptable [] { fWorkspace .getRoot () });
@@ -369,16 +360,14 @@ public void testRemovePropertyChangeListener() throws Throwable {
369
360
@ Test
370
361
public void testRemoveWorkingSet () throws Throwable {
371
362
fWorkingSetManager .removeWorkingSet (fWorkingSet );
372
- assertTrue (ArrayUtil .equals (new IWorkingSet [] {}, fWorkingSetManager
373
- .getWorkingSets ()));
363
+ assertArrayEquals (new IWorkingSet [] {}, fWorkingSetManager .getWorkingSets ());
374
364
375
365
fWorkingSetManager .addWorkingSet (fWorkingSet );
376
366
IWorkingSet workingSet2 = fWorkingSetManager .createWorkingSet (
377
367
WORKING_SET_NAME_2 , new IAdaptable [] { fWorkspace .getRoot () });
378
368
fWorkingSetManager .addWorkingSet (workingSet2 );
379
369
fWorkingSetManager .removeWorkingSet (fWorkingSet );
380
- assertTrue (ArrayUtil .equals (new IWorkingSet [] { workingSet2 },
381
- fWorkingSetManager .getWorkingSets ()));
370
+ assertArrayEquals (new IWorkingSet [] { workingSet2 }, fWorkingSetManager .getWorkingSets ());
382
371
}
383
372
384
373
@ Test
@@ -391,9 +380,7 @@ public void testRemoveWorkingSetAfterRename() throws Throwable {
391
380
String origName =fWorkingSet .getName ();
392
381
393
382
/* check that workingSetManager contains "fWorkingSet"*/
394
- assertTrue (ArrayUtil .equals (
395
- new IWorkingSet [] { fWorkingSet },
396
- workingSetManager .getWorkingSets ()));
383
+ assertArrayEquals (new IWorkingSet [] { fWorkingSet }, workingSetManager .getWorkingSets ());
397
384
398
385
fWorkingSet .setName (" " );
399
386
assertEquals (" " , fWorkingSet .getName ());
@@ -402,7 +389,7 @@ public void testRemoveWorkingSetAfterRename() throws Throwable {
402
389
workingSetManager .removeWorkingSet (fWorkingSet );
403
390
404
391
/* check that "fWorkingSet" was removed after rename*/
405
- if (! ArrayUtil .equals (new IWorkingSet [] {},
392
+ if (! Arrays .equals (new IWorkingSet [] {},
406
393
workingSetManager .getWorkingSets ())){
407
394
/*Test Failure, report after restoring state*/
408
395
fWorkingSet .setName (origName );
0 commit comments