tobj = new TransferObject(1);
root.setValue("assistant2", tobj);
tobj.setValue("card", tobj = new TransferObject(1));
tobj.setValue("fullName", "Sir Arthur Conan Doyle");
m_formatter.format(root, message, new WriterOutput(m_writer));
assertEquals("BEGIN:VCARD\r\n" +
"VERSION:2.1\r\n" +
"FN:Sherlock Holmes\r\n" +
"ORG:NexJ Systems Inc.;R&D\r\n" +
"TEL;TYPE=VOICE:555-1234\r\n" +
"X-NexJ-Collection;p1=1,1,2,3,5,8;p2=0;p3=4,9,16;p4=123\\;456\\:789:abc,def,g\\,hi\r\n" +
"Home.TEL:555-0000\r\n" +
"Home.NOTE:Evenings and weekends only.\r\n" +
"BEGIN:VCARD_CONTAINED\r\n" +
"VERSION:2.1\r\n" +
"N:Watson,,,Dr.\r\n" +
"END:VCARD_CONTAINED\r\n" +
"BEGIN:VCARD\r\n" +
"VERSION:2.1\r\n" +
"FN:Moriarty\r\n" +
"END:VCARD\r\n" +
"TEL;TYPE=VOICE:This is a really long\r\n" +
" line....12345678941234567895123456789612345678971234567 89\r\n" +
"TEL;TYPE=PIZZA:(416) 967-1111\r\n" +
"ADR;TYPE=WORK;ENCODING=QUOTED-PRINTABLE:;;4101 Yonge Street=0D=0AUnit 501;N=\r\n" +
"orth York;ON;111111;Canada\r\n" +
"LOGO;TYPE=PNG;ENCODING=BASE64:MTIzQUJD\r\n" +
"\r\n" +
"X-NexJ-IntlName;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Pr=E6tor\r\n" +
"AGENT;NUM=1:BEGIN:VCARD\r\n" +
"VERSION:2.1\r\n" +
"FN:Dr. John H. Watson\r\n" +
"END:VCARD\r\n" +
"AGENT;NUM=2:BEGIN:VCARD\r\n" +
"VERSION:2.1\r\n" +
"FN:Sir Arthur Conan Doyle\r\n" +
"END:VCARD\r\n" +
"END:vCard\r\n",
m_writer.toString());
try
{
companyInfo.add("extra");
m_writer = new StringWriter();
m_formatter.format(root, message, new WriterOutput(m_writer));
fail();
}
catch (IntegrationException ex)
{
assertEquals("err.integration.maxPartCount", ex.getErrorCode());
assertEquals("VCard_v21 company", ex.getErrorArgs()[0]);
}
finally
{
companyInfo.remove(2);
}
try
{
p2List.add(Primitive.createInteger(42));
p2List.add(Primitive.createInteger(21));
m_writer = new StringWriter();
m_formatter.format(root, message, new WriterOutput(m_writer));
fail();
}
catch (IntegrationException ex)
{
assertEquals("err.integration.maxPartCount", ex.getErrorCode());
assertEquals("VCard_v21 collection p2", ex.getErrorArgs()[0]);
}
finally
{
p2List.remove(2);
p2List.remove(1);
}
try
{
root.removeValue("fullName");
m_writer = new StringWriter();
m_formatter.format(root, message, new WriterOutput(m_writer));
fail();
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());
assertEquals("VCard_v21 fullName", ex.getErrorArgs()[0]);
}
finally
{
root.setValue("fullName", "Sherlock Holmes");
}
try
{
valList.remove(2);
m_writer = new StringWriter();
m_formatter.format(root, message, new WriterOutput(m_writer));
fail();
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());
assertEquals("VCard_v21 collection value", ex.getErrorArgs()[0]);
}
finally
{
valList.add("ghi");
}
try
{
tobj = (TransferObject)root.getValue("collection");
tobj.removeValue("value");
m_writer = new StringWriter();
m_formatter.format(root, message, new WriterOutput(m_writer));
fail();
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());
assertEquals("VCard_v21 collection value", ex.getErrorArgs()[0]);
}
finally
{
tobj.setValue("value", valList);
}
try
{
tobj = (TransferObject)root.getValue("collection");
tobj.removeValue("p1");
m_writer = new StringWriter();
m_formatter.format(root, message, new WriterOutput(m_writer));
fail();
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());