@Test(expected = IoTDBURLException.class) public void testParseWrongPort() throws IoTDBURLException { String userName = "test"; String userPwd = "test"; String host = "localhost"; int port = 66699999; Properties properties = new Properties(); properties.setProperty(Config.AUTH_USER, userName); properties.setProperty(Config.AUTH_PASSWORD, userPwd); IoTDBConnectionParams params = Utils .parseUrl(String.format(Config.IOTDB_URL_PREFIX + "%s:%s/", host, port), properties); }
static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } boolean isUrlLegal = false; Matcher matcher = null; if (url.startsWith(Config.IOTDB_URL_PREFIX)) { String subURL = url.substring(Config.IOTDB_URL_PREFIX.length()); matcher = URL_PATTERN.matcher(subURL); if (matcher.matches()) { isUrlLegal = true; } } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } params.setHost(matcher.group(1)); params.setPort(Integer.parseInt(matcher.group(2))); if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }
Utils { static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } boolean isUrlLegal = false; Matcher matcher = null; if (url.startsWith(Config.IOTDB_URL_PREFIX)) { String subURL = url.substring(Config.IOTDB_URL_PREFIX.length()); matcher = URL_PATTERN.matcher(subURL); if (matcher.matches()) { isUrlLegal = true; } } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } params.setHost(matcher.group(1)); params.setPort(Integer.parseInt(matcher.group(2))); if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; } }
Utils { static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } boolean isUrlLegal = false; Matcher matcher = null; if (url.startsWith(Config.IOTDB_URL_PREFIX)) { String subURL = url.substring(Config.IOTDB_URL_PREFIX.length()); matcher = URL_PATTERN.matcher(subURL); if (matcher.matches()) { isUrlLegal = true; } } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } params.setHost(matcher.group(1)); params.setPort(Integer.parseInt(matcher.group(2))); if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }  }
Utils { static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } boolean isUrlLegal = false; Matcher matcher = null; if (url.startsWith(Config.IOTDB_URL_PREFIX)) { String subURL = url.substring(Config.IOTDB_URL_PREFIX.length()); matcher = URL_PATTERN.matcher(subURL); if (matcher.matches()) { isUrlLegal = true; } } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } params.setHost(matcher.group(1)); params.setPort(Integer.parseInt(matcher.group(2))); if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }   }
Utils { static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } boolean isUrlLegal = false; Matcher matcher = null; if (url.startsWith(Config.IOTDB_URL_PREFIX)) { String subURL = url.substring(Config.IOTDB_URL_PREFIX.length()); matcher = URL_PATTERN.matcher(subURL); if (matcher.matches()) { isUrlLegal = true; } } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } params.setHost(matcher.group(1)); params.setPort(Integer.parseInt(matcher.group(2))); if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }    }