Skip to content

Commit 326506c

Browse files
committed
Remove ResourceTest#assert*(String, ...) methods #903
This change removes all assert*() methods from ResourceTest that accept a string and replaces all calls to use the according methods that do not accept a string. All callers only pass order numbers of assertions within the test methods to this assertion utility, which are unnecessary as failing tests deliver stack traces from which the failing statement is obvious. Contributes to #903
1 parent 709702c commit 326506c

33 files changed

+383
-455
lines changed

resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager1Test.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ public void testAnotherProject() throws CoreException {
139139
// create some children
140140
IResource[] resources = buildResources(project, defineHierarchy(PROJECT_1));
141141
ensureExistsInWorkspace(resources, true);
142-
assertExistsInFileSystem("3.1", resources);
143-
assertExistsInWorkspace("3.2", resources);
142+
assertExistsInFileSystem(resources);
143+
assertExistsInWorkspace(resources);
144144

145145
project.close(null);
146146
project.open(null);
147-
assertExistsInFileSystem("4.1", resources);
148-
assertExistsInWorkspace("4.2", resources);
147+
assertExistsInFileSystem(resources);
148+
assertExistsInWorkspace(resources);
149149

150150
getWorkspace().save(true, null);
151151
}
@@ -202,13 +202,13 @@ public void testCreateMyProject() throws CoreException {
202202
// create some children
203203
IResource[] resources = buildResources(project, defineHierarchy(PROJECT_1));
204204
ensureExistsInWorkspace(resources, true);
205-
assertExistsInFileSystem("3.1", resources);
206-
assertExistsInWorkspace("3.2", resources);
205+
assertExistsInFileSystem(resources);
206+
assertExistsInWorkspace(resources);
207207

208208
project.close(null);
209209
project.open(null);
210-
assertExistsInFileSystem("4.1", resources);
211-
assertExistsInWorkspace("4.2", resources);
210+
assertExistsInFileSystem(resources);
211+
assertExistsInWorkspace(resources);
212212
}
213213

