Skip to content
Open
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -21,6 +21,7 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.io.File;
import java.net.URI;
Expand Down Expand Up @@ -71,56 +72,56 @@ public void tearDown() throws Exception {
public void testParentExistsDeep() throws Exception {
topDir.mkdir(EFS.NONE, getMonitor());
IFileInfo info = topDir.fetchInfo();
assertTrue("1.1", info.exists());
assertTrue("1.2", info.isDirectory());
assertTrue(info.exists());
assertTrue(info.isDirectory());
}

@Test
public void testParentExistsShallow() throws Exception {
topDir.mkdir(EFS.SHALLOW, getMonitor());
IFileInfo info = topDir.fetchInfo();
assertTrue("2.1", info.exists());
assertTrue("2.2", info.isDirectory());
assertTrue(info.exists());
assertTrue(info.isDirectory());
}

@Test
public void testParentFileDeep() throws Exception {
ensureExists(file, false);
assertThrows(CoreException.class, () -> subFile.mkdir(EFS.NONE, getMonitor()));
IFileInfo info = subFile.fetchInfo();
assertTrue("2.1", !info.exists());
assertTrue("2.2", !info.isDirectory());
assertFalse(info.exists());
assertFalse(info.isDirectory());
}

@Test
public void testParentFileShallow() throws Exception {
ensureExists(file, false);
assertThrows(CoreException.class, () -> subFile.mkdir(EFS.SHALLOW, getMonitor()));
IFileInfo info = subFile.fetchInfo();
assertTrue("2.1", !info.exists());
assertTrue("2.2", !info.isDirectory());
assertFalse(info.exists());
assertFalse(info.isDirectory());
}

@Test
public void testParentNotExistsDeep() throws Exception {
subDir.mkdir(EFS.NONE, getMonitor());
IFileInfo info = topDir.fetchInfo();
assertTrue("1.1", info.exists());
assertTrue("1.2", info.isDirectory());
assertTrue(info.exists());
assertTrue(info.isDirectory());
info = subDir.fetchInfo();
assertTrue("1.3", info.exists());
assertTrue("1.4", info.isDirectory());
assertTrue(info.exists());
assertTrue(info.isDirectory());
}

@Test
public void testParentNotExistsShallow() {
assertThrows(CoreException.class, () -> subDir.mkdir(EFS.SHALLOW, getMonitor()));
IFileInfo info = topDir.fetchInfo();
assertTrue("1.1", !info.exists());
assertTrue("1.2", !info.isDirectory());
assertFalse(info.exists());
assertFalse(info.isDirectory());
info = subDir.fetchInfo();
assertTrue("1.3", !info.exists());
assertTrue("1.4", !info.isDirectory());
assertFalse(info.exists());
assertFalse(info.isDirectory());
}

@Test
Expand All @@ -131,8 +132,8 @@ public void testParentNotExistsShallowInLocalFile() throws CoreException {
IFileStore localFileTopDir = localFileBaseStore.getChild("topDir");
localFileTopDir.mkdir(EFS.SHALLOW, getMonitor());
});
assertNotNull("1.1", e.getStatus());
assertEquals("1.2", EFS.ERROR_NOT_EXISTS, e.getStatus().getCode());
assertNotNull(e.getStatus());
assertEquals(EFS.ERROR_NOT_EXISTS, e.getStatus().getCode());
}

@Test
Expand All @@ -144,10 +145,10 @@ public void testTargetIsFileInLocalFile() throws Exception {
IFileStore localFileTopDir = localFileBaseStore.getChild("topDir");
ensureExists(localFileTopDir, false);
localFileTopDir.mkdir(EFS.SHALLOW, getMonitor());
fail("1.99");
fail("Should not be reached");
});
assertNotNull("1.1", e.getStatus());
assertEquals("1.2", EFS.ERROR_WRONG_TYPE, e.getStatus().getCode());
assertNotNull(e.getStatus());
assertEquals(EFS.ERROR_WRONG_TYPE, e.getStatus().getCode());
}

@Test
Expand All @@ -160,14 +161,13 @@ public void testParentDeviceNotExistsInLocalFile() {
return;
}

