use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class HCardParserTest method assign_labels_to_addresses.
@Test
public void assign_labels_to_addresses() throws Exception {
// @formatter:off
VCardAsserter asserter = readHtml("<html>" + "<body>" + "<div class=\"vcard\">" + "<div class=\"adr\">" + "<span class=\"type\">Home</span>:<br>" + "<span class=\"street-address\">123 Main St.</span><br>" + "<span class=\"locality\">Austin</span>, <span class=\"region\">TX</span> <span class=\"postal-code\">12345</span>" + "</div>" + "<div class=\"label\"><abbr class=\"type\" title=\"home\"></abbr>123 Main St.\nAustin, TX 12345</div>" + "<abbr class=\"label\" title=\"456 Wall St., New York, NY 67890\"><abbr class=\"type\" title=\"work\"></abbr></abbr>" + "</div>" + "</body>" + "</html>");
asserter.next(V3_0);
asserter.address().streetAddress("123 Main St.").locality("Austin").region("TX").postalCode("12345").label("123 Main St. Austin, TX 12345").types(AddressType.HOME).noMore();
asserter.simpleProperty(Label.class).value("456 Wall St., New York, NY 67890").param("TYPE", "work").noMore();
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class HCardParserTest method read_multiple.
@Test
public void read_multiple() throws Exception {
// @formatter:off
VCardAsserter asserter = readHtml("<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"fn\">John Doe</span>" + "</div>" + "<div class=\"vcard\">" + "<span class=\"fn\">Jane Doe</span>" + "</div>" + "</body>" + "</html>");
asserter.next(V3_0);
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 HCardParserTest method cannotParseException.
@Test
public void cannotParseException() throws Exception {
// @formatter:off
String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"cannotparse\">value</span>" + "<span class=\"x-foo\">value</span>" + "</div>" + "</body>" + "</html>";
HCardParser parser = new HCardParser(html);
parser.registerScribe(new CannotParseScribe());
VCardAsserter asserter = new VCardAsserter(parser);
asserter.next(V3_0);
asserter.rawProperty("x-foo").value("value").noMore();
asserter.rawProperty("cannotparse").value("<span class=\"cannotparse\">value</span>").noMore();
asserter.warnings(25);
asserter.done();
// @formatter:on
}
use of ezvcard.property.asserter.VCardAsserter 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
}
use of ezvcard.property.asserter.VCardAsserter in project ez-vcard by mangstadt.
the class HCardParserTest method non_existant_anchor.
@Test
public void non_existant_anchor() throws Exception {
// @formatter:off
String html = "<html>" + "<body>" + "<div class=\"vcard\">" + "<span class=\"fn\">John Doe</span>" + "</div>" + "<div id=\"anchor\">" + "<div class=\"vcard\">" + "<span class=\"fn\">Jane Doe</span>" + "</div>" + "</div>" + "</body>" + "</html>";
HCardParser parser = new HCardParser(html, "http://johndoe.com/vcard.html#non-existant");
VCardAsserter asserter = new VCardAsserter(parser);
asserter.next(V3_0);
asserter.simpleProperty(FormattedName.class).value("John Doe").noMore();
asserter.simpleProperty(Source.class).value("http://johndoe.com/vcard.html#non-existant").noMore();
asserter.next(V3_0);
asserter.simpleProperty(FormattedName.class).value("Jane Doe").noMore();
asserter.simpleProperty(Source.class).value("http://johndoe.com/vcard.html#non-existant").noMore();
asserter.done();
// @formatter:on
}
Aggregations