From 4b4278c1f9404120cd22a8edbb5b55ce70948025 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 27 Nov 2024 17:29:16 -0500 Subject: [PATCH] Make UriTests.testAbsoluteURI() more lenient This is a URI test, not a cache test --- .../java/org/apache/commons/vfs2/UriTests.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/UriTests.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/UriTests.java index a63cfc76d9..dcc6007914 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/UriTests.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/UriTests.java @@ -18,6 +18,7 @@ import java.net.URI; +import org.apache.commons.lang3.ObjectUtils; import org.junit.Test; /** @@ -26,12 +27,12 @@ public class UriTests extends AbstractProviderTestCase { /** - * Returns the capabilities required by the tests of this test case. The tests are not run if the provider being - * tested does not support all the required capabilities. Return null or an empty array to always run the tests. + * Returns the capabilities required by the tests of this test case. The tests are not run if the provider being tested does not support all the required + * capabilities. Return null or an empty array to always run the tests. */ @Override protected Capability[] getRequiredCapabilities() { - return new Capability[] {Capability.URI}; + return new Capability[] { Capability.URI }; } /** @@ -62,14 +63,12 @@ public void testAbsoluteURI() throws Exception { assertEquals(readFolder.isSymbolicLink(), file.isSymbolicLink()); assertEquals(readFolder.isWriteable(), file.isWriteable()); assertEquals(readFolder.toString(), file.toString()); - // compare objects - // File objects don't implement equals(). - // assertEquals("file object " + readFolder.getClass() + ", " + file.getClass(), readFolder, file); - assertSame("file object " + readFolder.getClass() + ", " + file.getClass(), readFolder, file); + assertEquals(String.format("file object %s %s, %s %s", readFolder.getClass(), ObjectUtils.identityHashCodeHex(readFolder), file.getClass(), + ObjectUtils.identityHashCodeHex(file)), readFolder.toString(), file.toString()); // Try fetching the filesystem root by its URI final String rootUri = readFolder.getName().getRootURI(); file = getManager().resolveFile(rootUri, readFolder.getFileSystem().getFileSystemOptions()); - assertSame(readFolder.getFileSystem().getRoot(), file); + assertEquals(readFolder.getFileSystem().getRoot().toString(), file.toString()); assertEquals(rootUri, file.getName().getRootURI()); assertEquals(rootUri, file.getName().getURI()); assertEquals(FileName.ROOT_PATH, file.getName().getPath()); @@ -119,8 +118,7 @@ public void testURIContentProvider() throws Exception { final FileObject f2 = getManager().resolveFile(uriStr, options); assertEquals("Two files resolved by URI must be equals on " + uriStr, f1, f2); - assertSame("Resolving two times should not produce new filesystem on " + uriStr, f1.getFileSystem(), - f2.getFileSystem()); + assertSame("Resolving two times should not produce new filesystem on " + uriStr, f1.getFileSystem(), f2.getFileSystem()); } }