Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #5870 Windows URI case comparison fails #5873

Merged
merged 3 commits into from Jan 12, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -704,13 +704,12 @@ public boolean isFromExcludedJar(WebAppContext context, ServletContainerInitiali
}

//Check if it is excluded by an ordering
URI loadingJarURI = sciResource.getURI();
boolean found = false;
Iterator<Resource> itor = orderedJars.iterator();
while (!found && itor.hasNext())
{
Resource r = itor.next();
found = r.getURI().equals(loadingJarURI);
found = r.equals(sciResource);
}

if (LOG.isDebugEnabled())
Expand Down
Expand Up @@ -34,6 +34,7 @@
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -42,6 +43,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class ResourceTest
Expand Down Expand Up @@ -297,4 +299,30 @@ public void testGlobPath() throws IOException
Resource globResource = Resource.newResource(globReference);
assertNotNull(globResource, "Should have produced a Resource");
}

@Test
@EnabledOnOs(OS.WINDOWS)
public void testEqualsWindowsAltUriSyntax() throws Exception
{
URI a = new URI("file:/C:/foo/bar");
URI b = new URI("file:///C:/foo/bar");

Resource ra = Resource.newResource(a);
Resource rb = Resource.newResource(b);

assertEquals(rb, ra);
}

@Test
@EnabledOnOs(OS.WINDOWS)
public void testEqualsWindowsCaseInsensitiveDrive() throws Exception
{
URI a = new URI("file:///c:/foo/bar");
URI b = new URI("file:///C:/foo/bar");

Resource ra = Resource.newResource(a);
Resource rb = Resource.newResource(b);

assertEquals(rb, ra);
}
}