@Test(expected = IllegalArgumentException.class) public void testBadEnumValue() throws Exception { String value = "unknownEnumValue=notvalidclass" + LINE_SEP; DatabaseFieldConfigLoader.fromReader(new BufferedReader(new StringReader(value))); }
public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Could not read DatabaseFieldConfig from stream", e); } if (line == null) { break; } if (line.equals(CONFIG_FILE_END_MARKER)) { break; } if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) { continue; } String[] parts = line.split("=", -2); if (parts.length != 2) { throw new SQLException("DatabaseFieldConfig reading from stream cannot parse line: " + line); } readField(config, parts[0], parts[1]); anything = true; } if (anything) { return config; } else { return null; } }
DatabaseFieldConfigLoader { public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Could not read DatabaseFieldConfig from stream", e); } if (line == null) { break; } if (line.equals(CONFIG_FILE_END_MARKER)) { break; } if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) { continue; } String[] parts = line.split("=", -2); if (parts.length != 2) { throw new SQLException("DatabaseFieldConfig reading from stream cannot parse line: " + line); } readField(config, parts[0], parts[1]); anything = true; } if (anything) { return config; } else { return null; } } }
DatabaseFieldConfigLoader { public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Could not read DatabaseFieldConfig from stream", e); } if (line == null) { break; } if (line.equals(CONFIG_FILE_END_MARKER)) { break; } if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) { continue; } String[] parts = line.split("=", -2); if (parts.length != 2) { throw new SQLException("DatabaseFieldConfig reading from stream cannot parse line: " + line); } readField(config, parts[0], parts[1]); anything = true; } if (anything) { return config; } else { return null; } }  }
DatabaseFieldConfigLoader { public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Could not read DatabaseFieldConfig from stream", e); } if (line == null) { break; } if (line.equals(CONFIG_FILE_END_MARKER)) { break; } if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) { continue; } String[] parts = line.split("=", -2); if (parts.length != 2) { throw new SQLException("DatabaseFieldConfig reading from stream cannot parse line: " + line); } readField(config, parts[0], parts[1]); anything = true; } if (anything) { return config; } else { return null; } }  static DatabaseFieldConfig fromReader(BufferedReader reader); static void write(BufferedWriter writer, DatabaseFieldConfig config, String tableName); static void writeConfig(BufferedWriter writer, DatabaseFieldConfig config, String tableName); }
DatabaseFieldConfigLoader { public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Could not read DatabaseFieldConfig from stream", e); } if (line == null) { break; } if (line.equals(CONFIG_FILE_END_MARKER)) { break; } if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) { continue; } String[] parts = line.split("=", -2); if (parts.length != 2) { throw new SQLException("DatabaseFieldConfig reading from stream cannot parse line: " + line); } readField(config, parts[0], parts[1]); anything = true; } if (anything) { return config; } else { return null; } }  static DatabaseFieldConfig fromReader(BufferedReader reader); static void write(BufferedWriter writer, DatabaseFieldConfig config, String tableName); static void writeConfig(BufferedWriter writer, DatabaseFieldConfig config, String tableName);  }