View Javadoc
1   /*
2    * Copyright (C) 2012-2013, Robin Rosenberg <robin.rosenberg@dewire.com> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  package org.eclipse.jgit.treewalk;
11  
12  import static org.junit.Assert.assertEquals;
13  import static org.junit.Assert.assertFalse;
14  import static org.junit.Assert.assertTrue;
15  
16  import java.io.File;
17  
18  import org.eclipse.jgit.junit.RepositoryTestCase;
19  import org.eclipse.jgit.util.FS;
20  import org.junit.Test;
21  
22  public class TreeWalkJava7Test extends RepositoryTestCase {
23  	@Test
24  	public void testSymlinkToDirNotRecursingViaSymlink() throws Exception {
25  		org.junit.Assume.assumeTrue(FS.DETECTED.supportsSymlinks());
26  		FS fs = db.getFS();
27  		assertTrue(fs.supportsSymlinks());
28  		writeTrashFile("target/data", "targetdata");
29  		fs.createSymLink(new File(trash, "link"), "target");
30  		try (TreeWalk tw = new TreeWalk(db)) {
31  			tw.setRecursive(true);
32  			tw.addTree(new FileTreeIterator(db));
33  			assertTrue(tw.next());
34  			assertEquals("link", tw.getPathString());
35  			assertTrue(tw.next());
36  			assertEquals("target/data", tw.getPathString());
37  			assertFalse(tw.next());
38  		}
39  	}
40  }