use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class VCardReaderTest method cannotParseException.
@Test
public void cannotParseException() throws Exception {
for (VCardVersion version : VCardVersion.values()) {
// @formatter:off
String str = "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "group.CANNOTPARSE;PARAM=value;VALUE=text:value\r\n" + "X-FOO:value\r\n" + "END:VCARD\r\n";
VCardReader reader = new VCardReader(str);
reader.registerScribe(new CannotParseScribe());
VCardAsserter asserter = new VCardAsserter(reader);
asserter.next(version);
asserter.rawProperty("X-FOO").value("value").noMore();
asserter.rawProperty("CANNOTPARSE").group("group").param("PARAM", "value").dataType(VCardDataType.TEXT).value("value").noMore();
asserter.warnings(25);
asserter.done();
// @formatter:on
}
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class VCardReaderTest method type_parameter_enclosed_in_double_quotes.
/**
* Account for an error in the 4.0 specification, which places multi-valued
* TYPE parameters in double quotes.
*/
@Test
public void type_parameter_enclosed_in_double_quotes() throws Exception {
VCardVersion version = V2_1;
{
// @formatter:off
VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "PROP;TYPE=\"one,two,,three\";FOO=\"four,five,,six\":\r\n" + "END:VCARD\r\n");
asserter.next(version);
asserter.rawProperty("PROP").param("TYPE", "\"one,two,,three\"").param("FOO", "\"four,five,,six\"").value("").noMore();
asserter.done();
// @formatter:on
}
for (VCardVersion v : each(V3_0, V4_0)) {
// @formatter:off
VCardAsserter asserter = read("BEGIN:VCARD\r\n" + "VERSION:" + v + "\r\n" + "PROP;TYPE=\"one,two,,three\";FOO=\"four,five,,six\":\r\n" + "END:VCARD\r\n");
asserter.next(v);
asserter.rawProperty("PROP").param("TYPE", "one", "two", "", "three").param("FOO", "four,five,,six").value("").noMore();
asserter.done();
// @formatter:on
}
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardDocumentTest method read_groups.
@Test
public void read_groups() throws Exception {
// @formatter:off
VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<group name=\"item1\">" + "<fn><text>John Doe</text></fn>" + "<note><text>Hello world!</text></note>" + "</group>" + "<group>" + "<prodid><text>no name attribute</text></prodid>" + "</group>" + "<note><text>A property without a group</text></note>" + "</vcard>" + "</vcards>");
asserter.next(V4_0);
asserter.simpleProperty(FormattedName.class).group("item1").value("John Doe").noMore();
asserter.simpleProperty(Note.class).group("item1").value("Hello world!").next().value("A property without a group").noMore();
asserter.simpleProperty(ProductId.class).value("no name attribute").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardDocumentTest method read_parameters.
@Test
public void read_parameters() throws Exception {
// @formatter:off
VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + // zero params
"<note>" + "<text>Note 1</text>" + "</note>" + // one param
"<note>" + "<parameters>" + "<altid><text>1</text></altid>" + "</parameters>" + "<text>Hello world!</text>" + "</note>" + // one param, but doesn't have a value element, so it should be ignored
"<note>" + "<parameters>" + "<altid>1</altid>" + "</parameters>" + "<text>Hallo Welt!</text>" + "</note>" + // two params
"<note>" + "<parameters>" + "<altid><text>1</text></altid>" + "<language><language-tag>fr</language-tag></language>" + "</parameters>" + "<text>Bonjour tout le monde!</text>" + "</note>" + // a param with multiple values
"<tel>" + "<parameters>" + "<type>" + "<text>work</text>" + "<text>voice</text>" + "</type>" + "</parameters>" + "<uri>tel:+1-555-555-1234</uri>" + "</tel>" + "</vcard>" + "</vcards>");
asserter.next(V4_0);
asserter.simpleProperty(Note.class).value("Note 1").next().value("Hello world!").param("ALTID", "1").next().value("Hallo Welt!").next().value("Bonjour tout le monde!").param("ALTID", "1").param("LANGUAGE", "fr").noMore();
asserter.telephone().uri(new TelUri.Builder("+1-555-555-1234").build()).types(TelephoneType.WORK, TelephoneType.VOICE).noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardDocumentTest method readFile.
private static VCardAsserter readFile(String file) throws SAXException, IOException {
XCardDocument document = new XCardDocument(XCardDocumentTest.class.getResourceAsStream(file));
StreamReader reader = document.reader();
return new VCardAsserter(reader);
}
Aggregations