214214
/**
@@ -224,8 +224,8 @@ public void testCreateProject2() throws CoreException {
224224
// create some children
225225
IResource[] resources = buildResources(project, defineHierarchy(PROJECT_2));
226226
ensureExistsInWorkspace(resources, true);
227-
assertExistsInFileSystem("3.1", resources);
228-
assertExistsInWorkspace("3.2", resources);
227+
assertExistsInFileSystem(resources);
228+
assertExistsInWorkspace(resources);
229229

230230
// add a builder to this project
231231
IProjectDescription description = project.getDescription();

resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager2Test.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ public void testVerifyProject2() throws CoreException {
108108

109109
// verify its children
110110
IResource[] resources = buildResources(project, defineHierarchy(PROJECT_2));
111-
assertExistsInFileSystem("1.0", resources);
112-
assertDoesNotExistInWorkspace("1.1", resources);
111+
assertExistsInFileSystem(resources);
112+
assertDoesNotExistInWorkspace(resources);
113113

114114
project.open(null);
115115
assertTrue("2.1", project.exists());
116116
assertTrue("2.2", project.isOpen());
117-
assertExistsInFileSystem("2.3", resources);
118-
assertExistsInWorkspace("2.4", resources);
117+
assertExistsInFileSystem(resources);
118+
assertExistsInWorkspace(resources);
119119

120120
// verify builder -- cause an incremental build
121121
touch(project);
@@ -135,8 +135,8 @@ public void testVerifyRestoredWorkspace() throws CoreException {
135135

136136
// verify children still exist
137137
IResource[] resources = buildResources(project, defineHierarchy(PROJECT_1));
138-
assertExistsInFileSystem("1.0", resources);
139-
assertExistsInWorkspace("1.1", resources);
138+
assertExistsInFileSystem(resources);
139+
assertExistsInWorkspace(resources);
140140

141141
// add a file to test save participant delta
142142
IFile file = project.getFile("addedFile");

resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/BasicAliasTest.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,17 @@ public void testCopyFolder() throws CoreException {
533533
IFolder destFolder1 = fLinkOverlap1.getFolder(source.getName());
534534
IFolder destFolder2 = fLinkOverlap2.getFolder(source.getName());
535535
IResource[] allDest = new IResource[] {destFolder1, destFolder2};
536-
assertDoesNotExistInWorkspace("1.0", allDest);
536+
assertDoesNotExistInWorkspace(allDest);
537537

538538
//copy to dest 1
539539
source.copy(destFolder1.getFullPath(), IResource.NONE, getMonitor());
540-
assertExistsInWorkspace("1.2", allDest);
540+
assertExistsInWorkspace(allDest);
541541

542542
destFolder2.delete(IResource.NONE, getMonitor());
543543

544544
//copy to dest 2
545545
source.copy(destFolder2.getFullPath(), IResource.NONE, getMonitor());
546-
assertExistsInWorkspace("1.5", allDest);
546+
assertExistsInWorkspace(allDest);
547547

548548
destFolder1.delete(IResource.NONE, getMonitor());
549549
}
@@ -786,9 +786,10 @@ public void testDeleteProjectContents() throws CoreException {
786786
//delete the overlapping project - it should delete the children of the linked folder
787787
//but leave the actual links intact in the resource tree
788788
pOverlap.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT, getMonitor());
789-
assertDoesNotExistInWorkspace("1.1", new IResource[] {pOverlap, fOverlap, lOverlap, lChildOverlap, lChildLinked});
790-
assertDoesNotExistInFileSystem("1.2", new IResource[] {pOverlap, fOverlap, lOverlap, lChildOverlap, lChildLinked, lLinked, fLinked});
791-
assertExistsInWorkspace("1.3", new IResource[] {pLinked, fLinked, lLinked});
789+
assertDoesNotExistInWorkspace(new IResource[] { pOverlap, fOverlap, lOverlap, lChildOverlap, lChildLinked });
790+
assertDoesNotExistInFileSystem(
791+
new IResource[] { pOverlap, fOverlap, lOverlap, lChildOverlap, lChildLinked, lLinked, fLinked });
792+
assertExistsInWorkspace(new IResource[] { pLinked, fLinked, lLinked });
792793
}
793794

794795
@Test
@@ -834,43 +835,43 @@ public void testMoveFile() throws CoreException {
834835
IFile destination = pNoOverlap.getFile("MoveDestination");
835836
//file in linked folder
836837
lChildLinked.move(destination.getFullPath(), IResource.NONE, getMonitor());
837-
assertDoesNotExistInWorkspace("1.1", lChildLinked);
838-
assertDoesNotExistInWorkspace("1.2", lChildOverlap);
839-
assertExistsInWorkspace("1.3", destination);
838+
assertDoesNotExistInWorkspace(lChildLinked);
839+
assertDoesNotExistInWorkspace(lChildOverlap);
840+
assertExistsInWorkspace(destination);
840841
assertOverlap("1.4", lChildLinked, lChildOverlap);
841842
assertTrue("1.5", lChildLinked.isSynchronized(IResource.DEPTH_INFINITE));
842843
assertTrue("1.6", destination.isSynchronized(IResource.DEPTH_INFINITE));
843844

844845
destination.move(lChildLinked.getFullPath(), IResource.NONE, getMonitor());
845-
assertExistsInWorkspace("2.1", lChildLinked);
846-
assertExistsInWorkspace("2.2", lChildOverlap);
847-
assertDoesNotExistInWorkspace("2.3", destination);
846+
assertExistsInWorkspace(lChildLinked);
847+
assertExistsInWorkspace(lChildOverlap);
848+
assertDoesNotExistInWorkspace(destination);
848849
assertOverlap("2.4", lChildLinked, lChildOverlap);
849850
//duplicate file
850851
lOverlap.move(destination.getFullPath(), IResource.NONE, getMonitor());
851-
assertDoesNotExistInWorkspace("3.1", lOverlap);
852-
assertExistsInWorkspace("3.2", lLinked);
853-
assertDoesNotExistInFileSystem("3.25", lLinked);
854-
assertExistsInWorkspace("3.3", destination);
852+
assertDoesNotExistInWorkspace(lOverlap);
853+
assertExistsInWorkspace(lLinked);
854+
assertDoesNotExistInFileSystem(lLinked);
855+
assertExistsInWorkspace(destination);
855856
assertEquals("3.4", lLinked.getLocation(), lOverlap.getLocation());
856857
assertTrue("3.4.1", lLinked.isSynchronized(IResource.DEPTH_INFINITE));
857858

858859
destination.move(lOverlap.getFullPath(), IResource.NONE, getMonitor());
859-
assertExistsInWorkspace("3.5", lLinked);
860-
assertExistsInWorkspace("3.6", lOverlap);
861-
assertDoesNotExistInWorkspace("3.7", destination);
860+
assertExistsInWorkspace(lLinked);
861+
assertExistsInWorkspace(lOverlap);
862+
assertDoesNotExistInWorkspace(destination);
862863
assertOverlap("3.8", lLinked, lOverlap);
863864
//file in duplicate folder
864865
lChildOverlap.move(destination.getFullPath(), IResource.NONE, getMonitor());
865-
assertDoesNotExistInWorkspace("3.1", lChildLinked);
866-
assertDoesNotExistInWorkspace("3.2", lChildOverlap);
867-
assertExistsInWorkspace("3.3", destination);
866+
assertDoesNotExistInWorkspace(lChildLinked);
867+
assertDoesNotExistInWorkspace(lChildOverlap);
868+
assertExistsInWorkspace(destination);
868869
assertOverlap("3.4", lChildLinked, lChildOverlap);
869870

870871
destination.move(lChildOverlap.getFullPath(), IResource.NONE, getMonitor());
871-
assertExistsInWorkspace("3.5", lChildLinked);
872-
assertExistsInWorkspace("3.6", lChildOverlap);
873-
assertDoesNotExistInWorkspace("3.7", destination);
872+
assertExistsInWorkspace(lChildLinked);
873+
assertExistsInWorkspace(lChildOverlap);
874+
assertDoesNotExistInWorkspace(destination);
874875
assertOverlap("3.8", lChildLinked, lChildOverlap);
875876
}
876877
}

resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ public void testMoveFileAcrossVolumes() throws CoreException {
9090

9191
// assert file was moved
9292
IFile newFile = destination.getFile(fileName);
93-
assertDoesNotExistInWorkspace("4.1", file);
94-
assertDoesNotExistInFileSystem("4.2", file);
95-
assertExistsInWorkspace("4.3", newFile);
96-
assertExistsInFileSystem("4.4", newFile);
93+
assertDoesNotExistInWorkspace(file);
94+
assertDoesNotExistInFileSystem(file);
95+
assertExistsInWorkspace(newFile);
96+
assertExistsInFileSystem(newFile);
9797

9898
// assert properties still exist (server, local and session)
9999
for (int j = 0; j < numberOfProperties; j++) {
@@ -193,10 +193,10 @@ public void testMoveFolderAcrossVolumes() throws CoreException {
193193

194194
// assert folder was renamed
195195
IFolder newFolder = destination.getFolder(folderName);
196-
assertDoesNotExistInWorkspace("4.1", folder);
197-
assertDoesNotExistInFileSystem("4.2", folder);
198-
assertExistsInWorkspace("4.3", newFolder);
199-
assertExistsInFileSystem("4.4", newFolder);
196+
assertDoesNotExistInWorkspace(folder);
197+
assertDoesNotExistInFileSystem(folder);
198+
assertExistsInWorkspace(newFolder);
199+
assertExistsInFileSystem(newFolder);
200200

201201
// assert properties still exist (server, local and session)
202202
for (int j = 0; j < numberOfProperties; j++) {

resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/CharsetTest.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
524524
verifier.waitForEvent(10000);
525525
IFile regularPrefs = getResourcesPreferenceFile(project1, false);
526526
IFile derivedPrefs = getResourcesPreferenceFile(project1, true);
527-
assertExistsInWorkspace("0.2", regularPrefs);
528-
assertDoesNotExistInWorkspace("0.3", derivedPrefs);
527+
assertExistsInWorkspace(regularPrefs);
528+
assertDoesNotExistInWorkspace(derivedPrefs);
529529

530530
//1 - setting preference on project
531531
verifier.reset();
@@ -534,8 +534,8 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
534534
setDerivedEncodingStoredSeparately(project1, true);
535535
assertTrue("1.1", verifier.waitForEvent(10000));
536536
assertTrue("1.2 " + verifier.getMessage(), verifier.isDeltaValid());
537-
assertExistsInWorkspace("1.3", regularPrefs);
538-
assertDoesNotExistInWorkspace("1.4", derivedPrefs);
537+
assertExistsInWorkspace(regularPrefs);
538+
assertDoesNotExistInWorkspace(derivedPrefs);
539539
assertTrue("1.5", isDerivedEncodingStoredSeparately(project1));
540540

541541
//2 - changing charset for file
@@ -545,17 +545,17 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
545545
a.setCharset("UTF-8", getMonitor());
546546
assertTrue("2.1", verifier.waitForEvent(10000));
547547
assertTrue("2.2 " + verifier.getMessage(), verifier.isDeltaValid());
548-
assertExistsInWorkspace("2.3", regularPrefs);
549-
assertDoesNotExistInWorkspace("2.4", derivedPrefs);
548+
assertExistsInWorkspace(regularPrefs);
549+
assertDoesNotExistInWorkspace(derivedPrefs);
550550

551551
//3 - setting derived == 'true' for file
552552
// TODO update the test when bug 345271 is fixed
553553
a.setDerived(true, getMonitor());
554554
//wait for all resource deltas
555555
// Thread.sleep(500);
556556
waitForCharsetManagerJob();
557-
assertExistsInWorkspace("3.1", regularPrefs);
558-
assertExistsInWorkspace("3.2", derivedPrefs);
557+
assertExistsInWorkspace(regularPrefs);
558+
assertExistsInWorkspace(derivedPrefs);
559559
assertTrue("3.3", derivedPrefs.isDerived());
560560

561561
//4 - setting derived == 'false' for file
@@ -564,8 +564,8 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
564564
//wait for all resource deltas
565565
// Thread.sleep(500);
566566
waitForCharsetManagerJob();
567-
assertExistsInWorkspace("4.1", regularPrefs);
568-
assertDoesNotExistInWorkspace("4.2", derivedPrefs);
567+
assertExistsInWorkspace(regularPrefs);
568+
assertDoesNotExistInWorkspace(derivedPrefs);
569569

570570
//5 - moving file to derived folder
571571
IFile source = project1.getFolder("a1").getFile("a.txt");
@@ -578,10 +578,10 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
578578
waitForCharsetManagerJob();
579579
assertTrue("5.1", backgroundVerifier.waitForAllDeltas(10000, 15000));
580580
backgroundVerifier.assertExpectedDeltasWereReceived("5.2");
581-
assertExistsInWorkspace("5.3", regularPrefs);
582-
assertExistsInWorkspace("5.4", derivedPrefs);
583-
assertDoesNotExistInWorkspace("5.5", source);
584-
assertExistsInWorkspace("5.6", destination);
581+
assertExistsInWorkspace(regularPrefs);
582+
assertExistsInWorkspace(derivedPrefs);
583+
assertDoesNotExistInWorkspace(source);
584+
assertExistsInWorkspace(destination);
585585
assertTrue("5.7", derivedPrefs.isDerived());
586586
assertCharsetIs("5.8", "UTF-8", new IResource[] { a }, true);
587587

@@ -595,8 +595,8 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
595595
assertTrue("6.1.2", backgroundVerifier.waitForFirstDelta(10000));
596596
assertTrue("6.2.1 " + verifier.getMessage(), verifier.isDeltaValid());
597597
backgroundVerifier.assertExpectedDeltasWereReceived("6.2.2");
598-
assertExistsInWorkspace("6.3", regularPrefs);
599-
assertDoesNotExistInWorkspace("6.4", derivedPrefs);
598+
assertExistsInWorkspace(regularPrefs);
599+
assertDoesNotExistInWorkspace(derivedPrefs);
600600

601601
//7 - setting preference on project with derived files
602602
verifier.reset();
@@ -608,8 +608,8 @@ public void testBug207510() throws CoreException, InterruptedException, BackingS
608608
assertTrue("7.1.2", backgroundVerifier.waitForFirstDelta(10000));
609609
assertTrue("7.2.1 " + verifier.getMessage(), verifier.isDeltaValid());
610610
backgroundVerifier.assertExpectedDeltasWereReceived("7.2.2");
611-
assertExistsInWorkspace("7.3", regularPrefs);
612-
assertExistsInWorkspace("7.4", derivedPrefs);
611+
assertExistsInWorkspace(regularPrefs);
612+
assertExistsInWorkspace(derivedPrefs);
613613
assertTrue("7.5", isDerivedEncodingStoredSeparately(project1));
614614
assertTrue("7.6", derivedPrefs.isDerived());
615615

@@ -846,7 +846,7 @@ public void testClosingAndReopeningProject() throws CoreException {
846846
// now reopen the project and ensure the settings were not forgotten
847847
IProject projectB = workspace.getRoot().getProject(project.getName());
848848
projectB.open(null);
849-
assertExistsInWorkspace("0.9", getResourcesPreferenceFile(projectB, false));
849+
assertExistsInWorkspace(getResourcesPreferenceFile(projectB, false));
850850
assertEquals("1.0", "FOO", projectB.getDefaultCharset());
851851
assertEquals("3.0", "FRED", projectB.getFile("file1.txt").getCharset());
852852
assertEquals("2.0", "BAR", projectB.getFolder("folder").getDefaultCharset());
@@ -1255,19 +1255,19 @@ public void testFileCreation() throws CoreException {
12551255
IFile file1 = project.getFile("file1.txt");
12561256
IFile file2 = folder.getFile("file2.txt");
12571257
ensureExistsInWorkspace(new IResource[] {file1, file2}, true);
1258-
assertExistsInWorkspace("1.0", getResourcesPreferenceFile(project, false));
1258+
assertExistsInWorkspace(getResourcesPreferenceFile(project, false));
12591259
project.setDefaultCharset("FOO", getMonitor());
1260-
assertExistsInWorkspace("2.0", getResourcesPreferenceFile(project, false));
1260+
assertExistsInWorkspace(getResourcesPreferenceFile(project, false));
12611261
project.setDefaultCharset(null, getMonitor());
1262-
assertDoesNotExistInWorkspace("3.0", getResourcesPreferenceFile(project, false));
1262+
assertDoesNotExistInWorkspace(getResourcesPreferenceFile(project, false));
12631263
file1.setCharset("FRED", getMonitor());
1264-
assertExistsInWorkspace("4.0", getResourcesPreferenceFile(project, false));
1264+
assertExistsInWorkspace(getResourcesPreferenceFile(project, false));
12651265
folder.setDefaultCharset("BAR", getMonitor());
1266-
assertExistsInWorkspace("5.0", getResourcesPreferenceFile(project, false));
1266+
assertExistsInWorkspace(getResourcesPreferenceFile(project, false));
12671267
file1.setCharset(null, getMonitor());
1268-
assertExistsInWorkspace("6.0", getResourcesPreferenceFile(project, false));
1268+
assertExistsInWorkspace(getResourcesPreferenceFile(project, false));
12691269
folder.setDefaultCharset(null, getMonitor());
1270-
assertDoesNotExistInWorkspace("7.0", getResourcesPreferenceFile(project, false));
1270+
assertDoesNotExistInWorkspace(getResourcesPreferenceFile(project, false));
12711271
} finally {
12721272
clearAllEncodings(project);
12731273
}
@@ -1370,15 +1370,15 @@ public void testNonExistingResource() throws CoreException {
13701370
ensureExistsInWorkspace(project, true);
13711371
project.setDefaultCharset("FOO", getMonitor());
13721372
IFile file = project.getFile("file.xml");
1373-
assertDoesNotExistInWorkspace("2.0", file);
1373+
assertDoesNotExistInWorkspace(file);
13741374
assertEquals("2.2", "FOO", file.getCharset());
13751375
e = assertThrows(CoreException.class, () -> file.setCharset("BAR", getMonitor()));
13761376
assertEquals("file should not exist yet", IResourceStatus.RESOURCE_NOT_FOUND, e.getStatus().getCode());
13771377
ensureExistsInWorkspace(file, true);
13781378
file.setCharset("BAR", getMonitor());
13791379
assertEquals("2.8", "BAR", file.getCharset());
13801380
file.delete(IResource.NONE, null);
1381-
assertDoesNotExistInWorkspace("2.10", file);
1381+
assertDoesNotExistInWorkspace(file);
13821382
assertEquals("2.11", "FOO", file.getCharset());
13831383
} finally {
13841384
clearAllEncodings(project);

0 commit comments

Comments
 (0)