AndroidStringDocumentReader { public static AndroidStringDocument fromFile(String fileName) throws ParserConfigurationException, IOException, SAXException { return buildFromDocument(documentBuilder().parse(new File(fileName))); }  static AndroidStringDocument fromFile(String fileName); static AndroidStringDocument fromText(String text);  }
@Test public void testBuildFromFileRegular() throws Exception { path = Resources.getResource("com/box/l10n/mojito/android/strings/copytune_pinboard.xml").getPath(); document = AndroidStringDocumentReader.fromFile(path); assertThat(document).isNotNull(); assertThat(document.getSingulars()).hasSize(2); AndroidSingular singular = document.getSingulars().get(0); assertThat(singular.getComment()).isEqualTo("testing regular"); assertThat(singular.getName()).isEqualTo("pinterest"); assertThat(singular.getContent()).isEqualTo("Pinterest"); singular = document.getSingulars().get(1); assertThat(singular.getComment()).isEqualTo("testing @ escape"); assertThat(singular.getName()).isEqualTo("atescape"); assertThat(singular.getContent()).isEqualTo("@"); assertThat(document.getPlurals()).hasSize(1); AndroidPlural plural = document.getPlurals().get(0); assertThat(plural.getComment()).isEqualTo("testing plural"); assertThat(plural.getName()).isEqualTo("pins"); assertThat(plural.getItems()).hasSize(2); assertThat(plural.getItems().get(ONE).getContent()).isEqualTo("1 Pin"); assertThat(plural.getItems().get(OTHER).getContent()).isEqualTo("{num_pins} Pins"); }
@Test public void testBuildFromFileKorean() throws Exception { path = Resources.getResource("com/box/l10n/mojito/android/strings/copytune_pinboard_ko-KR.xml").getPath(); document = AndroidStringDocumentReader.fromFile(path); assertThat(document).isNotNull(); assertThat(document.getSingulars()).hasSize(1); AndroidSingular singular = document.getSingulars().get(0); assertThat(singular.getComment()).isEqualTo("testing regular"); assertThat(singular.getName()).isEqualTo("pinterest"); assertThat(singular.getContent()).isEqualTo("pinterest_ko"); assertThat(document.getPlurals()).hasSize(1); AndroidPlural plural = document.getPlurals().get(0); assertThat(plural.getComment()).isEqualTo("testing plural"); assertThat(plural.getName()).isEqualTo("pins"); assertThat(plural.getItems()).hasSize(1); assertThat(plural.getItems().get(OTHER).getContent()).isEqualTo("[Plural form OTHER]: {num_pins} Pins"); }