* indicate that annotation colours are applied across all groups (pre
* Jalview 2.8.1 behaviour)
*/
- boolean doGroupAnnColour = isVersionStringLaterThan("2.8.1",
- object.getVersion());
+ boolean doGroupAnnColour = Jalview2XML.isVersionStringLaterThan(
+ "2.8.1", object.getVersion());
AlignmentPanel ap = null;
boolean isnewview = true;
* @return true if version is development/null or evaluates to the same or
* later X.Y.Z (where X,Y,Z are like [0-9]+b?[0-9]*)
*/
- protected boolean isVersionStringLaterThan(String supported,
+ public static boolean isVersionStringLaterThan(String supported,
String version)
{
if (version == null || version.equalsIgnoreCase("DEVELOPMENT BUILD")
String fileT = fileV.nextToken().toLowerCase().replace('b', '.');
try
{
- if (Float.valueOf(curT) > Float.valueOf(fileT))
+ float supportedVersionToken = Float.parseFloat(curT);
+ float myVersiontoken = Float.parseFloat(fileT);
+ if (supportedVersionToken > myVersiontoken)
{
// current version is newer than the version that wrote the file
return false;
}
+ if (supportedVersionToken < myVersiontoken)
+ {
+ // current version is older than the version that wrote the file
+ return true;
+ }
} catch (NumberFormatException nfe)
{
System.err
*/
package jalview.io;
+import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import jalview.api.AlignmentViewPanel;
Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length);
}
+ @Test(groups = { "Functional" })
+ public void testIsVersionStringLaterThan()
+ {
+ /*
+ * No version / development / test / autobuild is leniently assumed to be
+ * compatible
+ */
+ assertTrue(Jalview2XML.isVersionStringLaterThan(null, null));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", null));
+ assertTrue(Jalview2XML.isVersionStringLaterThan(null,
+ "Development Build"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan(null,
+ "DEVELOPMENT BUILD"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
+ "Development Build"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan(null, "Test"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan(null, "TEST"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "Test"));
+ assertTrue(Jalview2XML
+ .isVersionStringLaterThan(null, "Automated Build"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
+ "Automated Build"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
+ "AUTOMATED BUILD"));
+
+ /*
+ * same version returns true i.e. compatible
+ */
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3b1"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3B1", "2.8.3b1"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3B1"));
+
+ /*
+ * later version returns true
+ */
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.4"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9.2"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8.3"));
+ assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3b1"));
+
+ /*
+ * earlier version returns false
+ */
+ assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8"));
+ assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.4", "2.8.3"));
+ assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3"));
+ assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.2b1"));
+ assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.0b2", "2.8.0b1"));
+ }
}