diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java index 46f86a52255..0bcf11e23b1 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java @@ -44,11 +44,6 @@ public class FileSystemResourceManagerTest extends LocalStoreTest implements ICoreConstants { - @Override - public String[] defineHierarchy() { - return new String[] {"/Folder1/", "/Folder1/File1", "/Folder1/Folder2/", "/Folder1/Folder2/File2", "/Folder1/Folder2/Folder3/"}; - } - @Test public void testBug440110() throws Exception { String projectName = getUniqueString(); @@ -168,7 +163,8 @@ public void testIsLocal() throws CoreException { final IProject project = projects[0]; // create resources - IResource[] resources = buildResources(project, defineHierarchy()); + IResource[] resources = buildResources(project, new String[] { "/Folder1/", "/Folder1/File1", + "/Folder1/Folder2/", "/Folder1/Folder2/File2", "/Folder1/Folder2/Folder3/" }); ensureExistsInWorkspace(resources, true); ensureDoesNotExistInFileSystem(resources); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java index 34afbc292e8..0a5555a2c5a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java @@ -30,11 +30,6 @@ public void assertExistsInFileSystemWithNoContent(IFile target) { assertTrue(existsInFileSystemWithNoContent(target)); } - @Override - public String[] defineHierarchy() { - return new String[] {"/File1", "/Folder1/", "/Folder1/File1", "/Folder1/Folder2/"}; - } - private boolean existsInFileSystemWithNoContent(IResource resource) { IPath path = resource.getLocation(); return path.toFile().exists() && path.toFile().length() == 0; @@ -48,7 +43,8 @@ public void testProjectDeletion() throws CoreException { TestingSupport.waitForSnapshot(); // create resources - IResource[] resources = buildResources(project, defineHierarchy()); + IResource[] resources = buildResources(project, + new String[] { "/File1", "/Folder1/", "/Folder1/File1", "/Folder1/Folder2/" }); ensureExistsInWorkspace(resources, true); // delete project's default directory diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java index e37481e5579..b110e5716c1 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java @@ -42,11 +42,6 @@ @RunWith(JUnit4.class) public class MoveTest extends LocalStoreTest { - @Override - public String[] defineHierarchy() { - return new String[] {"/", "/file1", "/file2", "/folder1/", "/folder1/file3", "/folder1/file4", "/folder2/", "/folder2/file5", "/folder2/file6", "/folder1/folder3/", "/folder1/folder3/file7", "/folder1/folder3/file8"}; - } - /** * This test has Windows as the target OS. Drives C: and D: should be available. */ @@ -266,7 +261,9 @@ public void testMoveHierarchy() throws Exception { ensureExistsInWorkspace(folderSource, true); // create hierarchy - String[] hierarchy = defineHierarchy(); + String[] hierarchy = new String[] { "/", "/file1", "/file2", "/folder1/", "/folder1/file3", + "/folder1/file4", "/folder2/", "/folder2/file5", "/folder2/file6", "/folder1/folder3/", + "/folder1/folder3/file7", "/folder1/folder3/file8" }; IResource[] resources = buildResources(folderSource, hierarchy); ensureExistsInWorkspace(resources, true); @@ -337,7 +334,9 @@ public void testMoveHierarchyBetweenProjects() throws Exception { ensureExistsInWorkspace(folderSource, true); // build hierarchy - String[] hierarchy = defineHierarchy(); + String[] hierarchy = new String[] { "/", "/file1", "/file2", "/folder1/", "/folder1/file3", "/folder1/file4", + "/folder2/", "/folder2/file5", "/folder2/file6", "/folder1/folder3/", "/folder1/folder3/file7", + "/folder1/folder3/file8" }; IResource[] resources = buildResources(folderSource, hierarchy); ensureExistsInWorkspace(resources, true); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ISynchronizerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ISynchronizerTest.java index 36f972f2840..40abf305bf5 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ISynchronizerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ISynchronizerTest.java @@ -63,15 +63,6 @@ protected void assertEquals(String message, byte[] b1, byte[] b2) { } } - /** - * Return a string array which defines the hierarchy of a tree. - * Folder resources must have a trailing slash. - */ - @Override - public String[] defineHierarchy() { - return new String[] {"/", "1/", "1/1", "1/2/", "1/2/1", "1/2/2/", "2/", "2/1", "2/2/", "2/2/1", "2/2/2/"}; - } - /* * Internal method used for flushing all sync information for a particular resource * and its children. @@ -96,7 +87,9 @@ protected void flushAllSyncInfo(final IResource root) throws CoreException { @Override public void setUp() throws Exception { super.setUp(); - resources = createHierarchy(); + resources = buildResources(getWorkspace().getRoot(), + new String[] { "/", "1/", "1/1", "1/2/", "1/2/1", "1/2/2/", "2/", "2/1", "2/2/", "2/2/1", "2/2/2/" }); + ensureExistsInWorkspace(resources, true); } @Override diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java index 98150603fbd..44aabdb1021 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java @@ -58,9 +58,13 @@ public class IWorkspaceTest extends ResourceTest { - @Override - public String[] defineHierarchy() { - return new String[] {"/", "/Project/", "/Project/Folder/", "/Project/Folder/File",}; + private IResource[] buildResourceHierarchy() throws CoreException { + return buildResources(getWorkspace().getRoot(), + new String[] { "/", "/Project/", "/Project/Folder/", "/Project/Folder/File", }); + } + + private void ensureResourceHierarchyExist() throws CoreException { + ensureExistsInWorkspace(buildResourceHierarchy(), true); } /** @@ -96,7 +100,7 @@ public void testCancelRunnable() { * See also testMultiCopy() */ public void testCopy() throws CoreException { - IResource[] resources = buildResources(); + IResource[] resources = buildResourceHierarchy(); IProject project = (IProject) resources[1]; IFolder folder = (IFolder) resources[2]; IFile file = (IFile) resources[3]; @@ -113,7 +117,7 @@ public void testCopy() throws CoreException { assertThrows(CoreException.class, () -> getWorkspace().copy(new IResource[] { file }, folder.getFullPath(), false, getMonitor())); - createHierarchy(); + ensureResourceHierarchyExist(); //copy to bogus destination assertThrows(CoreException.class, () -> getWorkspace().copy(new IResource[] { file }, @@ -212,7 +216,7 @@ public void testCopy() throws CoreException { * IStatus delete([IResource, boolean, IProgressMonitor) */ public void testDelete() throws CoreException { - IResource[] resources = buildResources(); + IResource[] resources = buildResourceHierarchy(); IProject project = (IProject) resources[1]; IFolder folder = (IFolder) resources[2]; IFile file = (IFile) resources[3]; @@ -221,14 +225,14 @@ public void testDelete() throws CoreException { assertTrue(getWorkspace().delete(new IResource[] {project, folder, file}, false, getMonitor()).isOK()); assertTrue(getWorkspace().delete(new IResource[] {file}, false, getMonitor()).isOK()); assertTrue(getWorkspace().delete(new IResource[] {}, false, getMonitor()).isOK()); - createHierarchy(); + ensureResourceHierarchyExist(); //delete existing resources resources = new IResource[] {file, project, folder}; assertTrue(getWorkspace().delete(resources, false, getMonitor()).isOK()); // assertDoesNotExistInFileSystem(resources); assertDoesNotExistInWorkspace(resources); - createHierarchy(); + ensureResourceHierarchyExist(); resources = new IResource[] {file}; assertTrue(getWorkspace().delete(resources, false, getMonitor()).isOK()); assertDoesNotExistInFileSystem(resources); @@ -238,7 +242,7 @@ public void testDelete() throws CoreException { assertTrue(getWorkspace().delete(resources, false, getMonitor()).isOK()); assertDoesNotExistInFileSystem(resources); assertDoesNotExistInWorkspace(resources); - createHierarchy(); + ensureResourceHierarchyExist(); //delete a combination of existing and non-existent resources IProject fakeProject = getWorkspace().getRoot().getProject("pigment"); @@ -247,7 +251,7 @@ public void testDelete() throws CoreException { assertTrue(getWorkspace().delete(resources, false, getMonitor()).isOK()); // assertDoesNotExistInFileSystem(resources); assertDoesNotExistInWorkspace(resources); - createHierarchy(); + ensureResourceHierarchyExist(); resources = new IResource[] {fakeProject, file}; assertTrue(getWorkspace().delete(resources, false, getMonitor()).isOK()); assertDoesNotExistInFileSystem(resources); @@ -257,7 +261,7 @@ public void testDelete() throws CoreException { assertTrue(getWorkspace().delete(resources, false, getMonitor()).isOK()); // assertDoesNotExistInFileSystem(resources); assertDoesNotExistInWorkspace(resources); - createHierarchy(); + ensureResourceHierarchyExist(); } /** @@ -542,7 +546,7 @@ public void testMove() throws CoreException { */ public void testMultiCopy() throws CoreException { /* create common objects */ - IResource[] resources = buildResources(); + IResource[] resources = buildResourceHierarchy(); IProject project = (IProject) resources[1]; IFolder folder = (IFolder) resources[2]; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java index 245489b56d2..a94633d60b3 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java @@ -170,19 +170,12 @@ public void createProblem(IResource host, int severity) throws CoreException { marker.setAttribute(IMarker.SEVERITY, severity); } - /** - * Return a string array which defines the hierarchy of a tree. - * Folder resources must have a trailing slash. - */ - @Override - public String[] defineHierarchy() { - return new String[] {"/", "1/", "1/1", "1/2/", "1/2/1", "1/2/2/", "2/", "2/1", "2/2/", "2/2/1", "2/2/2/"}; - } - @Override public void setUp() throws Exception { super.setUp(); - resources = createHierarchy(); + resources = buildResources(getWorkspace().getRoot(), + new String[] { "/", "1/", "1/1", "1/2/", "1/2/1", "1/2/2/", "2/", "2/1", "2/2/", "2/2/1", "2/2/2/" }); + ensureExistsInWorkspace(resources, true); // disable autorefresh an wait till that is finished IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectEncodingTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectEncodingTest.java index 13d95b877a3..ed9c3be8e87 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectEncodingTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectEncodingTest.java @@ -235,7 +235,6 @@ private String getExpectedMarkerMessage() { } private void buildAndWaitForBuildFinish() { - buildResources(); waitForBuild(); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java index 05cc3e412b7..dfa1f7b3ed9 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java @@ -265,18 +265,11 @@ public void assertExistsInWorkspace(IResource[] resources, boolean phantom) { } } - /** - * Return a collection of resources the hierarchy defined by defineHeirarchy(). - */ - public IResource[] buildResources() { - return buildResources(getWorkspace().getRoot(), defineHierarchy()); - } - /** * Return a collection of resources for the given hierarchy at * the given root. */ - public IResource[] buildResources(IContainer root, String[] hierarchy) { + public IResource[] buildResources(IContainer root, String[] hierarchy) throws CoreException { IResource[] result = new IResource[hierarchy.length]; for (int i = 0; i < hierarchy.length; i++) { IPath path = IPath.fromOSString(hierarchy[i]); @@ -425,27 +418,6 @@ public void createFileInFileSystem(IPath path, InputStream contents) throws Core } } - public IResource[] createHierarchy() throws CoreException { - IResource[] result = buildResources(); - ensureExistsInWorkspace(result, true); - return result; - } - - /** - * Returns a collection of string paths describing the standard - * resource hierarchy for this test. In the string forms, folders are - * represented as having trailing separators ('/'). All other resources - * are files. It is generally assumed that this hierarchy will be - * inserted under some project structure. - * For example, - *
- * return new String[] {"/", "/1/", "/1/1", "/1/2", "/1/3", "/2/", "/2/1"}; - *- */ - public String[] defineHierarchy() { - return new String[0]; - } - /** * Delete the given resource from the local store. Use the resource * manager to ensure that we have a correct Path -> File mapping. diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java index 9a6b000f6ef..2efca4718ca 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java @@ -32,6 +32,9 @@ * Test suites for {@link org.eclipse.core.internal.resources.PlatformURLResourceConnection} */ public class ResourceURLTest extends ResourceTest { + private final String[] resourcePaths = new String[] { "/", "/1/", "/1/1", "/1/2", "/1/3", "/2/", "/2/1", "/2/2", + "/2/3", "/3/", "/3/1", "/3/2", "/3/3", "/4/", "/5" }; + private static final String CONTENT = "content"; protected static IPath[] interestingPaths; protected static IResource[] interestingResources; @@ -56,18 +59,6 @@ private void checkURL(IResource resource) throws Throwable { assertEquals(metric, file); } - /** - * Returns a collection of string paths describing the standard - * resource hierarchy for this test. In the string forms, folders are - * represented as having trailing separators ('/'). All other resources - * are files. It is generally assumed that this hierarchy will be - * inserted under some solution and project structure. - */ - @Override - public String[] defineHierarchy() { - return new String[] {"/", "/1/", "/1/1", "/1/2", "/1/3", "/2/", "/2/1", "/2/2", "/2/3", "/3/", "/3/1", "/3/2", "/3/3", "/4/", "/5"}; - } - protected IProject getTestProject() { return getWorkspace().getRoot().getProject("testProject"); } @@ -85,7 +76,7 @@ private URL getURL(IResource resource) throws Throwable { } public void testBasicURLs() throws Throwable { - IResource[] resources = buildResources(); + IResource[] resources = buildResources(getWorkspace().getRoot(), resourcePaths); ensureExistsInWorkspace(resources, true); for (IResource resource : resources) { checkURL(resource); @@ -98,7 +89,7 @@ public void testExternalURLs() throws Throwable { desc.setLocation(Platform.getLocation().append("../testproject")); project.create(desc, null); project.open(null); - IResource[] resources = buildResources(project, defineHierarchy()); + IResource[] resources = buildResources(project, resourcePaths); ensureExistsInWorkspace(resources, true); for (IResource resource : resources) { checkURL(resource); @@ -106,7 +97,7 @@ public void testExternalURLs() throws Throwable { } public void testNonExistantURLs() throws Throwable { - IResource[] resources = buildResources(); + IResource[] resources = buildResources(getWorkspace().getRoot(), resourcePaths); for (int i = 1; i < resources.length; i++) { final int index = i; assertThrows(IOException.class, () -> checkURL(resources[index])); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java index 2206374d5b4..fbefd9b78fd 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java @@ -37,18 +37,6 @@ * solution, project, folder and file. */ public class WorkspaceTest extends ResourceTest { - /** - * Returns a collection of string paths describing the standard - * resource hierarchy for this test. In the string forms, folders are - * represented as having trailing separators ('/'). All other resources - * are files. It is generally assumed that this hierarchy will be - * inserted under some solution and project structure. - */ - @Override - public String[] defineHierarchy() { - return new String[] {"/", "/1/", "/1/1", "/1/2", "/1/3", "/2/", "/2/1", "/2/2", "/2/3", "/3/", "/3/1", "/3/2", "/3/3", "/4/", "/5"}; - } - protected IProject getTestProject() { return getWorkspace().getRoot().getProject("testProject"); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchWorkspace.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchWorkspace.java index 695a5399de7..a877dc2824a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchWorkspace.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchWorkspace.java @@ -47,7 +47,6 @@ private void addProblems(final int problemCount) { } } - @Override public String[] defineHierarchy() { //define a hierarchy with NUM_FOLDERS folders, NUM_FILES files. String[] names = new String[NUM_FOLDERS * (FILES_PER_FOLDER + 1)]; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java index 0f56d76279a..13ed88da405 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceVisitor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -40,18 +41,18 @@ private Collection