class 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;
	}

}

class XmlApplicationConfigParserTest {

    private XmlApplicationConfigParser xmlApplicationConfigParser;

    @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());
    }

}