JAL-3280 Test for remote release build_properties file version check
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 2 Sep 2020 17:25:40 +0000 (18:25 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 14 Dec 2020 13:07:36 +0000 (13:07 +0000)
src/jalview/bin/Cache.java
test/jalview/bin/CacheTest.java
test/jalview/bin/testProps.jvprops [new file with mode: 0644]

index ef42589..13532e7 100755 (executable)
@@ -1666,13 +1666,13 @@ public class Cache
     getdownDistDir = distDir;
   }
 
-  private static String getGetdownAppbase()
+  public static String getGetdownAppbase()
   {
     setGetdownAppbase();
     return getdownAppbase;
   }
 
-  private static String getAppbaseBuildProperties()
+  public static String getAppbaseBuildProperties()
   {
     String appbase = getGetdownAppbase();
     return appbase + "/" + getdownDistDir + "/build_properties";
index e762dd5..9edfd3b 100644 (file)
  */
 package jalview.bin;
 
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertTrue;
 import static org.testng.AssertJUnit.assertEquals;
-
-import jalview.gui.JvOptionPane;
+import static org.testng.AssertJUnit.assertNotNull;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -32,6 +33,8 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import jalview.gui.JvOptionPane;
+
 public class CacheTest
 {
 
@@ -70,9 +73,28 @@ public class CacheTest
     assertEquals(formattedDate, formattedDate2);
 
     // currently using Locale.UK to format dates:
-    assertEquals(
-            formattedDate2,
-            SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM,
-                    SimpleDateFormat.MEDIUM, Locale.UK).format(now));
+    assertEquals(formattedDate2,
+            SimpleDateFormat
+                    .getDateTimeInstance(SimpleDateFormat.MEDIUM,
+                            SimpleDateFormat.MEDIUM, Locale.UK)
+                    .format(now));
+  }
+
+  @Test(groups = "Functional")
+  public void testVersionChecker()
+  {
+    Cache.loadProperties("test/jalview/bin/testProps.jvprops");
+    try
+    {
+      // 10s sleep to allow VersionChecker thread to run
+      Thread.sleep(10000);
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+    String latestVersion = Cache.getProperty("LATEST_VERSION");
+    assertNotNull(latestVersion);
+    assertNotEquals(latestVersion, "test");
+    assertTrue(latestVersion.startsWith("2."));
   }
 }
diff --git a/test/jalview/bin/testProps.jvprops b/test/jalview/bin/testProps.jvprops
new file mode 100644 (file)
index 0000000..a1ab82a
--- /dev/null
@@ -0,0 +1,2 @@
+VERSION_CHECK=true
+LATEST_VERSION=test