try {
CoreException e = assertThrows(CoreException.class, () -> {
IFileStore localFileTopDir = EFS.getStore(URI.create("file:/" + device + ":" + UUID.randomUUID()));
localFileTopDir.mkdir(EFS.SHALLOW, getMonitor());
fail("1.99");
} catch (CoreException e) {
assertNotNull("1.1", e.getStatus());
assertEquals("1.2", EFS.ERROR_WRITE, e.getStatus().getCode());
}
fail("Should not be reached");
});
assertNotNull(e.getStatus());
assertEquals(EFS.ERROR_WRITE, e.getStatus().getCode());
}

private String findNonExistingDevice() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -41,9 +41,9 @@ public void testDeleteFile() throws Exception {
IFileStore file = baseStore.getChild("child");
ensureExists(file, false);

assertTrue("1.0", file.fetchInfo().exists());
assertTrue(file.fetchInfo().exists());
file.delete(EFS.NONE, getMonitor());
assertTrue("1.1", !file.fetchInfo().exists());
assertFalse(file.fetchInfo().exists());
}

@Test
Expand All @@ -52,9 +52,9 @@ public void testDeleteDirectory() throws Exception {
IFileStore dir = baseStore.getChild("child");
ensureExists(dir, true);

assertTrue("1.0", dir.fetchInfo().exists());
assertTrue(dir.fetchInfo().exists());
dir.delete(EFS.NONE, getMonitor());
assertTrue("1.1", !dir.fetchInfo().exists());
assertFalse(dir.fetchInfo().exists());
}

@Test
Expand All @@ -63,11 +63,11 @@ public void testDeleteReadOnlyFile() throws Exception {
ensureExists(localFileBaseStore, true);
IFileStore file = localFileBaseStore.getChild("child");
ensureExists(file, false);
assertTrue("1.0", file.fetchInfo().exists());
assertTrue(file.fetchInfo().exists());
ensureReadOnlyLocal(file);
file.delete(EFS.NONE, getMonitor());
// success: we expect that read-only files can be removed
assertTrue("1.1", !file.fetchInfo().exists());
assertFalse(file.fetchInfo().exists());
}

