Merge branch 'feature/JAL-3551Pymol' into develop
[jalview.git] / test / jalview / ext / pymol / PymolManagerTest.java
diff --git a/test/jalview/ext/pymol/PymolManagerTest.java b/test/jalview/ext/pymol/PymolManagerTest.java
new file mode 100644 (file)
index 0000000..c415ace
--- /dev/null
@@ -0,0 +1,64 @@
+package jalview.ext.pymol;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+import jalview.structure.StructureCommand;
+
+public class PymolManagerTest
+{
+  @Test(groups = "Functional")
+  public void testGetPostRequest()
+  {
+    String req = PymolManager
+            .getPostRequest(new StructureCommand("foobar"));
+    assertEquals(req,
+            "<methodCall><methodName>foobar</methodName><params></params></methodCall>");
+
+    req = PymolManager
+            .getPostRequest(new StructureCommand("foobar", "blue", "all"));
+    assertEquals(req, "<methodCall><methodName>foobar</methodName><params>"
+            + "<parameter><value>blue</value></parameter>"
+            + "<parameter><value>all</value></parameter>"
+            + "</params></methodCall>");
+  }
+
+  @Test(groups = "Functional")
+  public void testGetPymolPaths()
+  {
+    /*
+     * OSX
+     */
+    List<String> paths = PymolManager.getPymolPaths("Mac OS X");
+    assertEquals(paths.size(), 1);
+    assertTrue(
+            paths.contains("/Applications/PyMOL.app/Contents/MacOS/PyMOL"));
+
+    /*
+     * Linux
+     */
+    paths = PymolManager.getPymolPaths("Linux i386 1.5.0");
+    assertTrue(paths.contains("/usr/local/pymol/bin/PyMOL"));
+    assertTrue(paths.contains("/usr/local/bin/PyMOL"));
+    assertTrue(paths.contains("/usr/bin/PyMOL"));
+    assertTrue(paths.contains("/usr/local/pymol/bin/PyMOL"));
+    assertTrue(paths
+            .contains(System.getProperty("user.home") + "/opt/bin/PyMOL"));
+
+    /*
+     * Windows
+     */
+    paths = PymolManager.getPymolPaths("Windows 10");
+    assertTrue(paths.isEmpty()); // TODO - Windows paths
+
+    /*
+     * Other
+     */
+    paths = PymolManager.getPymolPaths("VAX/VMS");
+    assertTrue(paths.isEmpty());
+  }
+}