TMXConverter implements PropertyConverter { @Override public PropertyFile load(InputStream in, String encoding) throws IOException { try { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); PropertyFile file = PropertiesFactory.eINSTANCE.createPropertyFile(); TMXHandler handler = new TMXHandler(file); parser.getXMLReader().setEntityResolver(handler); parser.getXMLReader().setFeature("http: parser.parse(in, handler); return file; } catch (ParserConfigurationException e) { throw new IOException(e); } catch (SAXException e) { throw new IOException(e); } }  @Override PropertyFile load(InputStream in, String encoding); @Override int write(OutputStream out, PropertyFile file, String encoding);  }
@Test public void testLoad() throws FileNotFoundException, IOException { PropertyFile file = fixture.load(new FileInputStream("src/test/resources/tmx/sample.tmx"), "UTF-8"); assertEquals(5,file.getProperties().size()); int i = 0; assertEquals("Start Game", file.getProperties().get(i).getKey()); assertEquals("Iniciar el juego", file.getProperties().get(i++).getValue()); assertEquals("Options", file.getProperties().get(i).getKey()); assertEquals("Opciones", file.getProperties().get(i++).getValue()); assertEquals("Credits", file.getProperties().get(i).getKey()); assertEquals("Creditos", file.getProperties().get(i++).getValue()); assertEquals("Exit", file.getProperties().get(i).getKey()); assertEquals("Salir", file.getProperties().get(i++).getValue()); assertEquals("Resume", file.getProperties().get(i).getKey()); assertEquals("Reanudar", file.getProperties().get(i++).getValue()); Property property = file.getProperties().get(0); PropertyAnnotation annotation = property.findAnnotation(PropertyAnnotations.ANNOTATION_LANGUAGE); assertEquals("en_US", annotation.getValues().get(PropertyAnnotations.SOURCE_LANGUAGE)); assertEquals("es_MX", annotation.getValues().get(PropertyAnnotations.TARGET_LANGUAGE)); }