use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardReaderTest 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 XCardReaderTest method read_utf8.
@Test
public void read_utf8() throws Exception {
// @formatter:off
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<note><text>\u019dote</text></note>" + "</vcard>" + "</vcards>";
File file = tempFolder.newFile();
Writer writer = new Utf8Writer(file);
writer.write(xml);
writer.close();
XCardReader reader = new XCardReader(file);
VCardAsserter asserter = new VCardAsserter(reader);
asserter.next(V4_0);
asserter.simpleProperty(Note.class).value("\u019dote").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardReaderTest method read_namespace_prefix.
@Test
public void read_namespace_prefix() throws Exception {
// @formatter:off
VCardAsserter asserter = readXml("<v:vcards xmlns:v=\"" + V4_0.getXmlNamespace() + "\">" + "<v:vcard>" + "<v:fn><x:text xmlns:x=\"" + V4_0.getXmlNamespace() + "\">Dr. Gregory House M.D.</x:text></v:fn>" + "</v:vcard>" + "</v:vcards>");
asserter.next(V4_0);
asserter.simpleProperty(FormattedName.class).value("Dr. Gregory House M.D.").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardReaderTest method read_preserve_whitespace.
@Test
public void read_preserve_whitespace() throws Exception {
// @formatter:off
VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<note><text> This \t is \n a note </text></note>" + "</vcard>" + "</vcards>");
asserter.next(V4_0);
asserter.simpleProperty(Note.class).value(" This \t is \n a note ").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class XCardReaderTest method read_identical_element_names.
@Test
public void read_identical_element_names() throws Exception {
// @formatter:off
VCardAsserter asserter = readXml("<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<vcard>" + "<parameters>" + "<parameters><text>paramValue1</text></parameters>" + "<group><text>paramValue2</text></group>" + "</parameters>" + "<vcard>propValue</vcard>" + "</vcard>" + "<group name=\"grp\">" + "<group>" + "<text>value</text>" + "</group>" + "</group>" + "</vcard>" + "</vcards>");
asserter.next(V4_0);
asserter.rawProperty("VCARD").dataType(VCardDataType.get("VCARD")).value("propValue").param("PARAMETERS", "paramValue1").param("GROUP", "paramValue2").noMore();
asserter.rawProperty("GROUP").dataType(VCardDataType.TEXT).group("grp").value("value").noMore();
asserter.done();
// @formatter:on
}
Aggregations