Package rocks.xmpp.extensions.xhtmlim.model

Examples of rocks.xmpp.extensions.xhtmlim.model.Html


    @Test
    public void unmarshalHtml() throws XMLStreamException, JAXBException {
        String xml = "<html xmlns='http://jabber.org/protocol/xhtml-im'>\n" +
                "    <body xmlns='http://www.w3.org/1999/xhtml'><p style='font-weight:bold'>hi!</p><p style='font-weight:bold'>hi!</p></body>\n" +
                "  </html>\n";
        Html html = unmarshal(xml, Html.class);
        Assert.assertNotNull(html.getBody());
        Assert.assertEquals(html.getBody().getChildNodes().getLength(), 2);
        Assert.assertEquals(html.getContent(), "<p style=\"font-weight:bold\">hi!</p><p style=\"font-weight:bold\">hi!</p>");
    }
View Full Code Here


        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Document doc = builder.newDocument();

        Html html = new Html(doc);
        Element body = html.getBody();
        Element p = doc.createElement("p");
        p.setAttribute("style", "font-weight:bold");
        p.setTextContent("Hi1");
        Element p2 = doc.createElement("p");
        p2.setAttribute("style", "font-weight:bold");
        p2.setTextContent("Hi2");
        body.appendChild(p);
        body.appendChild(p2);

        String xml = marshal(html);
        String htmlString = html.getContent();
        Assert.assertEquals(htmlString, "<p style=\"font-weight:bold\">Hi1</p><p style=\"font-weight:bold\">Hi2</p>");
        Assert.assertEquals(xml, "<html xmlns=\"http://jabber.org/protocol/xhtml-im\"><body xmlns=\"http://www.w3.org/1999/xhtml\"><p style=\"font-weight:bold\">Hi1</p><p style=\"font-weight:bold\">Hi2</p></body></html>");
    }
View Full Code Here

        Assert.assertEquals(xml, "<html xmlns=\"http://jabber.org/protocol/xhtml-im\"><body xmlns=\"http://www.w3.org/1999/xhtml\"><p style=\"font-weight:bold\">Hi1</p><p style=\"font-weight:bold\">Hi2</p></body></html>");
    }

    @Test
    public void marshalHtmlWithPlainText() throws JAXBException, XMLStreamException, SAXException {
        Html html = new Html("<p>test</p><p>test2</p>");
        String xml = marshal(html);
        Assert.assertEquals(html.getContent(), "<p>test</p><p>test2</p>");
        Assert.assertEquals(xml, "<html xmlns=\"http://jabber.org/protocol/xhtml-im\"><body xmlns=\"http://www.w3.org/1999/xhtml\"><p>test</p><p>test2</p></body></html>");
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.xhtmlim.model.Html

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.