File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
spring-core/src/test/java/org/springframework/util Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -794,6 +794,25 @@ void collectionToDelimitedStringWithNullValuesShouldNotFail() {
794794 assertThat (StringUtils .collectionToCommaDelimitedString (Collections .singletonList (null ))).isEqualTo ("null" );
795795 }
796796
797+ @ Test
798+ void applyRelativePath () {
799+ // Basic combination
800+ assertThat (StringUtils .applyRelativePath ("mypath/myfile" , "otherfile" )).isEqualTo ("mypath/otherfile" );
801+ // Relative path starts with slash
802+ assertThat (StringUtils .applyRelativePath ("mypath/myfile" , "/otherfile" )).isEqualTo ("mypath/otherfile" );
803+ // Includes root path
804+ assertThat (StringUtils .applyRelativePath ("/mypath/myfile" , "otherfile" )).isEqualTo ("/mypath/otherfile" );
805+ assertThat (StringUtils .applyRelativePath ("/mypath/myfile" , "/otherfile" )).isEqualTo ("/mypath/otherfile" );
806+ // When base path has no slash
807+ assertThat (StringUtils .applyRelativePath ("myfile" , "otherfile" )).isEqualTo ("otherfile" );
808+ // Keep parent directory token as-is
809+ assertThat (StringUtils .applyRelativePath ("mypath/myfile" , "../otherfile" )).isEqualTo ("mypath/../otherfile" );
810+ // Base path ends with slash
811+ assertThat (StringUtils .applyRelativePath ("mypath/" , "otherfile" )).isEqualTo ("mypath/otherfile" );
812+ // Empty relative path
813+ assertThat (StringUtils .applyRelativePath ("mypath/myfile" , "" )).isEqualTo ("mypath/" );
814+ }
815+
797816 @ Test
798817 void truncatePreconditions () {
799818 assertThatIllegalArgumentException ()
You can’t perform that action at this time.
0 commit comments