需要convertStringToDocument方法

时间:2018-05-30 10:28:04

标签: junit junit4

我写过convertStringToDocument方法,我不明白怎么写 这种方法的junit测试用例。请帮忙...

public static String convertStringToDocument(String xmlString) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  
    DocumentBuilder builder;  
    try {  
        factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl",true);
        builder = factory.newDocumentBuilder();  
        Document doc = (Document) builder.parse(new InputSource(new StringReader( xmlString )));            
        // return doc;
    } catch (ParserConfigurationException| SAXException| IOException e) {  
        System.out.println("Unable to convert string to Document");  
    } 
    return null;
}

0 个答案:

没有答案