ReaderTGFF { protected Map<String, Double> importMessageSizes(Iterator<String> it) { Map<String, Double> sizes = new HashMap<String, Double>(); String line; while (!isClosing(line = it.next())) { if (!isComment(line)) { String[] entries = line.trim().split(SEPARATOR); assert entries.length >= 2 : "tgff-file \"" + COMMUN_QUANT + "\": wrong number of entries"; sizes.put(entries[0], Double.valueOf(entries[1])); } } return sizes; }  SpecificationTypeBased read(String filename); SpecificationTypeBased read(File file); SpecificationTypeBased read(InputStream in); SpecificationTypeBased toSpecification(List<String> in); static final String TGFF_TYPE; static final String PERIOD; static final String MSG_SIZE; static final String RES_ATTRIBUTES; static final String RES_VALUES; static final String HARD_DEADLINE; static final String SOFT_DEADLINE; static final String WIRE; }
@Test public void testImportMessageSizes() { ReaderTGFF reader = new ReaderTGFF(); List<String> in = Arrays.asList("# type quantity", " 0 5", " 1 6", "}"); Iterator<String> it = in.iterator(); Map<String, Double> messageSizes = reader.importMessageSizes(it); Assert.assertEquals(2, messageSizes.size()); Assert.assertTrue(messageSizes.keySet().contains("0")); Assert.assertTrue(messageSizes.keySet().contains("1")); Assert.assertEquals(5l, messageSizes.get("0").longValue()); Assert.assertEquals(6l, messageSizes.get("1").longValue()); }