mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 21:12:15 +00:00
added symlink resolution code
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@24373 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
6e2d965041
commit
52066f6440
3 files changed
+108
-31
No files matched your search
@@ -28,6 +28,10 @@ import junit.framework.TestCase;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.io.File;
|
||||
|
||||
import hudson.model.Hudson;
|
||||
import hudson.util.StreamTaskListener;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
@@ -138,4 +142,25 @@ public class UtilTest extends TestCase {
|
||||
assertEquals("Parsing empty string did not return the default value", 10, Util.tryParseNumber("", 10).intValue());
|
||||
assertEquals("Parsing null string did not return the default value", 10, Util.tryParseNumber(null, 10).intValue());
|
||||
}
|
||||
|
||||
public void testSymlink() throws Exception {
|
||||
if (Hudson.isWindows()) return;
|
||||
|
||||
StreamTaskListener l = new StreamTaskListener(System.out);
|
||||
File d = Util.createTempDir();
|
||||
try {
|
||||
new FilePath(new File(d, "a")).touch(0);
|
||||
Util.createSymlink(d,"a","x", l);
|
||||
assertEquals("a",Util.resolveSymlink(new File(d,"x"),l));
|
||||
|
||||
// test a long name
|
||||
StringBuilder buf = new StringBuilder(768);
|
||||
for( int i=0; i<768; i++)
|
||||
buf.append('0'+(i%10));
|
||||
Util.createSymlink(d,buf.toString(),"x", l);
|
||||
assertEquals(buf.toString(),Util.resolveSymlink(new File(d,"x"),l));
|
||||
} finally {
|
||||
Util.deleteRecursive(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user