CurrencyPairsConfigDocumentLoader { Set<CurrencyPair> readPairs(BufferedReader reader) throws IOException { String pairStr; Set<CurrencyPair> pairs = new HashSet<CurrencyPair>(); while ((pairStr = reader.readLine()) != null) { try { CurrencyPair pair = CurrencyPair.parse(pairStr.trim()); if (pairs.add(pair)) { s_logger.debug("Added currency pair " + pair.getName()); } else { s_logger.debug("Not adding duplicate currency pair " + pair.getName()); } } catch (IllegalArgumentException e) { s_logger.warn("Unable to create currency pair from " + pairStr, e); } } return pairs; } CurrencyPairsConfigDocumentLoader(ConfigMaster configMaster, String dataFilePath, String configName); void run();  }
@Test public void readPairs() throws IOException { CurrencyPairsConfigDocumentLoader loader = new CurrencyPairsConfigDocumentLoader(null, null, null); String eurUsdStr = "EUR/USD"; String gbpUsdStr = "GBP/USD"; String usdCadStr = "USD/CAD"; CurrencyPair eurUsd = CurrencyPair.parse(eurUsdStr); CurrencyPair gbpUsd = CurrencyPair.parse(gbpUsdStr); CurrencyPair usdCad = CurrencyPair.parse(usdCadStr); BufferedReader reader = new BufferedReader(new StringReader(eurUsdStr + "\n" + gbpUsdStr + "\n" + usdCadStr)); ImmutableSet<CurrencyPair> pairs = ImmutableSet.of(eurUsd, gbpUsd, usdCad); AssertJUnit.assertEquals(pairs, loader.readPairs(reader)); }