Skip to content

Commit

Permalink
Issue #5870 Windows URI case comparison fails (#5873)
Browse files Browse the repository at this point in the history
* Issue #5870 Windows URI case comparison fails

Signed-off-by: Jan Bartel <janb@webtide.com>

* Issue #5870 - Updating Windows tests

+ Eliminating OS.MAC (as it doesn't support drive letters)
+ Adding alt URI syntax version as well

Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
janbartel and joakime committed Jan 12, 2021
1 parent 1a7c3de commit e1e16ae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
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);
}
}

0 comments on commit e1e16ae

Please sign in to comment.