Search in sources :

Example 1 with SkipMeProperty

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

the class VCardWriterTest method skipMeException.

@Test
public void skipMeException() throws Throwable {
    VCard vcard = new VCard();
    vcard.addProperty(new SkipMeProperty());
    vcard.addExtendedProperty("X-FOO", "value");
    StringWriter sw = new StringWriter();
    VCardWriter vcw = new VCardWriter(sw, VCardVersion.V3_0);
    vcw.setAddProdId(false);
    vcw.registerScribe(new SkipMeScribe());
    vcw.write(vcard);
    String actual = sw.toString();
    // @formatter:off
    String expected = "BEGIN:VCARD\r\n" + "VERSION:3.0\r\n" + "X-FOO:value\r\n" + "END:VCARD\r\n";
    // @formatter:on
    assertEquals(actual, expected);
}
Also used : StringWriter(java.io.StringWriter) SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) SkipMeProperty(ezvcard.property.SkipMeProperty) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 2 with SkipMeProperty

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

the class XCardDocumentTest method add_skipMeException.

@Test
public void add_skipMeException() throws Throwable {
    VCard vcard = new VCard();
    vcard.addProperty(new SkipMeProperty());
    vcard.addExtendedProperty("x-foo", "value");
    XCardDocument xcard = new XCardDocument();
    XCardDocumentStreamWriter writer = xcard.writer();
    writer.setAddProdId(false);
    writer.registerScribe(new SkipMeScribe());
    writer.write(vcard);
    Document actual = xcard.getDocument();
    // @formatter:off
    String xml = "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<x-foo><unknown>value</unknown></x-foo>" + "</vcard>" + "</vcards>";
    Document expected = XmlUtils.toDocument(xml);
    // @formatter:on
    assertXMLEqual(expected, actual);
}
Also used : XCardDocumentStreamWriter(ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter) SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) SkipMeProperty(ezvcard.property.SkipMeProperty) Document(org.w3c.dom.Document) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 3 with SkipMeProperty

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

the class XCardWriterTest method skipMeException.

@Test
public void skipMeException() throws Exception {
    writer.registerScribe(new SkipMeScribe());
    VCard vcard = new VCard();
    vcard.addProperty(new SkipMeProperty());
    vcard.addExtendedProperty("x-foo", "value");
    writer.write(vcard);
    writer.close();
    // @formatter:off
    String expected = "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<x-foo><unknown>value</unknown></x-foo>" + "</vcard>" + "</vcards>";
    // @formatter:on
    assertOutput(expected);
}
Also used : SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) SkipMeProperty(ezvcard.property.SkipMeProperty) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 4 with SkipMeProperty

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

the class JCardWriterTest method skipMeException.

@Test
public void skipMeException() throws Throwable {
    StringWriter sw = new StringWriter();
    JCardWriter writer = new JCardWriter(sw);
    writer.registerScribe(new SkipMeScribe());
    writer.setAddProdId(false);
    VCard vcard = new VCard();
    vcard.setFormattedName("John Doe");
    vcard.addProperty(new SkipMeProperty());
    writer.write(vcard);
    writer.close();
    // @formatter:off
    String expected = "[\"vcard\"," + "[" + "[\"version\",{},\"text\",\"4.0\"]," + "[\"fn\",{},\"text\",\"John Doe\"]" + "]" + "]";
    // @formatter:on
    assertEquals(expected, sw.toString());
}
Also used : StringWriter(java.io.StringWriter) SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) SkipMeProperty(ezvcard.property.SkipMeProperty) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 5 with SkipMeProperty

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

the class XCardDocumentTest method add_no_scribe_registered.

@Test(expected = IllegalArgumentException.class)
public void add_no_scribe_registered() throws Throwable {
    VCard vcard = new VCard();
    SkipMeProperty property = new SkipMeProperty();
    vcard.addProperty(property);
    XCardDocument xcard = new XCardDocument();
    xcard.addVCard(vcard);
}
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