XmlApplicationConfigParser implements ApplicationConfigParser { @Override public ApplicationConfig parse(InputStream inputStream) { Digester digester = new Digester(); digester.addObjectCreate("Application", ApplicationConfig.class); for (String filed : fiedlds) { digester.addBeanPropertySetter("Application/"+filed); } try { return (ApplicationConfig) digester.parse(inputStream); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } return null; }  @Override ApplicationConfig parse(InputStream inputStream);  }
@Test public void testParser(){ InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("app.xml"); ApplicationConfig config = xmlApplicationConfigParser.parse(resourceAsStream); assertEquals("tavern", config.getName()); assertEquals("classpath*:spring/appcontext-*.xml", config.getContextPath()); assertEquals("com.dianping.tavern", config.getPackageBase()); assertNull(config.getParent()); }