Search in sources :

Example 6 with SkipMeScribe

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

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

the class HCardParserTest method skipMeException.

@Test
public void skipMeException() throws Exception {
    // @formatter:off
    String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"skipme\">value</span>" + "<span class=\"x-foo\">value</span>" + "</div>" + "</body>" + "</html>";
    HCardParser parser = new HCardParser(html);
    parser.registerScribe(new SkipMeScribe());
    VCardAsserter asserter = new VCardAsserter(parser);
    asserter.next(V3_0);
    asserter.rawProperty("x-foo").value("value").noMore();
    asserter.warnings(22);
    asserter.done();
// @formatter:on
}
Also used : SkipMeScribe(ezvcard.io.scribe.SkipMeScribe) VCardAsserter(ezvcard.property.asserter.VCardAsserter) Test(org.junit.Test)

Example 8 with SkipMeScribe

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

the class XCardReaderTest method skipMeException.

@Test
public void skipMeException() throws Exception {
    // @formatter:off
    String xml = "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<skipme><text>value</text></skipme>" + "<x-foo><text>value</text></x-foo>" + "</vcard>" + "</vcards>";
    XCardReader reader = new XCardReader(xml);
    reader.registerScribe(new SkipMeScribe());
    VCardAsserter asserter = new VCardAsserter(reader);
    asserter.next(V4_0);
    asserter.rawProperty("x-foo").dataType(VCardDataType.TEXT).value("value").noMore();
    asserter.warnings(22);
    asserter.done();
// @formatter:on
}
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