JAL-2994 disable tests for FileUtils path search methods on bamboo
[jalview.git] / test / jalview / util / FileUtilsTest.java
1 package jalview.util;
2
3 import static org.testng.Assert.assertFalse;
4 import static org.testng.Assert.assertTrue;
5
6 import java.io.IOException;
7 import java.nio.file.Paths;
8 import java.util.List;
9
10 import org.testng.annotations.Test;
11
12 public class FileUtilsTest
13 {
14         /*
15          * FIXME fails on bamboo since it the working directory named according to the build number
16          */
17   @Test(groups = {"Functional","Not-bamboo"})
18   public void testFindMatchingPaths() throws IOException
19   {
20     String expect1 = Paths.get("..", "jalview", "examples", "plantfdx.fa")
21             .toString();
22     String expect2 = Paths.get("../jalview/examples/plantfdx.features")
23             .toString();
24     String expect3 = Paths
25             .get("../jalview/examples/testdata/plantfdx.features")
26             .toString();
27
28     List<String> matches = FileUtils
29             .findMatchingPaths(Paths.get(".."),
30                     ".*[\\\\/]plant.*\\.f.*");
31     System.out.println(matches);
32     assertTrue(matches.contains(expect1));
33     assertTrue(matches.contains(expect2));
34     assertTrue(matches.contains(expect3));
35   }
36
37   @Test(groups = "External")
38   public void testWindowsPath() throws IOException
39   {
40     if (System.getProperty("os.name").startsWith("Windows"))
41     {
42       /*
43        * should pass provided Eclipse is installed
44        */
45       List<String> matches = FileUtils.findMatches("C:\\",
46               "Program Files*/eclips*/eclips?.exe");
47       assertFalse(matches.isEmpty());
48
49       /*
50        * should pass provided Chimera is installed
51        */
52       matches = FileUtils.findMatches("C:\\",
53               "Program Files*/Chimera*/bin/{chimera,chimera.exe}");
54       assertFalse(matches.isEmpty());
55     }
56   }
57
58   /*
59    * FIXME fails on bamboo since it the working directory named according to the build number
60    */
61   @Test(groups = {"Functional","Not-bamboo"})
62   public void testFindMatches() throws IOException
63   {
64     String expect1 = Paths.get("..", "jalview", "examples", "plantfdx.fa")
65             .toString();
66     String expect2 = Paths.get("../jalview/examples/plantfdx.features")
67             .toString();
68     String expect3 = Paths
69             .get("../jalview/examples/testdata/plantfdx.features")
70             .toString();
71   
72     List<String> matches = FileUtils
73             .findMatches("..", "jalview/ex*/plant*.f*");
74     System.out.println(matches);
75     assertTrue(matches.contains(expect1));
76     assertTrue(matches.contains(expect2));
77     assertFalse(matches.contains(expect3));
78   }
79 }