Skip to content

Commit

Permalink
Alternative fix for case sensitivity issue.
Browse files Browse the repository at this point in the history
Resource URLs are generated from canonical file paths so the expected paths need to be canonical as well.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1842705 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Oct 3, 2018
1 parent d63695a commit db71c92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
Expand Up @@ -18,7 +18,6 @@

import java.io.File;

import org.apache.tomcat.util.compat.JrePlatform;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -46,18 +45,10 @@ public void testNestedJarGetURL() throws Exception {
ctx.getResources().getClassLoaderResource("/META-INF/resources/index.html");

StringBuilder expectedURL = new StringBuilder("jar:war:");
expectedURL.append(docBase.getAbsoluteFile().toURI().toURL().toString());
expectedURL.append(docBase.getCanonicalFile().toURI().toURL().toString());
expectedURL.append("*/WEB-INF/lib/test.jar!/META-INF/resources/index.html");

String expected = expectedURL.toString();
String actual = webResource.getURL().toString();

if (JrePlatform.IS_WINDOWS){
expected = expected.toLowerCase();
actual = actual.toLowerCase();
}

Assert.assertEquals(expected, actual);
Assert.assertEquals(expectedURL.toString(), webResource.getURL().toString());
}


Expand All @@ -77,18 +68,10 @@ public void testJarGetURL() throws Exception {
ctx.getResources().getClassLoaderResource("/META-INF/tags/echo.tag");

StringBuilder expectedURL = new StringBuilder("jar:");
expectedURL.append(docBase.getAbsoluteFile().toURI().toURL().toString());
expectedURL.append(docBase.getCanonicalFile().toURI().toURL().toString());
expectedURL.append("WEB-INF/lib/test-lib.jar!/META-INF/tags/echo.tag");

String expected = expectedURL.toString();
String actual = webResource.getURL().toString();

if (JrePlatform.IS_WINDOWS){
expected = expected.toLowerCase();
actual = actual.toLowerCase();
}

Assert.assertEquals(expected, actual);
Assert.assertEquals(expectedURL.toString(), webResource.getURL().toString());
}

}
12 changes: 1 addition & 11 deletions test/org/apache/catalina/webresources/TestFileResource.java
Expand Up @@ -20,7 +20,6 @@

import javax.servlet.http.HttpServletResponse;

import org.apache.tomcat.util.compat.JrePlatform;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -41,15 +40,6 @@ public void testGetCodePath() throws Exception {

// Build the expected location the same way the webapp base dir is built
File f = new File("test/webapp/WEB-INF/classes");

String expected = f.toURI().toURL().toString();
String actual = out.toString().trim();

if (JrePlatform.IS_WINDOWS){
expected = expected.toLowerCase();
actual = actual.toLowerCase();
}

Assert.assertEquals(expected, actual);
Assert.assertEquals(f.getCanonicalFile().toURI().toURL().toString(), out.toString().trim());
}
}

0 comments on commit db71c92

Please sign in to comment.