@Test public void testCheckTomcatVersionIsValid() { Assert.assertEquals(IConstants.TOMCAT_VER_60, TomcatVersionValidator.getTomcatVersion(VMWARE_TOMCAT6_SERVERINFO)); Assert.assertEquals(IConstants.TOMCAT_VER_60, TomcatVersionValidator.getTomcatVersion(WINDOWS_TOMCAT6_SERVERINFO)); Assert.assertEquals(IConstants.TOMCAT_VER_60, TomcatVersionValidator.getTomcatVersion(LINUX_TOMCAT6_SERVERINFO)); Assert.assertEquals(IConstants.TOMCAT_VER_70, TomcatVersionValidator.getTomcatVersion(LINUX_TOMCAT7_SERVERINFO)); Assert.assertEquals(IConstants.TOMCAT_VER_80, TomcatVersionValidator.getTomcatVersion(LINUX_TOMCAT8_SERVERINFO)); Assert.assertEquals(IConstants.TOMCAT_VER_85, TomcatVersionValidator.getTomcatVersion(LINUX_TOMCAT85_SERVERINFO)); Assert.assertNull(TomcatVersionValidator.getTomcatVersion(LINUX_TOMCAT5_SERVERINFO)); Assert.assertNull(TomcatVersionValidator.getTomcatVersion(null)); Assert.assertNull(TomcatVersionValidator.getTomcatVersion("")); }
public static String getTomcatVersion(String serverInfo) { String result = null; if (serverInfo != null && !serverInfo.isEmpty()) { Debug.log("TomcatVersionValidator.getTomcatVersion() - validating ServerInfo:" + serverInfo); int currentIndex = serverInfo.indexOf(STR_APACHE_TOMCAT_SERVER_NUMBER); if (currentIndex == -1) { return null; } currentIndex += STR_APACHE_TOMCAT_SERVER_NUMBER.length(); int endIndex = serverInfo.indexOf('\n', currentIndex); if (endIndex == -1) { endIndex = serverInfo.length() - 1; } String versionLine = serverInfo.substring(currentIndex, endIndex).trim(); if (versionLine.startsWith("6.0")) { result = TOMCAT_VER_60; } else if (versionLine.startsWith("7.0")) { result = TOMCAT_VER_70; } else if (versionLine.startsWith("8.0")) { result = TOMCAT_VER_80; } else if (versionLine.startsWith("8.5")) { result = TOMCAT_VER_85; } Debug.log("TomcatVersionValidator.getTomcatVersion() - version:" + versionLine + " found version: " + result); } return result; }
TomcatVersionValidator extends ValidatorBase implements IConstants, IConfigKeys { public static String getTomcatVersion(String serverInfo) { String result = null; if (serverInfo != null && !serverInfo.isEmpty()) { Debug.log("TomcatVersionValidator.getTomcatVersion() - validating ServerInfo:" + serverInfo); int currentIndex = serverInfo.indexOf(STR_APACHE_TOMCAT_SERVER_NUMBER); if (currentIndex == -1) { return null; } currentIndex += STR_APACHE_TOMCAT_SERVER_NUMBER.length(); int endIndex = serverInfo.indexOf('\n', currentIndex); if (endIndex == -1) { endIndex = serverInfo.length() - 1; } String versionLine = serverInfo.substring(currentIndex, endIndex).trim(); if (versionLine.startsWith("6.0")) { result = TOMCAT_VER_60; } else if (versionLine.startsWith("7.0")) { result = TOMCAT_VER_70; } else if (versionLine.startsWith("8.0")) { result = TOMCAT_VER_80; } else if (versionLine.startsWith("8.5")) { result = TOMCAT_VER_85; } Debug.log("TomcatVersionValidator.getTomcatVersion() - version:" + versionLine + " found version: " + result); } return result; } }
TomcatVersionValidator extends ValidatorBase implements IConstants, IConfigKeys { public static String getTomcatVersion(String serverInfo) { String result = null; if (serverInfo != null && !serverInfo.isEmpty()) { Debug.log("TomcatVersionValidator.getTomcatVersion() - validating ServerInfo:" + serverInfo); int currentIndex = serverInfo.indexOf(STR_APACHE_TOMCAT_SERVER_NUMBER); if (currentIndex == -1) { return null; } currentIndex += STR_APACHE_TOMCAT_SERVER_NUMBER.length(); int endIndex = serverInfo.indexOf('\n', currentIndex); if (endIndex == -1) { endIndex = serverInfo.length() - 1; } String versionLine = serverInfo.substring(currentIndex, endIndex).trim(); if (versionLine.startsWith("6.0")) { result = TOMCAT_VER_60; } else if (versionLine.startsWith("7.0")) { result = TOMCAT_VER_70; } else if (versionLine.startsWith("8.0")) { result = TOMCAT_VER_80; } else if (versionLine.startsWith("8.5")) { result = TOMCAT_VER_85; } Debug.log("TomcatVersionValidator.getTomcatVersion() - version:" + versionLine + " found version: " + result); } return result; } TomcatVersionValidator(); }
TomcatVersionValidator extends ValidatorBase implements IConstants, IConfigKeys { public static String getTomcatVersion(String serverInfo) { String result = null; if (serverInfo != null && !serverInfo.isEmpty()) { Debug.log("TomcatVersionValidator.getTomcatVersion() - validating ServerInfo:" + serverInfo); int currentIndex = serverInfo.indexOf(STR_APACHE_TOMCAT_SERVER_NUMBER); if (currentIndex == -1) { return null; } currentIndex += STR_APACHE_TOMCAT_SERVER_NUMBER.length(); int endIndex = serverInfo.indexOf('\n', currentIndex); if (endIndex == -1) { endIndex = serverInfo.length() - 1; } String versionLine = serverInfo.substring(currentIndex, endIndex).trim(); if (versionLine.startsWith("6.0")) { result = TOMCAT_VER_60; } else if (versionLine.startsWith("7.0")) { result = TOMCAT_VER_70; } else if (versionLine.startsWith("8.0")) { result = TOMCAT_VER_80; } else if (versionLine.startsWith("8.5")) { result = TOMCAT_VER_85; } Debug.log("TomcatVersionValidator.getTomcatVersion() - version:" + versionLine + " found version: " + result); } return result; } TomcatVersionValidator(); ValidationResult isTomcatVersionValid(
        String catalinaHomeDir,
        Map props,
        IStateAccess state); void initializeValidatorMap(); static String getTomcatVersion(String serverInfo); }
