e246b7c83f329ac08ac87be0f263f441c1b4b6e3
[jalview.git] / test / jalview / ext / pymol / PymolManagerTest.java
1 package jalview.ext.pymol;
2
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
5
6 import java.util.List;
7
8 import org.testng.annotations.Test;
9
10 import jalview.structure.StructureCommand;
11
12 public class PymolManagerTest
13 {
14   @Test(groups = "Functional")
15   public void testGetPostRequest()
16   {
17     String req = PymolManager
18             .getPostRequest(new StructureCommand("foobar"));
19     assertEquals(req,
20             "<methodCall><methodName>foobar</methodName><params></params></methodCall>");
21
22     req = PymolManager
23             .getPostRequest(new StructureCommand("foobar", "blue", "all"));
24     assertEquals(req,
25             "<methodCall><methodName>foobar</methodName><params>"
26                     + "<parameter><value>blue</value></parameter>"
27                     + "<parameter><value>all</value></parameter>"
28                     + "</params></methodCall>");
29   }
30
31   @Test(groups = "Functional")
32   public void testGetPymolPaths()
33   {
34     /*
35      * OSX
36      */
37     List<String> paths = PymolManager.getPymolPaths("Mac OS X");
38     assertEquals(paths.size(), 1);
39     assertTrue(
40             paths.contains("/Applications/PyMOL.app/Contents/MacOS/PyMOL"));
41
42     /*
43      * Linux
44      */
45     paths = PymolManager.getPymolPaths("Linux i386 1.5.0");
46     assertTrue(paths.contains("/usr/local/pymol/bin/PyMOL"));
47     assertTrue(paths.contains("/usr/local/bin/PyMOL"));
48     assertTrue(paths.contains("/usr/bin/PyMOL"));
49     assertTrue(paths.contains("/usr/local/pymol/bin/PyMOL"));
50     assertTrue(paths
51             .contains(System.getProperty("user.home") + "/opt/bin/PyMOL"));
52
53     /*
54      * Windows
55      */
56     paths = PymolManager.getPymolPaths("Windows 10");
57     assertTrue(paths.isEmpty()); // TODO - Windows paths
58
59     /*
60      * Other
61      */
62     paths = PymolManager.getPymolPaths("VAX/VMS");
63     assertTrue(paths.isEmpty());
64   }
65 }