Search in sources :

Example 6 with SkipMeProperty

use of ezvcard.property.SkipMeProperty in project ez-vcard by mangstadt.

the class XCardWriterTest method write_no_scribe_registered.

@Test
public void write_no_scribe_registered() throws Exception {
    VCard vcard = new VCard();
    vcard.setFormattedName("John Doe");
    writer.write(vcard);
    vcard = new VCard();
    vcard.setFormattedName("Jane Doe");
    vcard.addProperty(new SkipMeProperty());
    try {
        writer.write(vcard);
        fail();
    } catch (IllegalArgumentException e) {
    // should be thrown
    }
    writer.close();
    // the writer should check for scribes before writing anything to the stream
    // @formatter:off
    String expected = "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<fn><text>John Doe</text></fn>" + "</vcard>" + "</vcards>";
    // @formatter:on
    assertOutput(expected);
}
Also used : SkipMeProperty(ezvcard.property.SkipMeProperty) VCard(ezvcard.VCard) Test(org.junit.Test)

Aggregations

VCard (ezvcard.VCard)6 SkipMeProperty (ezvcard.property.SkipMeProperty)6 Test (org.junit.Test)6 SkipMeScribe (ezvcard.io.scribe.SkipMeScribe)4 StringWriter (java.io.StringWriter)2 XCardDocumentStreamWriter (ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter)1 Document (org.w3c.dom.Document)1