Ejemplo n.º 1
0
 @Test
 public void testIsVersionNewer() {
   LOG.info("Testing isVersionNewer comparing two non-rc versions.");
   UpgradeResponse response = UpgradeResponse.fromJSON(TEST_JSON);
   assertTrue(response.isVersionNewer("1.2.3", "1.2.2"));
   assertTrue(response.isVersionNewer("1.2.3", "1.1.3"));
   assertTrue(response.isVersionNewer("1.2.3", "0.2.3"));
   assertFalse(response.isVersionNewer("1.2.3", "1.2.3"));
   assertFalse(response.isVersionNewer("1.2.2", "1.2.3"));
   assertFalse(response.isVersionNewer("1.1.3", "1.2.3"));
   assertFalse(response.isVersionNewer("0.2.3", "1.2.3"));
   LOG.info(
       "Testing isVersionNewer comparing one rc and one non-rc version, when non-rc "
           + "portions of versions are unequal.");
   assertTrue(response.isVersionNewer("1.2.3", "1.2.2-rc1"));
   assertTrue(response.isVersionNewer("1.2.3", "1.1.3-rc1"));
   assertTrue(response.isVersionNewer("1.2.3", "0.2.3-rc1"));
   assertFalse(response.isVersionNewer("1.2.2-rc1", "1.2.3"));
   assertFalse(response.isVersionNewer("1.1.3-rc1", "1.2.3"));
   assertFalse(response.isVersionNewer("0.2.3-rc1", "1.2.3"));
   LOG.info(
       "Testing isVersionNewer comparing one rc and one non-rc version, "
           + "when non-rc portions are equal.");
   assertTrue(response.isVersionNewer("1.2.3", "1.2.3-rc1"));
   assertFalse(response.isVersionNewer("1.2.3-rc1", "1.2.3"));
   LOG.info("Testing isVersionNewer with two rc versions, with unequal non-rc components.");
   assertTrue(response.isVersionNewer("1.2.3-rc2", "1.2.2-rc1"));
   assertTrue(response.isVersionNewer("1.2.3-rc2", "1.1.3-rc1"));
   assertTrue(response.isVersionNewer("1.2.3-rc2", "0.2.3-rc1"));
   assertFalse(response.isVersionNewer("1.2.2-rc1", "1.2.3-rc2"));
   assertFalse(response.isVersionNewer("1.1.3-rc1", "1.2.3-rc2"));
   assertFalse(response.isVersionNewer("0.2.3-rc1", "1.2.3-rc2"));
   LOG.info("Testing isVersionNewer with two rc versions, with equal non-rc components.");
   assertFalse(response.isVersionNewer("1.2.3-rc1", "1.2.3-rc2"));
   assertTrue(response.isVersionNewer("1.2.3-rc2", "1.2.3-rc1"));
   assertFalse(response.isVersionNewer("1.2.3-rc1", "1.2.3-rc1"));
 }