Search in sources :

Example 1 with Reportedref

use of org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Reportedref in project Smack by igniterealtime.

the class DataLayoutTest method testLayoutSpecialCharacters.

@Test
public void testLayoutSpecialCharacters() throws XmlPullParserException, IOException {
    DataLayout layout = new DataLayout("Label - & é á ");
    Fieldref reffield = new Fieldref("testField1");
    layout.getPageLayout().add(reffield);
    Section section = new Section("section Label - & é á ");
    section.getSectionLayout().add(new Text("SectionText - & é á "));
    layout.getPageLayout().add(section);
    layout.getPageLayout().add(new Text("PageText - & é á "));
    section = new Section("<html>Number of Persons by<br/> Nationality and Status</html>");
    section.getSectionLayout().add(new Reportedref());
    layout.getPageLayout().add(section);
    layout.getPageLayout().add(new Text("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>"));
    assertNotNull(layout.toXML());
    String output = layout.toXML().toString();
    assertEquals(TEST_OUTPUT_SPECIAL, output);
    XmlPullParser parser = PacketParserUtils.getParserFor(output);
    layout = DataLayoutProvider.parse(parser);
    assertEquals(5, layout.getPageLayout().size());
    assertEquals("Label - & é á ", layout.getLabel());
    section = (Section) layout.getPageLayout().get(1);
    assertEquals("section Label - & é á ", section.getLabel());
    Text text = (Text) layout.getPageLayout().get(2);
    assertEquals("PageText - & é á ", text.getText());
    section = (Section) layout.getPageLayout().get(3);
    assertEquals("<html>Number of Persons by<br/> Nationality and Status</html>", section.getLabel());
    text = (Text) layout.getPageLayout().get(4);
    assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
    assertNotNull(layout.toXML());
    output = layout.toXML().toString();
    assertEquals(TEST_OUTPUT_SPECIAL, output);
}
Also used : Fieldref(org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref) Reportedref(org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Reportedref) XmlPullParser(org.xmlpull.v1.XmlPullParser) Text(org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Text) Section(org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Section) Test(org.junit.Test)

Aggregations

Fieldref (org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref)1 Reportedref (org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Reportedref)1 Section (org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Section)1 Text (org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Text)1 Test (org.junit.Test)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1