From: Juergen H. <jho...@us...> - 2008-10-22 10:33:43
|
Update of /cvsroot/springframework/spring/test/org/springframework/util In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25875/test/org/springframework/util Modified Files: Tag: mbranch-2-0 StringUtilsTests.java Log Message: fixed "StringUtils.delete" to prevent an eternal loop in case of the pattern being empty; "StringUtils.cleanPath" preserves leading slash if given in original path Index: StringUtilsTests.java =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/util/StringUtilsTests.java,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.3 diff -C2 -d -r1.16.2.2 -r1.16.2.3 *** StringUtilsTests.java 10 Sep 2007 11:18:48 -0000 1.16.2.2 --- StringUtilsTests.java 22 Oct 2008 10:33:32 -0000 1.16.2.3 *************** *** 1,4 **** /* ! * Copyright 2002-2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 172,175 **** --- 172,178 ---- String mismatch = StringUtils.delete(inString, "dxxcxcxog"); assertTrue("Result is unchanged", mismatch.equals(inString)); + + String nochange = StringUtils.delete(inString, ""); + assertTrue("Result is unchanged", nochange.equals(inString)); } *************** *** 178,193 **** String res = StringUtils.deleteAny(inString, "I"); ! assertTrue("Result has no Is [" + res + "]", ! res.equals("Able was ere saw Elba")); res = StringUtils.deleteAny(inString, "AeEba!"); ! assertTrue("Result has no Is [" + res + "]", ! res.equals("l ws I r I sw l")); String mismatch = StringUtils.deleteAny(inString, "#@$#$^"); assertTrue("Result is unchanged", mismatch.equals(inString)); ! String whitespace = ! "This is\n\n\n \t a messagy string with whitespace\n"; assertTrue("Has CR", whitespace.indexOf("\n") != -1); assertTrue("Has tab", whitespace.indexOf("\t") != -1); --- 181,193 ---- String res = StringUtils.deleteAny(inString, "I"); ! assertTrue("Result has no Is [" + res + "]", res.equals("Able was ere saw Elba")); res = StringUtils.deleteAny(inString, "AeEba!"); ! assertTrue("Result has no Is [" + res + "]", res.equals("l ws I r I sw l")); String mismatch = StringUtils.deleteAny(inString, "#@$#$^"); assertTrue("Result is unchanged", mismatch.equals(inString)); ! String whitespace = "This is\n\n\n \t a messagy string with whitespace\n"; assertTrue("Has CR", whitespace.indexOf("\n") != -1); assertTrue("Has tab", whitespace.indexOf("\t") != -1); *************** *** 270,273 **** --- 270,274 ---- assertEquals("../mypath/myfile", StringUtils.cleanPath("../mypath/../mypath/myfile")); assertEquals("../mypath/myfile", StringUtils.cleanPath("mypath/../../mypath/myfile")); + assertEquals("/../mypath/myfile", StringUtils.cleanPath("/../mypath/myfile")); } |