diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/CreateDirectoryTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/CreateDirectoryTest.java index 1f8e4dfd2f0..f3ed9fd311e 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/CreateDirectoryTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/CreateDirectoryTest.java @@ -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 @@ -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; @@ -71,16 +72,16 @@ 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 @@ -88,8 +89,8 @@ 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 @@ -97,30 +98,30 @@ 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 @@ -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 @@ -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 @@ -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() { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/DeleteTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/DeleteTest.java index c6dab6606ca..44a48f2a083 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/DeleteTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/DeleteTest.java @@ -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 @@ -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 @@ -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 @@ -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()); } /** @@ -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()); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/EFSTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/EFSTest.java index 6b219bebe13..6b6fca672b2 100755 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/EFSTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/EFSTest.java @@ -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 @@ -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()); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java index adf7acd97b6..e500914336e 100755 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java @@ -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 @@ -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; @@ -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 @@ -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); } @@ -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()); } /** @@ -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); } /** @@ -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()); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/OpenOutputStreamTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/OpenOutputStreamTest.java index be4b24ef863..59f84630605 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/OpenOutputStreamTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/OpenOutputStreamTest.java @@ -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 @@ -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; @@ -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()); } } @@ -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 { @@ -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()); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/PutInfoTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/PutInfoTest.java index 695bd176869..7bf5b8edb0e 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/PutInfoTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/PutInfoTest.java @@ -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 @@ -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; @@ -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 @@ -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()); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java index 9c0014fbe4b..dc597df911f 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. + * Copyright (c) 2007, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,6 +15,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.net.URI; import org.eclipse.core.filesystem.EFS; @@ -37,12 +38,12 @@ public void testEquals() { //test that case variants are not equal URI one = new java.io.File("c:\\temp\\test").toURI(); URI two = new java.io.File("c:\\TEMP\\test").toURI(); - assertTrue("1.0", !URIUtil.equals(one, two)); + assertFalse(URIUtil.equals(one, two)); } else { //test that case variants are equal URI one = new java.io.File("c:\\temp\\test").toURI(); URI two = new java.io.File("c:\\TEMP\\test").toURI(); - assertTrue("1.0", URIUtil.equals(one, two)); + assertTrue(URIUtil.equals(one, two)); } } @@ -54,10 +55,10 @@ public void testEquals() { public void testPathToURI() { if (Platform.getOS().equals(Platform.OS_WIN32)) { //path with spaces - assertEquals("1.0", "/c:/temp/with spaces", URIUtil.toURI("c:\\temp\\with spaces").getSchemeSpecificPart()); + assertEquals("/c:/temp/with spaces", URIUtil.toURI("c:\\temp\\with spaces").getSchemeSpecificPart()); } else { //path with spaces - assertEquals("2.0", "/tmp/with spaces", URIUtil.toURI("/tmp/with spaces").getSchemeSpecificPart()); + assertEquals("/tmp/with spaces", URIUtil.toURI("/tmp/with spaces").getSchemeSpecificPart()); } } @@ -67,9 +68,11 @@ public void testPathToURI() { @Test public void testStringToURI() { if (Platform.getOS().equals(Platform.OS_WIN32)) { - assertEquals("1.0", "/c:/temp/with spaces", URIUtil.toURI(IPath.fromOSString("c:\\temp\\with spaces")).getSchemeSpecificPart()); + assertEquals("/c:/temp/with spaces", + URIUtil.toURI(IPath.fromOSString("c:\\temp\\with spaces")).getSchemeSpecificPart()); } else { - assertEquals("1.0", "/tmp/with spaces", URIUtil.toURI(IPath.fromOSString("/tmp/with spaces")).getSchemeSpecificPart()); + assertEquals("/tmp/with spaces", + URIUtil.toURI(IPath.fromOSString("/tmp/with spaces")).getSchemeSpecificPart()); } } @@ -80,16 +83,16 @@ public void testStringToURI() { public void testToPath() throws Exception { // Relative path String pathString = "test/path with/spaces to_file.txt"; - assertEquals("1.0", IPath.fromOSString(pathString), URIUtil.toPath(URIUtil.toURI(pathString, false))); + assertEquals(IPath.fromOSString(pathString), URIUtil.toPath(URIUtil.toURI(pathString, false))); // Absolute path if (Platform.getOS().equals(Platform.OS_WIN32)) { pathString = "c:/test/path with/spaces to_file.txt"; } else { pathString = "/test/path with/spaces to_file.txt"; } - assertEquals("2.0", IPath.fromOSString(pathString), URIUtil.toPath(URIUtil.toURI(pathString))); + assertEquals(IPath.fromOSString(pathString), URIUtil.toPath(URIUtil.toURI(pathString))); // User defined file system - assertEquals("3.0", IPath.fromOSString(pathString), + assertEquals(IPath.fromOSString(pathString), URIUtil.toPath(WrapperFileSystem.getWrappedURI(URIUtil.toURI(pathString)))); } @@ -108,7 +111,7 @@ public void testToURIAbsolute() { IPath path = IPath.fromOSString(pathString); URI uri01 = URIUtil.toURI(path); URI uri02 = URIUtil.toURI(pathString); - assertEquals("1.0", uri01, uri02); + assertEquals(uri01, uri02); } /** @@ -121,9 +124,9 @@ public void testToURIRelative() { IPath path = IPath.fromOSString(pathString); URI uri01 = URIUtil.toURI(path); URI uri02 = URIUtil.toURI(pathString, false); - assertEquals("1.0", uri01, uri02); - assertTrue("1.1", !uri01.isAbsolute()); - assertTrue("1.2", !uri02.isAbsolute()); + assertEquals(uri01, uri02); + assertFalse(uri01.isAbsolute()); + assertFalse(uri02.isAbsolute()); } /** @@ -145,14 +148,14 @@ public void testFromPathToURI() { URI aUri = URIUtil.toURI(aPath); URI rUri = URIUtil.toURI(rPath); - assertEquals("1.0", aPath.toString(), URIUtil.toPath(aUri).toString()); - assertEquals("2.0", rPath.toString(), URIUtil.toPath(rUri).toString()); + assertEquals(aPath.toString(), URIUtil.toPath(aUri).toString()); + assertEquals(rPath.toString(), URIUtil.toPath(rUri).toString()); } @Test public void testBug291323_doubleDotLocationPath() { URI aUri = URIUtil.toURI(".."); URI bUri = URIUtil.toURI(""); - assertEquals("1.0", URIUtil.toPath(bUri).toString(), URIUtil.toPath(aUri).toString()); + assertEquals(URIUtil.toPath(bUri).toString(), URIUtil.toPath(aUri).toString()); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java index 7263687d1ba..51c953327d0 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -131,9 +131,9 @@ public void testTraverseMechanismInFolder() throws Throwable { final IResource resource = node.getResource(); final IFileStore store = ((Resource) resource).getStore(); if (node.existsInFileSystem()) { - assertEquals("1.0", store.fetchInfo().getName(), node.getLocalName()); + assertEquals(store.fetchInfo().getName(), node.getLocalName()); } - assertEquals("1.1", store, node.getStore()); + assertEquals(store, node.getStore()); /* remove from the hash table the resource we're visiting */ set.remove(resource.getLocation().toOSString()); @@ -145,7 +145,7 @@ public void testTraverseMechanismInFolder() throws Throwable { tree.accept(visitor); /* if the hash table is empty, we walked through all resources */ - assertTrue("2.0", set.isEmpty()); + assertTrue(set.isEmpty()); } /** @@ -280,11 +280,11 @@ public void test342968() throws CoreException { IFile rf = link.getFile("fileTest342968.txt"); rf.create(new ByteArrayInputStream("test342968".getBytes()), false, null); - assertTrue("1.0", rf.exists()); + assertTrue(rf.exists()); project.refreshLocal(IResource.DEPTH_INFINITE, null); - assertTrue("2.0", rf.exists()); + assertTrue(rf.exists()); } @Test diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java index ca98510a931..25c8b3a1910 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -242,9 +242,9 @@ public void testOOME() throws Throwable { String hint = "Property cache returned another instance. Same instance is not required but expected. Eiter the Garbage Collector deleted the cache or the cache is not working."; assertSame(hint + "1.2", propValue, manager.getProperty(source, propName)); - assertNotNull("1.3", manager.getProperty(sourceFolder, propName)); + assertNotNull(manager.getProperty(sourceFolder, propName)); assertSame(hint + "1.4", propValue, manager.getProperty(sourceFolder, propName)); - assertNotNull("1.5", manager.getProperty(sourceFile, propName)); + assertNotNull(manager.getProperty(sourceFile, propName)); assertSame(hint + "1.6", propValue, manager.getProperty(sourceFile, propName)); List wastedMemory = new LinkedList<>(); @@ -268,20 +268,20 @@ public void testOOME() throws Throwable { } // the cache is guaranteed to be emptied before OutOfMemoryError: - assertNotNull("2.1", manager.getProperty(source, propName)); - assertEquals("2.2", propValue, manager.getProperty(source, propName)); - assertNotSame("2.3", propValue, manager.getProperty(source, propName)); + assertNotNull(manager.getProperty(source, propName)); + assertEquals(propValue, manager.getProperty(source, propName)); + assertNotSame(propValue, manager.getProperty(source, propName)); - assertNotNull("3.1", manager.getProperty(sourceFolder, propName)); - assertEquals("3.2", propValue, manager.getProperty(sourceFolder, propName)); - assertNotSame("3.3", propValue, manager.getProperty(sourceFolder, propName)); + assertNotNull(manager.getProperty(sourceFolder, propName)); + assertEquals(propValue, manager.getProperty(sourceFolder, propName)); + assertNotSame(propValue, manager.getProperty(sourceFolder, propName)); - assertNotNull("4.1", manager.getProperty(sourceFile, propName)); - assertEquals("4.2", propValue, manager.getProperty(sourceFile, propName)); + assertNotNull(manager.getProperty(sourceFile, propName)); + assertEquals(propValue, manager.getProperty(sourceFile, propName)); // We can not squeeze the active working set. // The cache was emptied but the active Bucket.entries map did survive: - assertSame("4.3", propValue, manager.getProperty(sourceFile, propName)); + assertSame(propValue, manager.getProperty(sourceFile, propName)); } @Test @@ -306,53 +306,53 @@ public void testCopy() throws Throwable { manager.setProperty(sourceFolder, propName, propValue); manager.setProperty(sourceFile, propName, propValue); - assertNotNull("1.1", manager.getProperty(source, propName)); - assertTrue("1.2", manager.getProperty(source, propName).equals(propValue)); - assertNotNull("1.3", manager.getProperty(sourceFolder, propName)); - assertTrue("1.4", manager.getProperty(sourceFolder, propName).equals(propValue)); - assertNotNull("1.5", manager.getProperty(sourceFile, propName)); - assertTrue("1.6", manager.getProperty(sourceFile, propName).equals(propValue)); + assertNotNull(manager.getProperty(source, propName)); + assertTrue(manager.getProperty(source, propName).equals(propValue)); + assertNotNull(manager.getProperty(sourceFolder, propName)); + assertTrue(manager.getProperty(sourceFolder, propName).equals(propValue)); + assertNotNull(manager.getProperty(sourceFile, propName)); + assertTrue(manager.getProperty(sourceFile, propName).equals(propValue)); // do the copy at the project level manager.copy(source, destination, IResource.DEPTH_INFINITE); - assertNotNull("1.7", manager.getProperty(destination, propName)); - assertTrue("1.8", manager.getProperty(destination, propName).equals(propValue)); + assertNotNull(manager.getProperty(destination, propName)); + assertTrue(manager.getProperty(destination, propName).equals(propValue)); - assertNotNull("1.9", manager.getProperty(destFolder, propName)); - assertTrue("1.10", manager.getProperty(destFolder, propName).equals(propValue)); - assertNotNull("1.11", manager.getProperty(destFile, propName)); - assertTrue("1.12", manager.getProperty(destFile, propName).equals(propValue)); + assertNotNull(manager.getProperty(destFolder, propName)); + assertTrue(manager.getProperty(destFolder, propName).equals(propValue)); + assertNotNull(manager.getProperty(destFile, propName)); + assertTrue(manager.getProperty(destFile, propName).equals(propValue)); // do the same thing but copy at the folder level manager.deleteProperties(source, IResource.DEPTH_INFINITE); manager.deleteProperties(destination, IResource.DEPTH_INFINITE); - assertNull("2.0", manager.getProperty(source, propName)); - assertNull("2.1", manager.getProperty(sourceFolder, propName)); - assertNull("2.2", manager.getProperty(sourceFile, propName)); - assertNull("2.3", manager.getProperty(destination, propName)); - assertNull("2.4", manager.getProperty(destFolder, propName)); - assertNull("2.5", manager.getProperty(destFile, propName)); + assertNull(manager.getProperty(source, propName)); + assertNull(manager.getProperty(sourceFolder, propName)); + assertNull(manager.getProperty(sourceFile, propName)); + assertNull(manager.getProperty(destination, propName)); + assertNull(manager.getProperty(destFolder, propName)); + assertNull(manager.getProperty(destFile, propName)); manager.setProperty(sourceFolder, propName, propValue); manager.setProperty(sourceFile, propName, propValue); - assertNotNull("2.6", manager.getProperty(sourceFolder, propName)); - assertTrue("2.7", manager.getProperty(sourceFolder, propName).equals(propValue)); - assertNotNull("2.8", manager.getProperty(sourceFile, propName)); - assertTrue("2.9", manager.getProperty(sourceFile, propName).equals(propValue)); + assertNotNull(manager.getProperty(sourceFolder, propName)); + assertTrue(manager.getProperty(sourceFolder, propName).equals(propValue)); + assertNotNull(manager.getProperty(sourceFile, propName)); + assertTrue(manager.getProperty(sourceFile, propName).equals(propValue)); manager.copy(sourceFolder, destFolder, IResource.DEPTH_INFINITE); - assertNotNull("2.10", manager.getProperty(destFolder, propName)); - assertTrue("2.11", manager.getProperty(destFolder, propName).equals(propValue)); - assertNotNull("2.12", manager.getProperty(destFile, propName)); - assertTrue("2.13", manager.getProperty(destFile, propName).equals(propValue)); + assertNotNull(manager.getProperty(destFolder, propName)); + assertTrue(manager.getProperty(destFolder, propName).equals(propValue)); + assertNotNull(manager.getProperty(destFile, propName)); + assertTrue(manager.getProperty(destFile, propName).equals(propValue)); /* test overwrite */ String newPropValue = "change property value"; manager.setProperty(source, propName, newPropValue); - assertTrue("2.0", manager.getProperty(source, propName).equals(newPropValue)); + assertTrue(manager.getProperty(source, propName).equals(newPropValue)); manager.copy(source, destination, IResource.DEPTH_INFINITE); - assertTrue("2.1", manager.getProperty(destination, propName).equals(newPropValue)); + assertTrue(manager.getProperty(destination, propName).equals(newPropValue)); } @Test @@ -366,10 +366,10 @@ public void testDeleteProperties() throws Throwable { QualifiedName propName = new QualifiedName("eclipse", "prop"); String propValue = "this is the property value"; manager.setProperty(target, propName, propValue); - assertTrue("1.1", manager.getProperty(target, propName).equals(propValue)); + assertTrue(manager.getProperty(target, propName).equals(propValue)); /* delete */ manager.deleteProperties(target, IResource.DEPTH_INFINITE); - assertTrue("1.3", manager.getProperty(target, propName) == null); + assertTrue(manager.getProperty(target, propName) == null); //test deep deletion of project properties IProject source = project; @@ -386,18 +386,18 @@ public void testDeleteProperties() throws Throwable { manager.setProperty(sourceFolder, propName, propValue); manager.setProperty(sourceFile, propName, propValue); - assertNotNull("2.1", manager.getProperty(source, propName)); - assertTrue("2.2", manager.getProperty(source, propName).equals(propValue)); - assertNotNull("2.3", manager.getProperty(sourceFolder, propName)); - assertTrue("2.4", manager.getProperty(sourceFolder, propName).equals(propValue)); - assertNotNull("2.5", manager.getProperty(sourceFile, propName)); - assertTrue("2.6", manager.getProperty(sourceFile, propName).equals(propValue)); + assertNotNull(manager.getProperty(source, propName)); + assertTrue(manager.getProperty(source, propName).equals(propValue)); + assertNotNull(manager.getProperty(sourceFolder, propName)); + assertTrue(manager.getProperty(sourceFolder, propName).equals(propValue)); + assertNotNull(manager.getProperty(sourceFile, propName)); + assertTrue(manager.getProperty(sourceFile, propName).equals(propValue)); //delete properties manager.deleteProperties(source, IResource.DEPTH_INFINITE); - assertNull("3.1", manager.getProperty(source, propName)); - assertNull("3.2", manager.getProperty(sourceFolder, propName)); - assertNull("3.3", manager.getProperty(sourceFile, propName)); + assertNull(manager.getProperty(source, propName)); + assertNull(manager.getProperty(sourceFolder, propName)); + assertNull(manager.getProperty(sourceFile, propName)); } /** @@ -415,10 +415,10 @@ public void testFileRename() throws CoreException { createInWorkspace(file1b); String value = null; value = file1b.getPersistentProperty(key); - assertNull("1.0", value); + assertNull(value); file1a = folder.getFile("file2"); value = file1a.getPersistentProperty(key); - assertEquals("2.0", "value", value); + assertEquals("value", value); } /** @@ -435,10 +435,10 @@ public void testFolderRename() throws CoreException { createInWorkspace(folder1b); String value = null; value = folder1b.getPersistentProperty(key); - assertNull("1.0", value); + assertNull(value); folder1a = project.getFolder("folder2"); value = folder1a.getPersistentProperty(key); - assertEquals("2.0", "value", value); + assertEquals("value", value); } /** @@ -474,11 +474,11 @@ public void testProjectRename() throws CoreException { IProject project1b = root.getProject("proj1"); createInWorkspace(project1b); String value = project1b.getPersistentProperty(key); - assertNull("1.0", value); + assertNull(value); project1a = root.getProject("proj2"); value = project1a.getPersistentProperty(key); - assertEquals("2.0", "value", value); + assertEquals("value", value); } @Test @@ -536,7 +536,7 @@ public void testSimpleUpdate() throws CoreException { // verify for (int i = 0; i < N; i++) { - assertTrue("2.0", target.getPersistentProperty(names[i]).equals(values[i])); + assertTrue(target.getPersistentProperty(names[i]).equals(values[i])); } for (int j = 0; j < 20; j++) { @@ -548,7 +548,7 @@ public void testSimpleUpdate() throws CoreException { // verify for (int i = 0; i < N; i++) { - assertTrue("5.0", target.getPersistentProperty(names[i]).equals(values[i])); + assertTrue(target.getPersistentProperty(names[i]).equals(values[i])); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java index 984be5abea8..66b79e289d2 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 IBM Corporation and others. + * Copyright (c) 2004, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -27,6 +27,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -111,7 +112,7 @@ private String typeCode(Object value) { if (value instanceof String) { return "S"; } - assertTrue("0.0", false); + fail(); return null; } @@ -156,56 +157,56 @@ public void testSimple() throws CoreException { Preferences node = instanceContext.getNode(qualifier); node.put(key, instanceValue); String actual = node.get(key, null); - assertNotNull("1.0", actual); - assertEquals("1.1", instanceValue, actual); + assertNotNull(actual); + assertEquals(instanceValue, actual); // get the value through service searching for (int i = 0; i < contextsWithoutScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithoutScope[i]); - assertNotNull("2.0." + i, actual); - assertEquals("2.1." + i, instanceValue, actual); + assertNotNull("Null Index:" + i, actual); + assertEquals("Not Equal Index:" + i, instanceValue, actual); } for (int i = 0; i < contextsWithScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithScope[i]); - assertNotNull("2.2." + i, actual); - assertEquals("2.3." + i, instanceValue, actual); + assertNotNull("Null Index:" + i, actual); + assertEquals("Not Equal Index:" + i, instanceValue, actual); } // set a preference value in the project scope node = projectContext.getNode(qualifier); node.put(key, projectValue); actual = node.get(key, null); - assertNotNull("3.0", actual); - assertEquals("3.1", projectValue, actual); + assertNotNull(actual); + assertEquals(projectValue, actual); // get the value through service searching for (int i = 0; i < contextsWithoutScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithoutScope[i]); - assertNotNull("4.0." + i, actual); - assertEquals("4.1." + i, instanceValue, actual); + assertNotNull("Null Index:" + i, actual); + assertEquals("Not Equal Index:" + i, instanceValue, actual); } for (int i = 0; i < contextsWithScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithScope[i]); - assertNotNull("4.2." + i, actual); - assertEquals("4.3." + i, projectValue, actual); + assertNotNull("Null Index:" + i, actual); + assertEquals("Not Equal Index:" + i, projectValue, actual); } // remove the project scope value node = projectContext.getNode(qualifier); node.remove(key); actual = node.get(key, null); - assertNull("5.0", actual); + assertNull(actual); // get the value through service searching for (int i = 0; i < contextsWithoutScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithoutScope[i]); - assertNotNull("6.0." + i, actual); - assertEquals("6.1." + i, instanceValue, actual); + assertNotNull("Null Index:" + i, actual); + assertEquals("Not Equal Index:" + i, instanceValue, actual); } for (int i = 0; i < contextsWithScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithScope[i]); - assertNotNull("6.2." + i, actual); - assertEquals("6.3." + i, instanceValue, actual); + assertNotNull("Null Index:" + i, actual); + assertEquals("Not Equal Index:" + i, instanceValue, actual); } // remove the instance value so there is nothing @@ -214,11 +215,11 @@ public void testSimple() throws CoreException { actual = node.get(key, null); for (int i = 0; i < contextsWithoutScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithoutScope[i]); - assertNull("7.0." + i, actual); + assertNull("Not Null Index:" + i, actual); } for (int i = 0; i < contextsWithScope.length; i++) { actual = service.getString(qualifier, key, null, contextsWithScope[i]); - assertNull("7.1." + i, actual); + assertNull("Not Null Index:" + i, actual); } } @@ -236,8 +237,8 @@ public void testListener() throws Exception { Preferences node = projectContext.getNode(qualifier); node.put(key, value); String actual = node.get(key, null); - assertNotNull("1.0", actual); - assertEquals("1.1", value, actual); + assertNotNull(actual); + assertEquals(value, actual); // flush node.flush(); @@ -271,9 +272,9 @@ public void testListener() throws Exception { // validate new settings actual = node.get(key, null); - assertEquals("4.1", value, actual); + assertEquals(value, actual); actual = node.get(newKey, null); - assertEquals("4.2", newValue, actual); + assertEquals(newValue, actual); } /** @@ -292,19 +293,19 @@ public void testProjectDelete() throws Exception { Preferences node = context.getNode(qualifier); Preferences parent = node.parent().parent(); node.put(key, value); - assertEquals("1.0", value, node.get(key, null)); + assertEquals(value, node.get(key, null)); // delete the project project.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, createTestMonitor()); // project pref should not exist - assertTrue("3.0", !parent.nodeExists(project.getName())); + assertFalse(parent.nodeExists(project.getName())); // create a project with the same name createInWorkspace(project); // ensure that the preference value is not set - assertNull("4.0", context.getNode(qualifier).get(key, null)); + assertNull(context.getNode(qualifier).get(key, null)); } /** See bug 91244, bug 93398 and bug 211006. */ @@ -325,19 +326,19 @@ public void testProjectMove() throws Exception { // ensure that preferences for the old project are removed node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); - assertNotNull("2.1", node); - assertTrue("2.2", !node.nodeExists(project1.getName())); + assertNotNull(node); + assertFalse(node.nodeExists(project1.getName())); // ensure preferences are preserved node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); - assertNotNull("2.3", node); - assertTrue("2.4", node.nodeExists(project2.getName())); + assertNotNull(node); + assertTrue(node.nodeExists(project2.getName())); node = node.node(project2.getName()); - assertNotNull("3.1", node); - assertTrue("3.2", node.nodeExists(qualifier)); + assertNotNull(node); + assertTrue(node.nodeExists(qualifier)); node = node.node(qualifier); - assertNotNull("4.1", node); - assertEquals("4.2", value, node.get(key, null)); + assertNotNull(node); + assertEquals(value, node.get(key, null)); } /** @@ -356,8 +357,8 @@ public void test_60925() throws Exception { IFile file = getFileInWorkspace(project, qualifier); // should be nothing in the file system - assertTrue("0.0", !file.exists()); - assertTrue("0.1", !file.getLocation().toFile().exists()); + assertFalse(file.exists()); + assertFalse(file.getLocation().toFile().exists()); // store a preference key/value pair IScopeContext context = new ProjectScope(project); @@ -370,8 +371,8 @@ public void test_60925() throws Exception { node.flush(); // changes should appear in the workspace - assertTrue("2.0", file.exists()); - assertTrue("2.1", file.isSynchronized(IResource.DEPTH_ZERO)); + assertTrue(file.exists()); + assertTrue(file.isSynchronized(IResource.DEPTH_ZERO)); } /** @@ -390,18 +391,18 @@ public void test_55410() throws Exception { String value2 = createUniqueString(); node.put(key1, value1); node.put(key2, value2); - assertEquals("0.8", value1, node.get(key1, null)); - assertEquals("0.9", value2, node.get(key2, null)); + assertEquals(value1, node.get(key1, null)); + assertEquals(value2, node.get(key2, null)); IFile prefsFile = getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES); - assertTrue("1.0", prefsFile.exists()); + assertTrue(prefsFile.exists()); node.flush(); - assertTrue("1.1", prefsFile.exists()); + assertTrue(prefsFile.exists()); Properties props = new Properties(); try (InputStream contents = prefsFile.getContents()) { props.load(contents); } - assertEquals("2.0", value2, props.getProperty("subnode/" + key2)); - assertEquals("2.1", value1, props.getProperty("subnode/" + key1)); + assertEquals(value2, props.getProperty("subnode/" + key2)); + assertEquals(value1, props.getProperty("subnode/" + key1)); } /** @@ -422,7 +423,7 @@ public void test_61277a() throws Exception { String key = createUniqueString(); String value = createUniqueString(); node.put(key, value); - assertEquals("1.0", value, node.get(key, null)); + assertEquals(value, node.get(key, null)); // save the prefs node.flush(); @@ -432,7 +433,7 @@ public void test_61277a() throws Exception { context = new ProjectScope(destProject); node = context.getNode(qualifier); - assertEquals("3.0", value, node.get(key, null)); + assertEquals(value, node.get(key, null)); } /** @@ -447,15 +448,15 @@ public void test_61277b() throws Exception { IProject project2 = getProject(createUniqueString()); createInWorkspace(project1); Preferences node = new ProjectScope(project1).getNode(ResourcesPlugin.PI_RESOURCES); - assertTrue("1.0", getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); node.put("key", "value"); node.flush(); - assertTrue("1.1", getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); // move project and ensures charsets settings are preserved project1.move(project2.getFullPath(), false, null); - assertTrue("2.0", getFileInWorkspace(project2, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project2, ResourcesPlugin.PI_RESOURCES).exists()); node = new ProjectScope(project2).getNode(ResourcesPlugin.PI_RESOURCES); - assertEquals("2.1", "value", node.get("key", null)); + assertEquals("value", node.get("key", null)); } /** @@ -470,7 +471,7 @@ public void test_61277b() throws Exception { public void test_61277c() throws Exception { IProject project1 = getProject(createUniqueString()); createInWorkspace(project1); - assertTrue("1.0", getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); Preferences node = new ProjectScope(project1).getNode(ResourcesPlugin.PI_RESOURCES); String key1 = "key"; String emptyKey = ""; @@ -479,16 +480,16 @@ public void test_61277c() throws Exception { node.put(key1, value1); node.put(emptyKey, value2); node.flush(); - assertTrue("1.2", getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project1, ResourcesPlugin.PI_RESOURCES).exists()); // move project and ensures charsets settings are preserved IProject project2 = getProject(createUniqueString()); project1.move(project2.getFullPath(), false, null); - assertTrue("2.0", getFileInWorkspace(project2, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project2, ResourcesPlugin.PI_RESOURCES).exists()); node = new ProjectScope(project2).getNode(ResourcesPlugin.PI_RESOURCES); - assertEquals("2.1", value1, node.get(key1, null)); - assertEquals("2.2", value2, node.get(emptyKey, null)); + assertEquals(value1, node.get(key1, null)); + assertEquals(value2, node.get(emptyKey, null)); } /* @@ -552,12 +553,12 @@ public void test_65068() throws Exception { String value = createUniqueString(); node.put(key, value); node.flush(); - assertTrue("1.2", getFileInWorkspace(project, ResourcesPlugin.PI_RESOURCES).exists()); + assertTrue(getFileInWorkspace(project, ResourcesPlugin.PI_RESOURCES).exists()); node = new ProjectScope(project).getNode(ResourcesPlugin.PI_RESOURCES); - assertEquals("1.3", value, node.get(key, null)); + assertEquals(value, node.get(key, null)); removeFromWorkspace(project.getFolder(DIR_NAME)); node = new ProjectScope(project).getNode(ResourcesPlugin.PI_RESOURCES); - assertNull("2.0", node.get(key, null)); + assertNull(node.get(key, null)); } /* @@ -573,14 +574,14 @@ public void test_95052() throws Exception { node.put("key3", "value3"); node.flush(); IFile prefFile = getFileInWorkspace(project, ResourcesPlugin.PI_RESOURCES); - assertTrue("1.2", prefFile.exists()); + assertTrue(prefFile.exists()); Properties properties = new Properties(); try (InputStream contents = prefFile.getContents()) { properties.load(contents); } - assertEquals("2.0", "value1", properties.get("key1")); - assertEquals("2.1", "value2", properties.get("key2")); - assertEquals("2.2", "value3", properties.get("key3")); + assertEquals("value1", properties.get("key1")); + assertEquals("value2", properties.get("key2")); + assertEquals("value3", properties.get("key3")); // add a new property properties.put("key0", "value0"); // change an existing property @@ -594,13 +595,13 @@ public void test_95052() throws Exception { // here, project preferences should have caught up with the changes node = new ProjectScope(project).getNode(ResourcesPlugin.PI_RESOURCES); // property was added - assertEquals("3.0", "value0", node.get("key0", null)); + assertEquals("value0", node.get("key0", null)); // property value was not changed - assertEquals("3.1", "value1", node.get("key1", null)); + assertEquals("value1", node.get("key1", null)); // property value was changed to upper case - assertEquals("3.2", "value2".toUpperCase(), node.get("key2", null)); + assertEquals("value2".toUpperCase(), node.get("key2", null)); // property was deleted - assertNull("3.3", node.get("key3", null)); + assertNull(node.get("key3", null)); } /* @@ -691,17 +692,17 @@ public void test_256900() throws Exception { node.flush(); IFile prefFile = getFileInWorkspace(project, ResourcesPlugin.PI_RESOURCES); - assertTrue("2.0", prefFile.exists()); + assertTrue(prefFile.exists()); // get the pref node for the destination project Preferences project2Node = new ProjectScope(project2).getNode(ResourcesPlugin.PI_RESOURCES); - assertNull("3.0", project2Node.get(key, null)); + assertNull(project2Node.get(key, null)); // copy the pref file to the destination project getFileInWorkspace(project2, ResourcesPlugin.PI_RESOURCES).delete(true, null); prefFile.copy(getFileInWorkspace(project2, ResourcesPlugin.PI_RESOURCES).getFullPath(), true, null); - assertEquals("5.0", value, project2Node.get(key, null)); + assertEquals(value, project2Node.get(key, null)); } /** @@ -856,7 +857,7 @@ public void test_384151() throws BackingStoreException, CoreException { node.put(key, createUniqueString()); node.flush(); // if there is no preference, OS default line separator should be used - assertEquals("1.0", systemValue, getLineSeparatorFromFile(file)); + assertEquals(systemValue, getLineSeparatorFromFile(file)); file.delete(true, createTestMonitor()); instanceNode.put(Platform.PREF_LINE_SEPARATOR, newInstanceValue); @@ -864,7 +865,7 @@ public void test_384151() throws BackingStoreException, CoreException { node.put(key, createUniqueString()); node.flush(); // if there is instance preference then it should be used - assertEquals("2.0", newInstanceValue, getLineSeparatorFromFile(file)); + assertEquals(newInstanceValue, getLineSeparatorFromFile(file)); file.delete(true, createTestMonitor()); projectNode.put(Platform.PREF_LINE_SEPARATOR, newProjectValue); @@ -873,7 +874,7 @@ public void test_384151() throws BackingStoreException, CoreException { node.flush(); // if there is project preference then it should be used String recentlyUsedLineSeparator = getLineSeparatorFromFile(file); - assertEquals("3.0", newProjectValue, recentlyUsedLineSeparator); + assertEquals(newProjectValue, recentlyUsedLineSeparator); // don't delete the prefs file, it will be used in the next step // remove preferences for the next step @@ -892,7 +893,7 @@ public void test_384151() throws BackingStoreException, CoreException { node.put(key, createUniqueString()); node.flush(); // if the prefs file exists, line delimiter from the existing file should be used - assertEquals("4.0", recentlyUsedLineSeparator, getLineSeparatorFromFile(file)); + assertEquals(recentlyUsedLineSeparator, getLineSeparatorFromFile(file)); } finally { // revert instance preference to original value if (oldInstanceValue == null) { @@ -931,7 +932,7 @@ public void test_336211() throws BackingStoreException, CoreException, IOExcepti project.open(createTestMonitor()); //loading preferences from a file must not remove nodes that were previously created - assertTrue(node == projectNode.node(nodeName)); + assertSame(node, projectNode.node(nodeName)); assertEquals("VALUE", node.get("KEY", null)); } @@ -950,15 +951,15 @@ public void testProjectOpenClose() throws Exception { // now reopen the project and ensure the settings were not forgotten project.open(createTestMonitor()); node = new ProjectScope(project).getNode(qualifier); - assertEquals("2.1", value, node.get(key, null)); + assertEquals(value, node.get(key, null)); } @Test public void testContentType() { IContentType prefsType = Platform.getContentTypeManager().getContentType(ResourcesPlugin.PI_RESOURCES + ".preferences"); - assertNotNull("1.0", prefsType); + assertNotNull(prefsType); IContentType associatedType = Platform.getContentTypeManager().findContentTypeFor("some.qualifier." + EclipsePreferences.PREFS_FILE_EXTENSION); - assertEquals("1.1", prefsType, associatedType); + assertEquals(prefsType, associatedType); } @Test @@ -977,8 +978,8 @@ public void testListenerOnChangeFile() throws Exception { Tracer tracer = new Tracer(); ((IEclipsePreferences) node).addPreferenceChangeListener(tracer); String actual = node.get(key, null); - assertNotNull("1.0", actual); - assertEquals("1.1", value, actual); + assertNotNull(actual); + assertEquals(value, actual); // flush node.flush(); @@ -1006,12 +1007,12 @@ public void testListenerOnChangeFile() throws Exception { // validate new settings actual = node.get(key, null); - assertEquals("4.1", value, actual); + assertEquals(value, actual); actual = node.get(newKey, null); - assertEquals("4.2", newValue, actual); + assertEquals(newValue, actual); // validate the change events - assertEquals("4.3", "[" + newKey + ":null->S" + newValue + "]", tracer.log.toString()); + assertEquals("[" + newKey + ":null->S" + newValue + "]", tracer.log.toString()); } private static IProject getProject(String name) { @@ -1046,7 +1047,7 @@ public void testLoadIsImport() throws Exception { // set the values in the nodes and flush the values to the file system node.put(key, oldValue); node.flush(); - assertEquals("1.00", oldValue, node.get(key, null)); + assertEquals(oldValue, node.get(key, null)); // copy the data into a buffer for later use File fileInFS = getFileInFilesystem(project, qualifier); @@ -1055,11 +1056,11 @@ public void testLoadIsImport() throws Exception { // remove the file from the project IFile fileInWS = getFileInWorkspace(project, qualifier); fileInWS.delete(IResource.NONE, createTestMonitor()); - assertTrue("3.0", !fileInWS.exists()); - assertTrue("3.1", !fileInFS.exists()); + assertFalse(fileInWS.exists()); + assertFalse(fileInFS.exists()); IEclipsePreferences projectNode = (IEclipsePreferences) service.getRootNode().node(ProjectScope.SCOPE).node(project.getName()); // when the pref file is deleted, the node will be cleared, but not removed - assertTrue("3.2", isNodeCleared(projectNode, new String[] { qualifier })); + assertTrue(isNodeCleared(projectNode, new String[] { qualifier })); // assertNull("3.3", projectNode.node(qualifier).get(oldKey, null)); // create the file in the project and discover it via a refresh local @@ -1077,7 +1078,7 @@ public void testLoadIsImport() throws Exception { // verification - note that the preference modify listener gets called // here so that's why we are checking for "new value" and not the original one node = context.getNode(qualifier); - assertEquals("5.0", newValue, node.get(key, null)); + assertEquals(newValue, node.get(key, null)); } /** diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java index 32e24becb15..a21a68ee8ec 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -36,6 +36,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -338,17 +339,17 @@ public void testAppendContents2() throws Exception { // setup file.create(null, false, monitor); monitor.assertUsedUp(); - assertTrue("1.0", !file.isLocal(IResource.DEPTH_ZERO)); - assertTrue("1.1", !file.getLocation().toFile().exists()); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.getLocation().toFile().exists()); createInFileSystem(file); - assertTrue("1.2", !file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); monitor.prepare(); file.appendContents(createRandomContentsStream(), IResource.FORCE, monitor); monitor.assertUsedUp(); - assertTrue("1.5", file.isLocal(IResource.DEPTH_ZERO)); - assertTrue("1.6", file.getLocation().toFile().exists()); + assertTrue(file.isLocal(IResource.DEPTH_ZERO)); + assertTrue(file.getLocation().toFile().exists()); // cleanup removeFromWorkspace(file); @@ -359,13 +360,13 @@ public void testAppendContents2() throws Exception { monitor.prepare(); file.create(null, false, monitor); monitor.assertUsedUp(); - assertTrue("2.0", !file.isLocal(IResource.DEPTH_ZERO)); - assertTrue("2.1", !file.getLocation().toFile().exists()); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.getLocation().toFile().exists()); monitor.prepare(); assertThrows(CoreException.class, () -> file.appendContents(createRandomContentsStream(), IResource.FORCE, monitor)); monitor.sanityCheck(); - assertTrue("2.4", !file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); // cleanup removeFromWorkspace(file); @@ -375,15 +376,15 @@ public void testAppendContents2() throws Exception { monitor.prepare(); file.create(null, false, monitor); monitor.assertUsedUp(); - assertTrue("3.0", !file.isLocal(IResource.DEPTH_ZERO)); - assertTrue("3.1", !file.getLocation().toFile().exists()); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.getLocation().toFile().exists()); createInFileSystem(file); - assertTrue("3.2", !file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); monitor.prepare(); assertThrows(CoreException.class, () -> file.appendContents(createRandomContentsStream(), IResource.NONE, monitor)); monitor.assertUsedUp(); - assertTrue("3.5", !file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); // cleanup removeFromWorkspace(file); @@ -393,13 +394,13 @@ public void testAppendContents2() throws Exception { monitor.prepare(); file.create(null, false, monitor); monitor.assertUsedUp(); - assertTrue("4.0", !file.isLocal(IResource.DEPTH_ZERO)); - assertTrue("4.1", !file.getLocation().toFile().exists()); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.getLocation().toFile().exists()); monitor.prepare(); assertThrows(CoreException.class, () -> file.appendContents(createRandomContentsStream(), IResource.NONE, monitor)); monitor.sanityCheck(); - assertTrue("4.4", !file.isLocal(IResource.DEPTH_ZERO)); + assertFalse(file.isLocal(IResource.DEPTH_ZERO)); // cleanup removeFromWorkspace(file); } @@ -478,8 +479,8 @@ public void testCreateDerived() throws CoreException { FussyProgressMonitor monitor = new FussyProgressMonitor(); derived.create(createRandomContentsStream(), IResource.DERIVED, monitor); monitor.assertUsedUp(); - assertTrue("1.0", derived.isDerived()); - assertTrue("1.1", !derived.isTeamPrivateMember()); + assertTrue(derived.isDerived()); + assertFalse(derived.isTeamPrivateMember()); monitor.prepare(); derived.delete(false, monitor); @@ -487,8 +488,8 @@ public void testCreateDerived() throws CoreException { monitor.prepare(); derived.create(createRandomContentsStream(), IResource.NONE, monitor); monitor.assertUsedUp(); - assertTrue("2.0", !derived.isDerived()); - assertTrue("2.1", !derived.isTeamPrivateMember()); + assertFalse(derived.isDerived()); + assertFalse(derived.isTeamPrivateMember()); } @Test public void testCreateBytes() throws CoreException { @@ -528,7 +529,7 @@ public void testCreateBytes() throws CoreException { // if the parent is deleted in workspace Exception is expected: try { orphan.write("parentDoesNotExist - not even in workspace".getBytes(), true, false, false, monitor); - assertFalse("should not be reached", true); + fail("should not be reached"); } catch (ResourceException expected) { monitor.assertUsedUp(); assertFalse(orphan.exists()); @@ -705,7 +706,7 @@ public void testDeltaOnCreateDerived() throws CoreException { derived.create(createRandomContentsStream(), IResource.FORCE | IResource.DERIVED, monitor); monitor.assertUsedUp(); - assertTrue("2.0", verifier.isDeltaValid()); + assertTrue(verifier.isDeltaValid()); } @Test @@ -718,8 +719,8 @@ public void testCreateDerivedTeamPrivate() throws CoreException { teamPrivate.create(createRandomContentsStream(), IResource.TEAM_PRIVATE | IResource.DERIVED, monitor); monitor.assertUsedUp(); - assertTrue("1.0", teamPrivate.isTeamPrivateMember()); - assertTrue("1.1", teamPrivate.isDerived()); + assertTrue(teamPrivate.isTeamPrivateMember()); + assertTrue(teamPrivate.isDerived()); monitor.prepare(); teamPrivate.delete(false, monitor); @@ -727,8 +728,8 @@ public void testCreateDerivedTeamPrivate() throws CoreException { monitor.prepare(); teamPrivate.create(createRandomContentsStream(), IResource.NONE, monitor); monitor.assertUsedUp(); - assertTrue("2.0", !teamPrivate.isTeamPrivateMember()); - assertTrue("2.1", !teamPrivate.isDerived()); + assertFalse(teamPrivate.isTeamPrivateMember()); + assertFalse(teamPrivate.isDerived()); } @Test @@ -740,8 +741,8 @@ public void testCreateTeamPrivate() throws CoreException { FussyProgressMonitor monitor = new FussyProgressMonitor(); teamPrivate.create(createRandomContentsStream(), IResource.TEAM_PRIVATE, monitor); monitor.assertUsedUp(); - assertTrue("1.0", teamPrivate.isTeamPrivateMember()); - assertTrue("1.1", !teamPrivate.isDerived()); + assertTrue(teamPrivate.isTeamPrivateMember()); + assertFalse(teamPrivate.isDerived()); monitor.prepare(); teamPrivate.delete(false, monitor); @@ -749,28 +750,28 @@ public void testCreateTeamPrivate() throws CoreException { monitor.prepare(); teamPrivate.create(createRandomContentsStream(), IResource.NONE, monitor); monitor.assertUsedUp(); - assertTrue("2.0", !teamPrivate.isTeamPrivateMember()); - assertTrue("2.1", !teamPrivate.isDerived()); + assertFalse(teamPrivate.isTeamPrivateMember()); + assertFalse(teamPrivate.isDerived()); } @Test public void testFileCreation() throws Exception { IFile fileWithoutInput = projects[0].getFile("file1"); FussyProgressMonitor monitor = new FussyProgressMonitor(); - assertTrue("1.0", !fileWithoutInput.exists()); + assertFalse(fileWithoutInput.exists()); monitor.prepare(); fileWithoutInput.create(null, true, monitor); monitor.assertUsedUp(); - assertTrue("1.2", fileWithoutInput.exists()); + assertTrue(fileWithoutInput.exists()); // creation with empty content IFile emptyFile = projects[0].getFile("file2"); - assertTrue("2.0", !emptyFile.exists()); + assertFalse(emptyFile.exists()); String contents = ""; monitor.prepare(); emptyFile.create(createInputStream(contents), true, monitor); monitor.assertUsedUp(); - assertTrue("2.2", emptyFile.exists()); + assertTrue(emptyFile.exists()); try (InputStream stream = emptyFile.getContents(false)) { assertEquals(0, stream.available()); assertThat(stream).hasContent(contents); @@ -779,12 +780,12 @@ public void testFileCreation() throws Exception { // creation with random content IFile fileWithRandomContent = projects[0].getFile("file3"); - assertTrue("3.0", !fileWithRandomContent.exists()); + assertFalse(fileWithRandomContent.exists()); contents = createRandomString(); monitor.prepare(); fileWithRandomContent.create(createInputStream(contents), true, monitor); monitor.assertUsedUp(); - assertTrue("3.2", fileWithRandomContent.exists()); + assertTrue(fileWithRandomContent.exists()); try (InputStream fileInput = fileWithRandomContent.getContents(false)) { assertThat(fileInput).hasContent(contents); } @@ -794,24 +795,24 @@ public void testFileCreation() throws Exception { monitor.prepare(); folder.create(true, true, monitor); monitor.assertUsedUp(); - assertTrue("4.1", folder.exists()); + assertTrue(folder.exists()); IFile fileOnFolder = projects[0].getFile("folder1"); monitor.prepare(); assertThrows(CoreException.class, () -> fileOnFolder.create(null, true, monitor)); monitor.assertUsedUp(); - assertTrue("4.3", folder.exists()); - assertTrue("4.4", !fileOnFolder.exists()); + assertTrue(folder.exists()); + assertFalse(fileOnFolder.exists()); // try to create a file under a non-existent parent folder = projects[0].getFolder("folder2"); - assertTrue("5.0", !folder.exists()); + assertFalse(folder.exists()); IFile fileUnderNonExistentParent = folder.getFile("file4"); monitor.prepare(); assertThrows(CoreException.class, () -> fileUnderNonExistentParent.create(null, true, monitor)); monitor.assertUsedUp(); - assertTrue("5.2", !folder.exists()); - assertTrue("5.3", !fileUnderNonExistentParent.exists()); + assertFalse(folder.exists()); + assertFalse(fileUnderNonExistentParent.exists()); //create from stream that throws exceptions IFile fileFromStream = projects[0].getFile("file2"); @@ -878,11 +879,11 @@ public void testFileDeletion() throws Throwable { FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(null, true, monitor); monitor.assertUsedUp(); - assertTrue("1.0", target.exists()); + assertTrue(target.exists()); monitor.prepare(); target.delete(true, monitor); monitor.assertUsedUp(); - assertTrue("1.1", !target.exists()); + assertFalse(target.exists()); } @Test @@ -891,11 +892,11 @@ public void testFileEmptyDeletion() throws Throwable { FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(createInputStream(""), true, monitor); monitor.assertUsedUp(); - assertTrue("1.0", target.exists()); + assertTrue(target.exists()); monitor.prepare(); target.delete(true, monitor); monitor.assertUsedUp(); - assertTrue("1.1", !target.exists()); + assertFalse(target.exists()); } @Test @@ -909,7 +910,7 @@ public void testFileInFolderCreation() throws CoreException { monitor.prepare(); target.create(createRandomContentsStream(), true, monitor); monitor.assertUsedUp(); - assertTrue("1.1", target.exists()); + assertTrue(target.exists()); } @Test @@ -921,7 +922,7 @@ public void testFileInFolderCreation1() throws Throwable { FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(createRandomContentsStream(), true, monitor); monitor.assertUsedUp(); - assertTrue("1.0", target.exists()); + assertTrue(target.exists()); } @Test @@ -935,7 +936,7 @@ public void testFileInFolderCreation2() throws CoreException { monitor.prepare(); target.create(createRandomContentsStream(), true, monitor); monitor.assertUsedUp(); - assertTrue("1.1", target.exists()); + assertTrue(target.exists()); } @Test @@ -950,8 +951,8 @@ public void testFileMove() throws Throwable { target.move(destination.getFullPath(), true, monitor); monitor.assertUsedUp(); - assertTrue("1.0", destination.exists()); - assertTrue("1.1", !target.exists()); + assertTrue(destination.exists()); + assertFalse(target.exists()); } @Test @@ -962,7 +963,7 @@ public void testFileOverFolder() throws Throwable { FussyProgressMonitor monitor = new FussyProgressMonitor(); assertThrows(CoreException.class, () -> target.create(null, true, monitor)); monitor.assertUsedUp(); - assertTrue("1.1", existing.exists()); + assertTrue(existing.exists()); } /** @@ -1099,11 +1100,11 @@ public void testInvalidFileNames() throws CoreException { } for (String name : names) { IFile file = project.getFile(name); - assertTrue("2.0 " + name, !file.exists()); + assertFalse(name + " shouldn't exist", file.exists()); monitor.prepare(); file.create(createRandomContentsStream(), true, monitor); monitor.assertUsedUp(); - assertTrue("2.2 " + name, file.exists()); + assertTrue(name + " should exist", file.exists()); } } @@ -1197,12 +1198,7 @@ public void testReadNBytes() throws IOException, CoreException { IFile file = projects[0].getFile("smallfile"); byte[] bytes = "1234".getBytes(StandardCharsets.US_ASCII); file.write(bytes, false, false, false, null); - try { - file.readNBytes(-1); - assertFalse(true); - } catch (IllegalArgumentException expected) { - // expected - } + assertThrows(IllegalArgumentException.class, () -> file.readNBytes(-1)); byte[] nBytes0 = file.readNBytes(0); assertEquals(0, nBytes0.length); byte[] nBytes1 = file.readNBytes(1); @@ -1278,10 +1274,10 @@ public void testSetGetFolderPersistentProperty() throws Throwable { createInWorkspace(target); target.setPersistentProperty(name, value); // see if we can get the property - assertTrue("2.0", target.getPersistentProperty(name).equals(value)); + assertTrue(target.getPersistentProperty(name).equals(value)); // see what happens if we get a non-existant property QualifiedName nonExistentPropertyName = new QualifiedName("itp-test", "testNonProperty"); - assertNull("2.1", target.getPersistentProperty(nonExistentPropertyName)); + assertNull(target.getPersistentProperty(nonExistentPropertyName)); //set a persistent property with null qualifier QualifiedName nullQualifierName = new QualifiedName(null, "foo");