use of ezvcard.VCardVersion 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.VCardVersion in project ez-vcard by mangstadt.
the class VCardReaderTest method embedded_vcard.
@Test
public void embedded_vcard() throws Exception {
for (VCardVersion version : VCardVersion.values()) {
/*
* Test against all versions, even though embedded vCards are only
* supported by 3.0.
*/
// @formatter:off
String str = "BEGIN:VCARD\r\n" + "VERSION:" + version + "\r\n" + "AGENT:" + "BEGIN:VCARD\\n" + "VERSION:" + version + "\\n" + "FN:Agent 007\\n" + "AGENT:" + "BEGIN:VCARD\\\\n" + "VERSION:" + version + "\\\\n" + "FN:Agent 009\\\\n" + "END:VCARD\\\\n" + "END:VCARD\r\n" + "FN:John Doe\r\n" + "END:VCARD\r\n";
// @formatter:on
VCardReader reader = new VCardReader(str);
VCard vcard = reader.readNext();
assertVersion(version, vcard);
assertPropertyCount(2, vcard);
assertEquals("John Doe", vcard.getFormattedName().getValue());
{
VCard agentVCard = vcard.getAgent().getVCard();
assertVersion(version, agentVCard);
assertPropertyCount(2, agentVCard);
assertEquals("Agent 007", agentVCard.getFormattedName().getValue());
{
VCard agentAgentVCard = agentVCard.getAgent().getVCard();
assertVersion(version, agentAgentVCard);
assertPropertyCount(1, agentAgentVCard);
assertEquals("Agent 009", agentAgentVCard.getFormattedName().getValue());
}
}
assertParseWarnings(reader);
assertNoMoreVCards(reader);
}
}
use of ezvcard.VCardVersion 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.VCardVersion in project ez-vcard by mangstadt.
the class VCardParameterTest method isSupportedBy.
@Test
public void isSupportedBy() {
assertTrue(VCardParameterImpl.ONE.isSupportedBy(VCardVersion.V2_1));
assertFalse(VCardParameterImpl.ONE.isSupportedBy(VCardVersion.V3_0));
assertFalse(VCardParameterImpl.ONE.isSupportedBy(VCardVersion.V4_0));
for (VCardVersion version : VCardVersion.values()) {
assertTrue(VCardParameterImpl.TWO.isSupportedBy(version));
}
VCardParameterImpl three = new VCardParameterImpl("three");
for (VCardVersion version : VCardVersion.values()) {
assertTrue(three.isSupportedBy(version));
}
}
use of ezvcard.VCardVersion in project ez-vcard by mangstadt.
the class AgentScribeTest method writeText.
@Test
public void writeText() {
sensei.assertWriteText(withUrl).run(url);
for (VCardVersion version : values()) {
try {
scribe.writeText(withVCard, new WriteContext(version, null, false));
fail();
} catch (EmbeddedVCardException e) {
assertEquals(vcard, e.getVCard());
}
}
sensei.assertWriteText(empty).skipMe();
}
Aggregations