TomcatVersionValidator extends ValidatorBase implements IConstants, IConfigKeys { public static String getTomcatVersion(String serverInfo) { String result = null; if (serverInfo != null && !serverInfo.isEmpty()) { Debug.log("TomcatVersionValidator.getTomcatVersion() - validating ServerInfo:" + serverInfo); int currentIndex = serverInfo.indexOf(STR_APACHE_TOMCAT_SERVER_NUMBER); if (currentIndex == -1) { return null; } currentIndex += STR_APACHE_TOMCAT_SERVER_NUMBER.length(); int endIndex = serverInfo.indexOf('\n', currentIndex); if (endIndex == -1) { endIndex = serverInfo.length() - 1; } String versionLine = serverInfo.substring(currentIndex, endIndex).trim(); if (versionLine.startsWith("6.0")) { result = TOMCAT_VER_60; } else if (versionLine.startsWith("7.0")) { result = TOMCAT_VER_70; } else if (versionLine.startsWith("8.0")) { result = TOMCAT_VER_80; } else if (versionLine.startsWith("8.5")) { result = TOMCAT_VER_85; } Debug.log("TomcatVersionValidator.getTomcatVersion() - version:" + versionLine + " found version: " + result); } return result; } TomcatVersionValidator(); ValidationResult isTomcatVersionValid(
        String catalinaHomeDir,
        Map props,
        IStateAccess state); void initializeValidatorMap(); static String getTomcatVersion(String serverInfo);  }