use of ezvcard.property.FormattedName in project ez-vcard by mangstadt.
the class EzvcardTest method writeXml_dom.
@Test
public void writeXml_dom() throws Exception {
VCard vcard = new VCard();
vcard.setFormattedName(new FormattedName("John Doe"));
Document actual = Ezvcard.writeXml(vcard).prodId(false).dom();
// @formatter:off
String html = "<vcards xmlns=\"" + VCardVersion.V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<fn><text>John Doe</text></fn>" + "</vcard>" + "</vcards>";
Document expected = XmlUtils.toDocument(html);
// @formatter:on
assertXMLEqual(expected, actual);
}
use of ezvcard.property.FormattedName in project ez-vcard by mangstadt.
the class EzvcardTest method write_multiple.
@Test
public void write_multiple() throws Exception {
VCard vcard1 = new VCard();
vcard1.setVersion(VCardVersion.V2_1);
vcard1.setFormattedName(new FormattedName("John Doe"));
VCard vcard2 = new VCard();
vcard2.setVersion(VCardVersion.V3_0);
vcard2.setFormattedName(new FormattedName("Jane Doe"));
VCard vcard3 = new VCard();
vcard3.setVersion(VCardVersion.V4_0);
vcard3.setFormattedName(new FormattedName("Janet Doe"));
String actual = Ezvcard.write(vcard1, vcard2, vcard3).go();
assertTrue(actual.matches("(?s)BEGIN:VCARD.*?VERSION:2\\.1.*?FN:John Doe.*?END:VCARD.*?BEGIN:VCARD.*?VERSION:3\\.0.*?FN:Jane Doe.*?END:VCARD.*?BEGIN:VCARD.*?VERSION:4\\.0.*?FN:Janet Doe.*?END:VCARD.*"));
}
use of ezvcard.property.FormattedName in project ez-vcard by mangstadt.
the class EzvcardTest method writeXml_indent.
@Test
public void writeXml_indent() throws Exception {
VCard vcard = new VCard();
vcard.setFormattedName(new FormattedName("John Doe"));
String actual = Ezvcard.writeXml(vcard).indent(2).go();
assertTrue(actual.contains(" <fn>" + NEWLINE + " <text>John Doe</text>" + NEWLINE + " </fn>"));
}
use of ezvcard.property.FormattedName in project ez-vcard by mangstadt.
the class EzvcardTest method write_caretEncoding.
@Test
public void write_caretEncoding() throws Exception {
VCard vcard = new VCard();
vcard.setVersion(VCardVersion.V4_0);
FormattedName fn = vcard.setFormattedName("test");
fn.getParameters().put("X-TEST", "George Herman \"Babe\" Ruth");
// default should be "false"
try {
Ezvcard.write(vcard).go();
fail("IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// expected
}
String actual = Ezvcard.write(vcard).caretEncoding(true).go();
assertTrue(actual.contains("\r\nFN;X-TEST=George Herman ^'Babe^' Ruth:"));
try {
Ezvcard.write(vcard).caretEncoding(false).go();
fail("IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations