Package org.apache.qpid.info.util

Examples of org.apache.qpid.info.util.XMLWriter


    /** Test constructor arg is returned via getXML() */
    public void testXMLWriter()
    {
        StringBuffer input = new StringBuffer("Test");
        xw = new XMLWriter(input);
        assertNotNull("XMLWriter could not instantiate", xw);
        assertEquals("XMLWriter.getXML() failed", input, xw.getXML());
    }
View Full Code Here


    }

    /** Test header generation */
    public void testWriteXMLHeader()
    {
        xw = new XMLWriter(new StringBuffer());
        assertNotNull(xw);
        xw.writeXMLHeader();
        assertEquals("XMLWriter.writeXMLHeader(...) failed", "<?xml version=\"1.0\"?>\n", xw.getXML().toString());
    }
View Full Code Here

    /** Test tag created and written correctly */
    public void testWriteTag()
    {
        String INDENT = "    ";
        xw = new XMLWriter(new StringBuffer());
        assertNotNull("XMLWriter could not instantiate", xw);
        xw.writeTag("test", new HashMap<String, String>(), "TEST");
        assertEquals("XMLWriter.writeTag(...) failed", "<test>\n" + INDENT + "TEST\n" + "</test>\n", xw.getXML()
                .toString());
    }
View Full Code Here

    /** Test tag created and written correctly */
    public void testWriteTagWithNullAttribute()
    {
        String INDENT = "    ";
        xw = new XMLWriter(new StringBuffer());
        assertNotNull("XMLWriter could not instantiate", xw);
        xw.writeTag("test", null, "TEST");
        assertEquals("XMLWriter.writeTag(...) failed", "<test>\n" + INDENT + "TEST\n" + "</test>\n", xw.getXML()
                .toString());
    }
View Full Code Here

    /** Test tag created and written correctly with attribute */
    public void testWriteTagWithAttribute()
    {
        String INDENT = "    ";
        xw = new XMLWriter(new StringBuffer());
        assertNotNull("XMLWriter could not instantiate", xw);
        HashMap<String, String> attr = new HashMap<String, String>();
        attr.put("id", "1");

        xw.writeTag("test", attr, "TEST");
View Full Code Here

    }

    /** Test open tag with an empty attribute map. Just creates an open tag */
    public void testWriteOpenTag()
    {
        xw = new XMLWriter(new StringBuffer());
        assertNotNull(xw);
        HashMap<String, String> attr = new HashMap<String, String>();
        xw.writeOpenTag("test", attr);
        assertEquals("XMLWriter.writeOpenTag(...) failed", "<test>\n", xw.getXML().toString());
    }
View Full Code Here

    }

    /** Test open tag with a null attribute map. Just creates an open tag */
    public void testNullAtrributeOnTag()
    {
        xw = new XMLWriter(new StringBuffer());
        assertNotNull(xw);
        xw.writeOpenTag("test", null);
        assertEquals("XMLWriter.writeOpenTag(...) failed", "<test>\n", xw.getXML().toString());
    }
View Full Code Here

    }

    /** Test that setting an attribute value on the tag is correctly outputted. */
    public void testAtrributeOnTag()
    {
        xw = new XMLWriter(new StringBuffer());
        assertNotNull(xw);
        HashMap<String, String> attr = new HashMap<String, String>();

        attr.put("id", "1");
        xw.writeOpenTag("test1", attr);
View Full Code Here

    }

    /** Test Close Tag is correctly written */
    public void testWriteCloseTag()
    {
        xw = new XMLWriter(new StringBuffer());
        assertNotNull(xw);
        xw.writeCloseTag("test");
        assertEquals("</test>\n", xw.getXML().toString());
    }
View Full Code Here

     *
     * @return A StringBuffer object containing an XML representation of the Info map
     */
    public StringBuffer toXML()
    {
        XMLWriter xw = new XMLWriter(new StringBuffer());
        xw.writeXMLHeader();
        Map<String, String> attr = new HashMap<String, String>();
        xw.writeOpenTag("qpidinfo", attr);
        String key;
        for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
        {
            attr.clear();
            key = it.next();
            xw.writeTag(key, attr, _info.get(key).toString());
        }
        xw.writeCloseTag("qpidinfo");
        return xw.getXML();
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.info.util.XMLWriter

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.