Skip to content

Commit

Permalink
Provide unique strings for resource tests via utility class eclipse-p…
Browse files Browse the repository at this point in the history
…latform#903

The getUniqueString() method in CoreTest is actually a factory method
creating a unique string upon each call. It is not tied to an instance
of CoreTest. This change adds an according method with a name indicating
the creation behavior to the ResourceTestUtil and updates calls to that
method within the resource tests. This is part of the cleanup for the
ResourceTest inheritance hierarchy in order to migrate to JUnit 4.

Contributes to
eclipse-platform#903
  • Loading branch information
HeikoKlare committed Dec 6, 2023
1 parent c970847 commit b92af67
Show file tree
Hide file tree
Showing 37 changed files with 285 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.eclipse.core.tests.resources.ResourceTestUtil.assertDoesNotExistInWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.assertExistsInWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createTestMonitor;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createUniqueString;
import static org.eclipse.core.tests.resources.ResourceTestUtil.waitForRefresh;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThrows;
Expand Down Expand Up @@ -264,7 +265,7 @@ public void testBug198571() throws CoreException {
String[] devices = findAvailableDevices();
Assume.assumeFalse(devices[0] == null || devices[1] == null);

String location = getUniqueString();
String location = createUniqueString();
IProject testProject1 = getWorkspace().getRoot().getProject(location + "1");
IProject testProject2 = getWorkspace().getRoot().getProject(location + "2");

Expand Down Expand Up @@ -402,8 +403,8 @@ public void testBug256837() throws CoreException {
aliasManager.startup(null);

IWorkspaceRoot root = getWorkspace().getRoot();
IProject p1 = root.getProject(getUniqueString());
IProject p2 = root.getProject(getUniqueString());
IProject p1 = root.getProject(createUniqueString());
IProject p2 = root.getProject(createUniqueString());
ensureExistsInWorkspace(new IResource[] {p1, p2}, true);

IFileStore tempStore = getTempStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.core.tests.internal.localstore;

import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createUniqueString;
import static org.eclipse.core.tests.resources.ResourceTestUtil.waitForRefresh;
import static org.junit.Assert.assertThrows;

Expand Down Expand Up @@ -48,7 +49,7 @@ public class FileSystemResourceManagerTest extends LocalStoreTest implements ICo

@Test
public void testBug440110() throws Exception {
String projectName = getUniqueString();
String projectName = createUniqueString();
IWorkspace workspace = getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
IProjectDescription projectDescription = workspace.newProjectDescription(projectName);
Expand Down Expand Up @@ -401,7 +402,7 @@ public void testWriteProject() throws CoreException {
*/
@Test
public void testBug547691() throws CoreException {
String projectName = getUniqueString();
String projectName = createUniqueString();
IWorkspace workspace = getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
IProjectDescription projectDescription = workspace.newProjectDescription(projectName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.eclipse.core.tests.resources.ResourceTestUtil.assertExistsInFileSystem;
import static org.eclipse.core.tests.resources.ResourceTestUtil.assertExistsInWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createTestMonitor;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createUniqueString;
import static org.junit.Assert.assertThrows;

import org.eclipse.core.internal.resources.File;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void testMoveFileAcrossVolumes() throws CoreException {
Assume.assumeFalse(devices[0] == null || devices[1] == null);

// create common objects
String location = getUniqueString();
String location = createUniqueString();
IProject source = getWorkspace().getRoot().getProject(location + "1");
IProject destination = getWorkspace().getRoot().getProject(location + "2");
source.create(createTestMonitor());
Expand Down Expand Up @@ -162,7 +163,7 @@ public void testMoveFolderAcrossVolumes() throws CoreException {
Assume.assumeFalse(devices[0] == null || devices[1] == null);

// create common objects
String location = getUniqueString();
String location = createUniqueString();
IProject source = getWorkspace().getRoot().getProject(location + "1");
IProject destination = getWorkspace().getRoot().getProject(location + "2");
source.create(createTestMonitor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createTestMonitor;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createUniqueString;

import java.io.ByteArrayInputStream;
import java.io.File;
Expand Down Expand Up @@ -272,7 +273,7 @@ public void test342968() throws CoreException {
}

public void test368376() throws CoreException, IOException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getUniqueString());
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(createUniqueString());
ensureExistsInWorkspace(project, true);

String filePath = "a/b/c/file.txt";
Expand Down
Loading

0 comments on commit b92af67

Please sign in to comment.