Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createInFileSystem;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createInputStream;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -30,14 +30,17 @@
import org.eclipse.core.internal.utils.UniversalUniqueIdentifier;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.eclipse.core.tests.resources.util.FileStoreAutoDeleteExtension;
import org.eclipse.core.tests.resources.util.WorkspaceResetExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

@ExtendWith(WorkspaceResetExtension.class)
public class BlobStoreTest {

@Rule
public WorkspaceTestRule workspaceRule = new WorkspaceTestRule();
@RegisterExtension
private final FileStoreAutoDeleteExtension fileStoreExtension = new FileStoreAutoDeleteExtension();

@Test
public void testConstructor() throws CoreException {
Expand All @@ -63,11 +66,11 @@ public void testConstructor() throws CoreException {
}

private IFileStore createStore() throws CoreException {
IFileStore root = workspaceRule.getTempStore();
IFileStore root = fileStoreExtension.getTempStore();
root.mkdir(EFS.NONE, null);
IFileInfo info = root.fetchInfo();
assertTrue("createStore.1", info.exists());
assertTrue("createStore.2", info.isDirectory());
assertTrue(info.exists());
assertTrue(info.isDirectory());
return root;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.core.tests.harness.FileSystemHelper.getRandomLocation;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createInWorkspace;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.DataInputStream;
import java.io.DataOutputStream;
Expand All @@ -39,14 +39,17 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.eclipse.core.tests.resources.util.FileStoreAutoDeleteExtension;
import org.eclipse.core.tests.resources.util.WorkspaceResetExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

@ExtendWith(WorkspaceResetExtension.class)
public class BucketTreeTests {

@Rule
public WorkspaceTestRule workspaceRule = new WorkspaceTestRule();
@RegisterExtension
private final FileStoreAutoDeleteExtension fileStoreExtension = new FileStoreAutoDeleteExtension();

static class SimpleBucket extends Bucket {

Expand Down Expand Up @@ -147,7 +150,7 @@ protected void writeEntryValue(DataOutputStream destination, Object entryValue)
@Test
public void testVisitor() throws CoreException {
IPath baseLocation = getRandomLocation();
workspaceRule.deleteOnTearDown(baseLocation);
fileStoreExtension.deleteOnTearDown(baseLocation);

// keep the reference around - it is the same returned by tree.getCurrent()
SimpleBucket bucket = new SimpleBucket();
Expand All @@ -166,62 +169,62 @@ public void testVisitor() throws CoreException {
bucket.set(path, "segments", Integer.toString(path.segmentCount()));
}
bucket.save();
verify(tree, "1.1", IPath.ROOT, BucketTree.DEPTH_ZERO, Set.of(IPath.ROOT));
verify(tree, "1.2", IPath.ROOT, BucketTree.DEPTH_ONE,
verify(tree, IPath.ROOT, BucketTree.DEPTH_ZERO, Set.of(IPath.ROOT));
verify(tree, IPath.ROOT, BucketTree.DEPTH_ONE,
Set.of(IPath.ROOT, proj1.getFullPath(), proj2.getFullPath()));
verify(tree, "1.3", IPath.ROOT, BucketTree.DEPTH_INFINITE, Set.of(IPath.ROOT, proj1.getFullPath(),
verify(tree, IPath.ROOT, BucketTree.DEPTH_INFINITE, Set.of(IPath.ROOT, proj1.getFullPath(),
file1.getFullPath(), folder1.getFullPath(), file2.getFullPath(), proj2.getFullPath()));
verify(tree, "2.1", proj1.getFullPath(), BucketTree.DEPTH_ZERO,
verify(tree, proj1.getFullPath(), BucketTree.DEPTH_ZERO,
Arrays.asList(new IPath[] { proj1.getFullPath() }));
verify(tree, "2.2", proj1.getFullPath(), BucketTree.DEPTH_ONE,
verify(tree, proj1.getFullPath(), BucketTree.DEPTH_ONE,
Arrays.asList(new IPath[] { proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath() }));
verify(tree, "2.3", proj1.getFullPath(), BucketTree.DEPTH_INFINITE, Arrays.asList(
verify(tree, proj1.getFullPath(), BucketTree.DEPTH_INFINITE, Arrays.asList(
new IPath[] { proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath(), file2.getFullPath() }));
verify(tree, "3.1", file1.getFullPath(), BucketTree.DEPTH_ZERO,
verify(tree, file1.getFullPath(), BucketTree.DEPTH_ZERO,
Arrays.asList(new IPath[] { file1.getFullPath() }));
verify(tree, "3.2", file1.getFullPath(), BucketTree.DEPTH_ONE,
verify(tree, file1.getFullPath(), BucketTree.DEPTH_ONE,
Arrays.asList(new IPath[] { file1.getFullPath() }));
verify(tree, "3.3", file1.getFullPath(), BucketTree.DEPTH_INFINITE,
verify(tree, file1.getFullPath(), BucketTree.DEPTH_INFINITE,
Arrays.asList(new IPath[] { file1.getFullPath() }));
verify(tree, "4.1", folder1.getFullPath(), BucketTree.DEPTH_ZERO,
verify(tree, folder1.getFullPath(), BucketTree.DEPTH_ZERO,
Arrays.asList(new IPath[] { folder1.getFullPath() }));
verify(tree, "4.2", folder1.getFullPath(), BucketTree.DEPTH_ONE,
verify(tree, folder1.getFullPath(), BucketTree.DEPTH_ONE,
Arrays.asList(new IPath[] { folder1.getFullPath(), file2.getFullPath() }));
verify(tree, "4.3", folder1.getFullPath(), BucketTree.DEPTH_INFINITE,
verify(tree, folder1.getFullPath(), BucketTree.DEPTH_INFINITE,
Arrays.asList(new IPath[] { folder1.getFullPath(), file2.getFullPath() }));
verify(tree, "5.1", file2.getFullPath(), BucketTree.DEPTH_ZERO,
verify(tree, file2.getFullPath(), BucketTree.DEPTH_ZERO,
Arrays.asList(new IPath[] { file2.getFullPath() }));
verify(tree, "5.2", file2.getFullPath(), BucketTree.DEPTH_ONE,
verify(tree, file2.getFullPath(), BucketTree.DEPTH_ONE,
Arrays.asList(new IPath[] { file2.getFullPath() }));
verify(tree, "5.3", file2.getFullPath(), BucketTree.DEPTH_INFINITE,
verify(tree, file2.getFullPath(), BucketTree.DEPTH_INFINITE,
Arrays.asList(new IPath[] { file2.getFullPath() }));
verify(tree, "6.1", proj2.getFullPath(), BucketTree.DEPTH_ZERO,
verify(tree, proj2.getFullPath(), BucketTree.DEPTH_ZERO,
Arrays.asList(new IPath[] { proj2.getFullPath() }));
verify(tree, "6.2", proj2.getFullPath(), BucketTree.DEPTH_ONE,
verify(tree, proj2.getFullPath(), BucketTree.DEPTH_ONE,
Arrays.asList(new IPath[] { proj2.getFullPath() }));
verify(tree, "6.3", proj2.getFullPath(), BucketTree.DEPTH_INFINITE,
verify(tree, proj2.getFullPath(), BucketTree.DEPTH_INFINITE,
Arrays.asList(new IPath[] { proj2.getFullPath() }));
}

public void verify(BucketTree tree, final String tag, IPath root, int depth, final Collection<IPath> expected)
public void verify(BucketTree tree, IPath root, int depth, final Collection<IPath> expected)
throws CoreException {
final Set<IPath> visited = new HashSet<>();
SimpleBucket.Visitor verifier = new SimpleBucket.Visitor() {
@Override
public int visit(org.eclipse.core.internal.localstore.Bucket.Entry entry) {
SimpleBucket.SimpleEntry simple = (SimpleBucket.SimpleEntry) entry;
IPath path = simple.getPath();
assertTrue(tag + ".0 " + path, expected.contains(path));
assertTrue(expected.contains(path), path.toString());
visited.add(path);
assertEquals(tag + ".1 " + path, path.toString(), simple.getProperty("path"));
assertEquals(tag + ".2 " + path, Integer.toString(path.segmentCount()), simple.getProperty("segments"));
assertEquals(path.toString(), simple.getProperty("path"), path.toString());
assertEquals(Integer.toString(path.segmentCount()), simple.getProperty("segments"), path.toString());
return CONTINUE;
}
};
tree.accept(verifier, root, depth);
assertEquals(tag + ".4", expected.size(), visited.size());
assertEquals(expected.size(), visited.size());
for (IPath path : expected) {
assertTrue(tag + ".5 " + path, visited.contains(path));
assertTrue(visited.contains(path), path.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import static org.eclipse.core.tests.resources.ResourceTestUtil.createInWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createRandomContentsStream;
import static org.eclipse.core.tests.resources.ResourceTestUtil.removeFromFileSystem;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import org.eclipse.core.internal.resources.Workspace;
Expand All @@ -30,16 +30,14 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.eclipse.core.tests.resources.util.WorkspaceResetExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.Executable;

@ExtendWith(WorkspaceResetExtension.class)
public class CaseSensitivityTest {

@Rule
public WorkspaceTestRule workspaceRule = new WorkspaceTestRule();

private final boolean isCaseSensitive = Workspace.caseSensitive;

@Test
Expand All @@ -53,12 +51,12 @@ public void testCreateProjects() throws Throwable {

// create a second project; should fail because has same name with different casing
IProject project2 = getWorkspace().getRoot().getProject(projectName.toUpperCase());
ThrowingRunnable projectCreation = () -> {
Executable projectCreation = () -> {
project2.create(null);
project2.open(null);
};
if (isCaseSensitive) {
projectCreation.run();
projectCreation.execute();
} else {
assertThrows(CoreException.class, projectCreation);
}
Expand All @@ -76,9 +74,9 @@ public void testCreateFolders() throws Throwable {

// create a second folder; should fail because has same name with different casing
IFolder folder2 = project.getFolder(folderName.toUpperCase());
ThrowingRunnable folderCreation = () -> folder2.create(true, true, null);
Executable folderCreation = () -> folder2.create(true, true, null);
if (isCaseSensitive) {
folderCreation.run();
folderCreation.execute();
} else {
assertThrows(CoreException.class, folderCreation);
}
Expand All @@ -100,9 +98,9 @@ public void testCreateFiles() throws Throwable {

// create a second file; should fail because has same name with different casing
IFile file2 = project.getFile(fileName.toUpperCase());
ThrowingRunnable fileCreation = () -> file2.create(createRandomContentsStream(), true, null);
Executable fileCreation = () -> file2.create(createRandomContentsStream(), true, null);
if (isCaseSensitive) {
fileCreation.run();
fileCreation.execute();
} else {
assertThrows(CoreException.class, fileCreation);
}
Expand All @@ -127,10 +125,10 @@ public void testRenameProject() throws Throwable {
project2.open(null);

// try to rename project 1 to the uppercase name of project 2, should fail
ThrowingRunnable projectMovement = () -> project1.move(IPath.ROOT.append(project2.getName().toUpperCase()),
Executable projectMovement = () -> project1.move(IPath.ROOT.append(project2.getName().toUpperCase()),
true, null);
if (isCaseSensitive) {
projectMovement.run();
projectMovement.execute();
} else {
assertThrows(CoreException.class, projectMovement);
}
Expand All @@ -153,9 +151,9 @@ public void testRenameFolder() throws Throwable {

// try to rename folder 1 to the uppercase name of folder 2, should fail
IFolder folder3 = project.getFolder(folder2name.toUpperCase());
ThrowingRunnable folderMovement = () -> folder1.move(folder3.getFullPath(), true, null);
Executable folderMovement = () -> folder1.move(folder3.getFullPath(), true, null);
if (isCaseSensitive) {
folderMovement.run();
folderMovement.execute();
} else {
assertThrows(CoreException.class, folderMovement);
}
Expand All @@ -178,9 +176,9 @@ public void testRenameFile() throws Throwable {

// try to rename folder 1 to the uppercase name of folder 2, should fail
IFile file3 = project.getFile(file2name.toUpperCase());
ThrowingRunnable fileMovement = () -> file1.move(file3.getFullPath(), true, null);
Executable fileMovement = () -> file1.move(file3.getFullPath(), true, null);
if (isCaseSensitive) {
fileMovement.run();
fileMovement.execute();
} else {
assertThrows(CoreException.class, fileMovement);
}
Expand All @@ -203,10 +201,10 @@ public void testCopyAndMoveFolder() throws Throwable {

// try to copy the folder from source project to destination project.
// should fail due to conflict
ThrowingRunnable folderCopy = () -> folder1.copy(destinationProject.getFullPath().append(folder1.getName()),
Executable folderCopy = () -> folder1.copy(destinationProject.getFullPath().append(folder1.getName()),
true, null);
if (isCaseSensitive) {
folderCopy.run();
folderCopy.execute();
} else {
assertThrows(CoreException.class, folderCopy);
}
Expand Down Expand Up @@ -234,10 +232,10 @@ public void testCopyAndMoveFile() throws Throwable {

// try to copy the file from source project to destination project.
// should fail due to conflict
ThrowingRunnable fileCopy = () -> file1.copy(destinationProject.getFullPath().append(file1.getName()), true,
Executable fileCopy = () -> file1.copy(destinationProject.getFullPath().append(file1.getName()), true,
null);
if (isCaseSensitive) {
fileCopy.run();
fileCopy.execute();
} else {
assertThrows(CoreException.class, fileCopy);
}
Expand Down Expand Up @@ -265,10 +263,10 @@ public void testCopyAndMoveFolderOverFile() throws Throwable {

// try to copy the folder from source project to destination project.
// should fail due to conflict with existing file with case-different name
ThrowingRunnable folderCopy = () -> folder.copy(destinationProject.getFullPath().append(folder.getName()), true,
Executable folderCopy = () -> folder.copy(destinationProject.getFullPath().append(folder.getName()), true,
null);
if (isCaseSensitive) {
folderCopy.run();
folderCopy.execute();
} else {
assertThrows(CoreException.class, folderCopy);
}
Expand Down Expand Up @@ -296,10 +294,10 @@ public void testCopyAndMoveFileOverFolder() throws Throwable {

// try to copy the file from source project to destination project.
// should fail due to conflict with existing folder with case-different name
ThrowingRunnable fileCopy = () -> file.copy(destinationProject.getFullPath().append(file.getName()), true,
Executable fileCopy = () -> file.copy(destinationProject.getFullPath().append(file.getName()), true,
null);
if (isCaseSensitive) {
fileCopy.run();
fileCopy.execute();
} else {
assertThrows(CoreException.class, fileCopy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import static org.eclipse.core.tests.resources.ResourceTestUtil.createInWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.removeFromFileSystem;
import static org.eclipse.core.tests.resources.ResourceTestUtil.removeFromWorkspace;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
Expand All @@ -30,20 +30,18 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.eclipse.core.tests.resources.util.WorkspaceResetExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Test the copy operation.
*/
@ExtendWith(WorkspaceResetExtension.class)
public class CopyTest {

private static final int NUMBER_OF_PROPERTIES = 5;

@Rule
public WorkspaceTestRule workspaceRule = new WorkspaceTestRule();

@Test
public void testCopyResource() throws Throwable {
IProject project = getWorkspace().getRoot().getProject("Project");
Expand Down
Loading
Loading