Package org.rhq.plugins.apache

Examples of org.rhq.plugins.apache.UnitTestException


    private Document loadXML(String file) throws UnitTestException {
        Document document = null;
        try {
            File xmlFile = new File(file);
            if (!xmlFile.exists())
                throw new UnitTestException("Configuration file not found.");

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder loader = factory.newDocumentBuilder();

            document = loader.parse(file);

        } catch (Exception e) {
            throw new UnitTestException("Loading of xml file failed.", e);
        }

        return document;
    }
View Full Code Here


            }
            doc.appendChild(element);
            saveXML(doc, fileName);

        } catch (Exception e) {
            throw new UnitTestException(e);
        }
    }
View Full Code Here

    public Configuration loadConfiguration(String fileName) throws UnitTestException {
        Document document = loadXML(fileName);
        NodeList nodeList = document.getElementsByTagName(ROOT_ELEMENT);
        if (nodeList.getLength() != 1)
            throw new UnitTestException("Configuration file's " + fileName + " format is not valid.");

        Node rootElement = nodeList.item(0);
        Configuration configuration = new Configuration();
        NodeList childNodes = rootElement.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
View Full Code Here

            XMLSerializer serializer = new XMLSerializer();
            serializer.setOutputCharStream(new java.io.FileWriter(fileName));
            serializer.serialize(document);
        } catch (Exception e) {
            throw new UnitTestException("Saving of xml file failed", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.plugins.apache.UnitTestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.