/**
Expand All @@ -76,7 +76,7 @@ public void testDeleteReadOnlyFile() throws Exception {
protected void ensureReadOnlyLocal(IFileStore store) throws Exception {
File localFile = store.toLocalFile(0, getMonitor());
boolean readOnly = localFile.setReadOnly();
assertTrue("1.0", readOnly);
assertFalse("1.1", localFile.canWrite());
assertTrue(readOnly);
assertFalse(localFile.canWrite());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2012 IBM Corporation and others.
* Copyright (c) 2006, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -28,14 +28,14 @@ public class EFSTest {
@Test
public void testGetLocalFileSystem() {
IFileSystem system = EFS.getLocalFileSystem();
assertNotNull("1.0", system);
assertEquals("1.1", "file", system.getScheme());
assertNotNull(system);
assertEquals("file", system.getScheme());
}

@Test
public void testGetNullFileSystem() {
IFileSystem system = EFS.getNullFileSystem();
assertNotNull("1.0", system);
assertEquals("1.1", "null", system.getScheme());
assertNotNull(system);
assertEquals("null", system.getScheme());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -17,6 +17,7 @@
import static org.eclipse.core.tests.filesystem.FileSystemTestUtil.getMonitor;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.io.File;
import java.io.OutputStream;
Expand Down Expand Up @@ -53,8 +54,8 @@ public void testCacheFile() throws Exception {
out.write(contents);
}
File cachedFile = store.toLocalFile(EFS.CACHE, getMonitor());
assertTrue("1.0", cachedFile.exists());
assertTrue("1.1", !cachedFile.isDirectory());
assertTrue(cachedFile.exists());
assertFalse(cachedFile.isDirectory());
assertThat(Files.readAllBytes(cachedFile.toPath())).containsExactly(contents);

// write out new file contents
Expand All @@ -68,8 +69,8 @@ public void testCacheFile() throws Exception {

// fetching the cache again should return up to date file
cachedFile = store.toLocalFile(EFS.CACHE, getMonitor());
assertTrue("3.0", cachedFile.exists());
assertTrue("3.1", !cachedFile.isDirectory());
assertTrue(cachedFile.exists());
assertFalse(cachedFile.isDirectory());
assertThat(Files.readAllBytes(cachedFile.toPath())).containsExactly(newContents);
}

Expand All @@ -78,8 +79,8 @@ public void testCacheFolder() throws Exception {
IFileStore store = new MemoryFileStore(IPath.fromOSString("testCacheFolder"));
store.mkdir(EFS.NONE, getMonitor());
File cachedFile = store.toLocalFile(EFS.CACHE, getMonitor());
assertTrue("1.0", cachedFile.exists());
assertTrue("1.1", cachedFile.isDirectory());
assertTrue(cachedFile.exists());
assertTrue(cachedFile.isDirectory());
}

/**
Expand All @@ -90,7 +91,7 @@ public void testNoCacheFlag() throws Exception {
IFileStore store = new MemoryFileStore(IPath.fromOSString("testNoCacheFlag"));
store.mkdir(EFS.NONE, getMonitor());
File cachedFile = store.toLocalFile(EFS.NONE, getMonitor());
assertNull("1.0", cachedFile);
assertNull(cachedFile);
}

/**
Expand All @@ -100,6 +101,6 @@ public void testNoCacheFlag() throws Exception {
public void testNonExisting() throws Exception {
IFileStore store = new MemoryFileStore(IPath.fromOSString("testNonExisting"));
File cachedFile = store.toLocalFile(EFS.CACHE, getMonitor());
assertTrue("1.0", !cachedFile.exists());
assertFalse(cachedFile.exists());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2019 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -19,7 +19,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -57,9 +57,9 @@ public void testAppend() throws Exception {
}
//file should contain two bytes
try (InputStream in = file.openInputStream(EFS.NONE, getMonitor())) {
assertEquals("1.0", BYTE_ONE, in.read());
assertEquals("1.1", BYTE_TWO, in.read());
assertEquals("1.2", EOF, in.read());
assertEquals(BYTE_ONE, in.read());
assertEquals(BYTE_TWO, in.read());
assertEquals(EOF, in.read());
}
}

Expand All @@ -74,8 +74,8 @@ public void testParentExists() throws Exception {
}
final IFileInfo info = file.fetchInfo();
assertExists(file);
assertTrue("1.1", !info.isDirectory());
assertEquals("1.2", file.getName(), info.getName());
assertFalse(info.isDirectory());
assertEquals(file.getName(), info.getName());
}

private static void assertExists(IFileStore store) throws CoreException {
Expand All @@ -96,10 +96,9 @@ public void testParentNotExists() throws CoreException {

assertThrows(CoreException.class, () -> {
file.openOutputStream(EFS.NONE, getMonitor());
fail("1.0");
});
final IFileInfo info = file.fetchInfo();
assertTrue("1.1", !info.exists());
assertTrue("1.2", !info.isDirectory());
assertFalse(info.exists());
assertFalse(info.isDirectory());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -16,6 +16,7 @@
import static org.eclipse.core.tests.filesystem.FileSystemTestUtil.ensureExists;
import static org.eclipse.core.tests.filesystem.FileSystemTestUtil.getMonitor;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
Expand Down Expand Up @@ -50,8 +51,8 @@ public void testSetFileLastModified() throws Exception {
info.setLastModified(newLastModified);
file.putInfo(info, EFS.SET_LAST_MODIFIED, getMonitor());
info = file.fetchInfo();
assertEquals("1.0", newLastModified, info.getLastModified());
assertEquals("1.1", file.getName(), info.getName());
assertEquals(newLastModified, info.getLastModified());
assertEquals(file.getName(), info.getName());
}

@Test
Expand All @@ -63,7 +64,7 @@ public void testSetReadOnly() throws Exception {
info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
file.putInfo(info, EFS.SET_ATTRIBUTES, getMonitor());
info = file.fetchInfo();
assertEquals("1.0", true, info.getAttribute(EFS.ATTRIBUTE_READ_ONLY));
assertEquals("1.1", file.getName(), info.getName());
assertTrue(info.getAttribute(EFS.ATTRIBUTE_READ_ONLY));
assertEquals(file.getName(), info.getName());
}
}
Loading
Loading