use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class VCardReaderTest method read_multiple.
@Test
public void read_multiple() throws Exception {
// @formatter:off
VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:2.1\r\n" + "FN:John Doe\r\n" + "END:VCARD\r\n" + "BEGIN:VCARD\r\n" + "VERSION:3.0\r\n" + "FN:Jane Doe\r\n" + "END:VCARD\r\n");
asserter.next(V2_1);
asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
asserter.next(V3_0);
asserter.simpleProperty(FormattedName.class).value("Jane Doe").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class VCardReaderTest method label_properties.
/**
* LABEL properties should be assigned to an ADR and stored in the
* "Address.getLabel()" field. LABELs that could not be assigned to an ADR
* should go in "VCard.getOrphanedLabels()".
*/
@Test
public void label_properties() throws Exception {
for (VCardVersion version : VCardVersion.values()) {
// @formatter:off
VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version.getVersion() + "\r\n" + "ADR;TYPE=home;TYPE=parcel:;;123 Main St.;Austin;TX;91827;USA\r\n" + "LABEL;TYPE=parcel;TYPE=home:123 Main St.\\nAustin\\, TX 91827\\nUSA\r\n" + "ADR;TYPE=work:;;200 Broadway;New York;NY;12345;USA\r\n" + "LABEL;TYPE=parcel:200 Broadway\\nNew York\\, NY 12345\\nUSA\r\n" + "END:VCARD\r\n");
asserter.next(version);
asserter.address().streetAddress("123 Main St.").locality("Austin").region("TX").postalCode("91827").country("USA").label("123 Main St." + NEWLINE + "Austin, TX 91827" + NEWLINE + "USA").types(AddressType.HOME, AddressType.PARCEL).next().streetAddress("200 Broadway").locality("New York").region("NY").postalCode("12345").country("USA").types(AddressType.WORK).noMore();
asserter.simpleProperty(Label.class).value("200 Broadway" + NEWLINE + "New York, NY 12345" + NEWLINE + "USA").param("TYPE", "parcel").noMore();
asserter.done();
// @formatter:on
}
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class VCardReaderTest method nameless_parameters.
/**
* All nameless parameters should be assigned a name.
*/
@Test
public void nameless_parameters() throws Exception {
for (VCardVersion version : VCardVersion.values()) {
// @formatter:off
VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "PROP;TEXT;QUOTED-PRINTABLE;HOME;FOO:\r\n" + "END:VCARD\r\n");
asserter.next(version);
asserter.rawProperty("PROP").param("ENCODING", "QUOTED-PRINTABLE").param("TYPE", "HOME", "FOO").dataType(VCardDataType.TEXT).value("").noMore();
asserter.done();
// @formatter:on
}
}
use of ezvcard.property.asserter.VCardAsserter 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
}
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardDocumentTest method readXml.
private static VCardAsserter readXml(String xml) throws SAXException {
XCardDocument xcard = new XCardDocument(xml);
StreamReader reader = xcard.reader();
return new VCardAsserter(reader);
}
Aggregations