@Test (expected = NullPointerException.class) public void testLoadNullFile () throws IOException { new MySQLConfig().load(null); }
public void load (File file) throws IOException { if (file == null) { throw new NullPointerException("file cannot be null."); } if (!file.exists()) { throw new IllegalStateException("mysql config file doesnt exists: " + file.getAbsolutePath()); } LocalLogger.print("load mysql configuration " + file.getName()); Ini ini = new Ini(file); Profile.Section section = ini.get("MySQL"); this.host = section.getOrDefault("host", "locahost"); this.port = getInt(section, "port"); this.database = section.get("database"); this.user = section.getOrDefault("user", ""); this.password = section.get("password"); this.prefix = section.getOrDefault("prefix", ""); this.maxPoolSize = Integer.parseInt(section.getOrDefault("max_pool_size", "30")); this.prepStmtCacheSize = Integer.parseInt(section.getOrDefault("prepStmtCacheSize", "250")); this.prepStmtCacheSqlLimit = Integer.parseInt(section.getOrDefault("prepStmtCacheSqlLimit", "2048")); }
MySQLConfig implements ConfigLoader { public void load (File file) throws IOException { if (file == null) { throw new NullPointerException("file cannot be null."); } if (!file.exists()) { throw new IllegalStateException("mysql config file doesnt exists: " + file.getAbsolutePath()); } LocalLogger.print("load mysql configuration " + file.getName()); Ini ini = new Ini(file); Profile.Section section = ini.get("MySQL"); this.host = section.getOrDefault("host", "locahost"); this.port = getInt(section, "port"); this.database = section.get("database"); this.user = section.getOrDefault("user", ""); this.password = section.get("password"); this.prefix = section.getOrDefault("prefix", ""); this.maxPoolSize = Integer.parseInt(section.getOrDefault("max_pool_size", "30")); this.prepStmtCacheSize = Integer.parseInt(section.getOrDefault("prepStmtCacheSize", "250")); this.prepStmtCacheSqlLimit = Integer.parseInt(section.getOrDefault("prepStmtCacheSqlLimit", "2048")); } }
MySQLConfig implements ConfigLoader { public void load (File file) throws IOException { if (file == null) { throw new NullPointerException("file cannot be null."); } if (!file.exists()) { throw new IllegalStateException("mysql config file doesnt exists: " + file.getAbsolutePath()); } LocalLogger.print("load mysql configuration " + file.getName()); Ini ini = new Ini(file); Profile.Section section = ini.get("MySQL"); this.host = section.getOrDefault("host", "locahost"); this.port = getInt(section, "port"); this.database = section.get("database"); this.user = section.getOrDefault("user", ""); this.password = section.get("password"); this.prefix = section.getOrDefault("prefix", ""); this.maxPoolSize = Integer.parseInt(section.getOrDefault("max_pool_size", "30")); this.prepStmtCacheSize = Integer.parseInt(section.getOrDefault("prepStmtCacheSize", "250")); this.prepStmtCacheSqlLimit = Integer.parseInt(section.getOrDefault("prepStmtCacheSqlLimit", "2048")); } MySQLConfig(); }
MySQLConfig implements ConfigLoader { public void load (File file) throws IOException { if (file == null) { throw new NullPointerException("file cannot be null."); } if (!file.exists()) { throw new IllegalStateException("mysql config file doesnt exists: " + file.getAbsolutePath()); } LocalLogger.print("load mysql configuration " + file.getName()); Ini ini = new Ini(file); Profile.Section section = ini.get("MySQL"); this.host = section.getOrDefault("host", "locahost"); this.port = getInt(section, "port"); this.database = section.get("database"); this.user = section.getOrDefault("user", ""); this.password = section.get("password"); this.prefix = section.getOrDefault("prefix", ""); this.maxPoolSize = Integer.parseInt(section.getOrDefault("max_pool_size", "30")); this.prepStmtCacheSize = Integer.parseInt(section.getOrDefault("prepStmtCacheSize", "250")); this.prepStmtCacheSqlLimit = Integer.parseInt(section.getOrDefault("prepStmtCacheSqlLimit", "2048")); } MySQLConfig(); void load(File file); String getHost(); int getPort(); String getDatabase(); String getUser(); String getPassword(); String getPrefix(); void setPrefix(String prefix); int getMaxPoolSize(); String getJDBCUrl(); int getPrepStmtCacheSize(); int getPrepStmtCacheSqlLimit(); }
MySQLConfig implements ConfigLoader { public void load (File file) throws IOException { if (file == null) { throw new NullPointerException("file cannot be null."); } if (!file.exists()) { throw new IllegalStateException("mysql config file doesnt exists: " + file.getAbsolutePath()); } LocalLogger.print("load mysql configuration " + file.getName()); Ini ini = new Ini(file); Profile.Section section = ini.get("MySQL"); this.host = section.getOrDefault("host", "locahost"); this.port = getInt(section, "port"); this.database = section.get("database"); this.user = section.getOrDefault("user", ""); this.password = section.get("password"); this.prefix = section.getOrDefault("prefix", ""); this.maxPoolSize = Integer.parseInt(section.getOrDefault("max_pool_size", "30")); this.prepStmtCacheSize = Integer.parseInt(section.getOrDefault("prepStmtCacheSize", "250")); this.prepStmtCacheSqlLimit = Integer.parseInt(section.getOrDefault("prepStmtCacheSqlLimit", "2048")); } MySQLConfig(); void load(File file); String getHost(); int getPort(); String getDatabase(); String getUser(); String getPassword(); String getPrefix(); void setPrefix(String prefix); int getMaxPoolSize(); String getJDBCUrl(); int getPrepStmtCacheSize(); int getPrepStmtCacheSqlLimit();  }