diff --git a/spring-test/src/main/java/org/springframework/test/context/aot/hint/StandardTestRuntimeHints.java b/spring-test/src/main/java/org/springframework/test/context/aot/hint/StandardTestRuntimeHints.java index b545bba6f7..6204cb2e52 100644 --- a/spring-test/src/main/java/org/springframework/test/context/aot/hint/StandardTestRuntimeHints.java +++ b/spring-test/src/main/java/org/springframework/test/context/aot/hint/StandardTestRuntimeHints.java @@ -114,8 +114,8 @@ class StandardTestRuntimeHints implements TestRuntimeHintsRegistrar { private String cleanClasspathResource(String location) { location = location.substring(CLASSPATH_URL_PREFIX.length()); - if (!location.startsWith(SLASH)) { - location = SLASH + location; + if (location.startsWith(SLASH)) { + location = location.substring(1); } return location; } diff --git a/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java index 0b16e4f216..1f4192a635 100644 --- a/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java @@ -399,8 +399,8 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen private String cleanClasspathResource(String location) { location = location.substring(CLASSPATH_URL_PREFIX.length()); - if (!location.startsWith(SLASH)) { - location = SLASH + location; + if (location.startsWith(SLASH)) { + location = location.substring(1); } return location; } diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java index 07a8dc02ef..20407fbf0d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java @@ -181,21 +181,21 @@ class TestContextAotGeneratorTests extends AbstractAotTests { ).forEach(type -> assertReflectionRegistered(runtimeHints, type, INVOKE_DECLARED_CONSTRUCTORS)); // @ContextConfiguration(locations = ...) - assertThat(resource().forResource("/org/springframework/test/context/aot/samples/xml/test-config.xml")) + assertThat(resource().forResource("org/springframework/test/context/aot/samples/xml/test-config.xml")) .accepts(runtimeHints); // @TestPropertySource(locations = ...) - assertThat(resource().forResource("/org/springframework/test/context/aot/samples/basic/BasicSpringVintageTests.properties")) + assertThat(resource().forResource("org/springframework/test/context/aot/samples/basic/BasicSpringVintageTests.properties")) .accepts(runtimeHints); // @WebAppConfiguration(value = ...) - assertThat(resource().forResource("/META-INF/web-resources/resources/Spring.js")).accepts(runtimeHints); - assertThat(resource().forResource("/META-INF/web-resources/WEB-INF/views/home.jsp")).accepts(runtimeHints); + assertThat(resource().forResource("META-INF/web-resources/resources/Spring.js")).accepts(runtimeHints); + assertThat(resource().forResource("META-INF/web-resources/WEB-INF/views/home.jsp")).accepts(runtimeHints); // @Sql(scripts = ...) - assertThat(resource().forResource("/org/springframework/test/context/jdbc/schema.sql")) + assertThat(resource().forResource("org/springframework/test/context/jdbc/schema.sql")) .accepts(runtimeHints); - assertThat(resource().forResource("/org/springframework/test/context/aot/samples/jdbc/SqlScriptsSpringJupiterTests.test.sql")) + assertThat(resource().forResource("org/springframework/test/context/aot/samples/jdbc/SqlScriptsSpringJupiterTests.test.sql")) .accepts(runtimeHints); }