package jalview.util; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.io.IOException; import java.nio.file.Paths; import java.util.List; import org.testng.annotations.Test; public class FileUtilsTest { @Test(groups = "Functional") public void testFindMatchingPaths() throws IOException { String expect1 = Paths.get("..", "jalview", "examples", "plantfdx.fa") .toString(); String expect2 = Paths.get("../jalview/examples/plantfdx.features") .toString(); String expect3 = Paths .get("../jalview/examples/testdata/plantfdx.features") .toString(); List matches = FileUtils .findMatchingPaths(Paths.get(".."), ".*[\\\\/]plant.*\\.f.*"); System.out.println(matches); assertTrue(matches.contains(expect1)); assertTrue(matches.contains(expect2)); assertTrue(matches.contains(expect3)); } @Test(groups = "External") public void testWindowsPath() throws IOException { if (System.getProperty("os.name").startsWith("Windows")) { /* * should pass provided Eclipse is installed */ List matches = FileUtils.findMatches("C:\\", "Program Files*/eclips*/eclips?.exe"); assertFalse(matches.isEmpty()); /* * should pass provided Chimera is installed */ matches = FileUtils.findMatches("C:\\", "Program Files*/Chimera*/bin/{chimera,chimera.exe}"); assertFalse(matches.isEmpty()); } } @Test(groups = "Functional") public void testFindMatches() throws IOException { String expect1 = Paths.get("..", "jalview", "examples", "plantfdx.fa") .toString(); String expect2 = Paths.get("../jalview/examples/plantfdx.features") .toString(); String expect3 = Paths .get("../jalview/examples/testdata/plantfdx.features") .toString(); List matches = FileUtils .findMatches("..", "jalview/ex*/plant*.f*"); System.out.println(matches); assertTrue(matches.contains(expect1)); assertTrue(matches.contains(expect2)); assertFalse(matches.contains(expect3)); } }