Search in sources :

Example 1 with SkipMeScribe

use of ezvcard.io.scribe.SkipMeScribe in project ez-vcard by mangstadt.

the class VCardReaderTest method skipMeException.

@Test
public void skipMeException() throws Exception {
    for (VCardVersion version : VCardVersion.values()) {
        // @formatter:off
        String str = "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "SKIPME:value\r\n" + "X-FOO:value\r\n" + "END:VCARD\r\n";
        VCardReader reader = new VCardReader(str);
        reader.registerScribe(new SkipMeScribe());
        VCardAsserter asserter = new VCardAsserter(reader);
        asserter.next(version);
        asserter.rawProperty("X-FOO").value("value").noMore();
        asserter.warnings(22);
        asserter.done();
    // @formatter:on
    }
}
Also used : SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) VCardVersion(ezvcard.VCardVersion) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 2 with SkipMeScribe

use of ezvcard.io.scribe.SkipMeScribe 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 3 with SkipMeScribe

use of ezvcard.io.scribe.SkipMeScribe 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 4 with SkipMeScribe

use of ezvcard.io.scribe.SkipMeScribe 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 5 with SkipMeScribe

use of ezvcard.io.scribe.SkipMeScribe in project ez-vcard by mangstadt.

the class JCardReaderTest method skipMeException.

@Test
public void skipMeException() throws Throwable {
    // @formatter:off
    String json = "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"skipme\", {}, \"text\", \"value\"]" + "]" + "]";
    // @formatter:on
    JCardReader reader = new JCardReader(json);
    reader.registerScribe(new SkipMeScribe());
    VCardAsserter asserter = new VCardAsserter(reader);
    asserter.next(V4_0);
    asserter.warnings(22);
    asserter.done();
}
Also used : SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Aggregations

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