Commits

Zemian Deng committed 4e9d605

Improved Version string and default to "0" if no date is found instead of word UNKNOWN.
(grafted from 653dab1805669cf7909314a1919e2d36475721d5)

Comments (0)

Files changed (2)

timemachine-scheduler/src/main/java/timemachine/scheduler/support/VersionUtils.java

 	public static final String GROUP_ID = "org.bitbucket.timemachine";
 	public static final String ARTIFACT_ID = "timemachine-scheduler";
 	public static final String VERSION_DEV = "DEVELOPMENT";
-	public static final String VERSION_UNKNOWN = "UNKNOWN";
+	public static final String VERSION_UNKNOWN = "0";
 	public static final String VERSION_FILE = "META-INF/maven/" + GROUP_ID + "/" + ARTIFACT_ID + "/pom.properties";
 	private static String schedulerVersion;
 	
 				}
 			} catch (Exception e) {
 				logger.warn("Unable to read " + VERSION_FILE, e);
-				// We will set version value to UNKOWN and move on.
-				schedulerVersion = VERSION_UNKNOWN;
 			}
 		}
+		if (schedulerVersion == null || schedulerVersion.trim().equals("")) {
+			// We will set version value to UNKOWN and move on.
+			schedulerVersion = VERSION_UNKNOWN;
+		}
+		
 		return schedulerVersion;
 	}
 	

timemachine-scheduler/src/test/java/unit/timemachine/scheduler/support/VersionUtilsTest.java

 			String pathSep = File.pathSeparator;
 			System.setProperty("java.class.path", testClasspath + pathSep + origClasspath);
 			List<String> result = ProcessUtils.runJava(-1, new String[]{ Main.class.getName() });
-			Assert.assertThat(result.get(result.size() - 1).matches("0.0.0.UNKNOWN"), Matchers.is(true));
+			Assert.assertThat(result.get(result.size() - 1).matches("0.0.0.0"), Matchers.is(true));
 		} finally {
 			System.setProperty("java.class.path", origClasspath);
 		}