Skip to content

Commit

Permalink
Make UriTests.testAbsoluteURI() more lenient
Browse files Browse the repository at this point in the history
This is a URI test, not a cache test
  • Loading branch information
garydgregory committed Nov 27, 2024
1 parent be5c4bb commit 4b4278c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions commons-vfs2/src/test/java/org/apache/commons/vfs2/UriTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.net.URI;

import org.apache.commons.lang3.ObjectUtils;
import org.junit.Test;

/**
Expand All @@ -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 };
}

/**
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
}

}

0 comments on commit 4b4278c

Please sign in to comment.