assertEquals(incorrectNote, parsedNote);
}
private static VCardImpl getFullVCardNoErrors() throws IOException, URISyntaxException
{
VCardImpl vcard = new VCardImpl();
vcard.setVersion(new VersionType(VCardVersion.V3_0));
NameType name = new NameType();
name.setName("VCard for John Doe");
vcard.setName(name);
ProfileType profile = new ProfileType();
profile.setProfile("VCard");
vcard.setProfile(profile);
SourceType source = new SourceType();
source.setSource("Whatever");
vcard.setSource(source);
NType n = new NType();
n.setEncodingType(EncodingType.QUOTED_PRINTABLE);
n.setCharset(Charset.forName("UTF-8"));
n.setLanguage(LanguageType.EN);
n.setFamilyName("DÖe");
// n.setFamilyName("Doe");
n.setGivenName("John");
n.addHonorificPrefix("Mr.");
n.addHonorificSuffix("I");
n.addAdditionalName("Johny");
vcard.setN(n);
FNType fn = new FNType();
fn.setFormattedName("John \"Johny\" Doe");
fn.setCharset(Charset.forName("UTF-8"));
fn.setLanguage(LanguageType.EN);
vcard.setFN(fn);
NicknameType nicknames = new NicknameType();
nicknames.addNickname("Johny");
nicknames.addNickname("JayJay");
vcard.setNickname(nicknames);
CategoriesType categories = new CategoriesType();
categories.addCategory("Category 1");
categories.addCategory("Category 2");
categories.addCategory("Category 3");
vcard.setCategories(categories);
vcard.setSecurityClass(new ClassType("Public"));
vcard.setProdId(new ProdIdType("31e78c0d-fb07-479d-b6af-95a9a3f2916f"));
vcard.setSortString(new SortStringType("JOHN"));
vcard.setMailer(new MailerType("Mozilla Thunderbird"));
vcard.setTitle(new TitleType("Generic Accountant"));
vcard.setRole(new RoleType("Counting Money"));
OrgType organizations = new OrgType();
organizations.setOrgName("IBM");
organizations.addOrgUnit("SUN");
vcard.setOrg(organizations);
vcard.setUid(new UidType("c0ff639f-9633-4e57-bcfd-55079cfd9d65"));
vcard.addUrl(new UrlType(new URL("http://www.sun.com")));
vcard.setGeo(new GeoType(3.4f, -2.6f));
Calendar birthday = Calendar.getInstance();
birthday.clear();
birthday.set(Calendar.YEAR, 1980);
birthday.set(Calendar.MONTH, 4);
birthday.set(Calendar.DAY_OF_MONTH, 21);
vcard.setBDay(new BDayType(birthday));
Calendar revision = Calendar.getInstance();
revision.clear();
revision.set(Calendar.YEAR, 2012);
revision.set(Calendar.MONTH, 6);
revision.set(Calendar.DAY_OF_MONTH, 8);
vcard.setRev(new RevType(revision));
vcard.setTz(new TzType(Calendar.getInstance().getTimeZone()));
AdrType address1 = new AdrType();
address1.setCharset("UTF-8");
address1.setExtendedAddress("");
address1.setCountryName("U.S.A.");
address1.setLocality("New York");
address1.setRegion("New York");
address1.setPostalCode("NYC887");
address1.setPostOfficeBox("25334");
address1.setStreetAddress("South cresent drive, Building 5, 3rd floor");
address1.addParam(AdrParamType.HOME)
.addParam(AdrParamType.PARCEL)
.addParam(AdrParamType.PREF)
.addExtendedParam(new ExtendedParamType("CUSTOM-PARAM-TYPE", VCardTypeName.ADR))
.addExtendedParam(new ExtendedParamType("CUSTOM-PARAM-TYPE", "WITH-CUSTOM-VALUE", VCardTypeName.ADR));
LabelType labelForAddress1 = new LabelType();
labelForAddress1.setCharset("UTF-8");
labelForAddress1.addParam(LabelParamType.HOME)
.addParam(LabelParamType.PARCEL)
.addParam(LabelParamType.PREF)
.setLabel("John Doe\nNew York, NewYork,\nSouth Crecent Drive,\nBuilding 5, floor 3,\nUSA");
address1.setLabel(labelForAddress1);
vcard.addAdr(address1);
TelType telephone = new TelType();
telephone.setCharset("UTF-8");
telephone.setTelephone("+1 (212) 204-34456");
telephone.addParam(TelParamType.CELL)
.addParam(TelParamType.HOME)
.setParameterTypeStyle(ParameterTypeStyle.PARAMETER_VALUE_LIST);
vcard.addTel(telephone);
TelType telephone2 = new TelType();
telephone2.setTelephone("00-1-212-555-7777");
telephone2.addParam(TelParamType.FAX)
.addParam(TelParamType.WORK)
.setParameterTypeStyle(ParameterTypeStyle.PARAMETER_LIST);
vcard.addTel(telephone2);
EmailType email = new EmailType();
email.setEmail("john.doe@ibm.com");
email.addParam(EmailParamType.IBMMAIL)
.addParam(EmailParamType.INTERNET)
.addParam(EmailParamType.PREF)
.setCharset("UTF-8");
vcard.addEmail(email);
vcard.addEmail(new EmailType("billy_bob@gmail.com"));
NoteType note = new NoteType();
note.setNote("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.");
vcard.addNote(note);
PhotoType photo1 = new PhotoType();
photo1.setCompression(false);
photo1.setEncodingType(EncodingType.BINARY);
photo1.setImageMediaType(ImageMediaType.PNG);
byte[] tuxPicture1 = Util.getFileAsBytes(new File("test/images/smallTux.png"));
photo1.setPhoto(tuxPicture1);
vcard.addPhoto(photo1);
LogoType logo = new LogoType();
logo.setCompression(true);
logo.setEncodingType(EncodingType.BINARY);
logo.setImageMediaType(ImageMediaType.PNG);
byte[] tuxPicture2 = Util.getFileAsBytes(new File("test/images/smallTux.png"));
logo.setLogo(tuxPicture2);
vcard.addLogo(logo);
SoundType sound = new SoundType();
sound.setCompression(false);
sound.setEncodingType(EncodingType.BINARY);
sound.setAudioMediaType(AudioMediaType.OGG);
sound.setSoundURI(new File("test/images/smallTux.png").toURI());
vcard.addSound(sound);
KeyType key = new KeyType();
key.setKeyTextType(KeyTextType.GPG);
key.setEncodingType(EncodingType.BINARY);
key.setCompression(false);
byte[] keyBytes = Util.getFileAsBytes(new File("test/images/smallTux.png"));
key.setKey(keyBytes);
vcard.addKey(key);
ExtendedType xGenerator = new ExtendedType("X-GENERATOR", "Cardme Generator");
xGenerator.setCharset("UTF-8");
vcard.addExtendedType(xGenerator);
vcard.addExtendedType(new ExtendedType("X-LONG-STRING", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
vcard.addImpp(new ImppType("im:alice@example.com"));
vcard.addImpp(new ImppType(new URI("im:alice2@example.com")));
ImppType impp = new ImppType();
impp.setUri(new URI("im:alice3@example.com"));
impp.addParam(ImppParamType.HOME)
.addParam(ImppParamType.PREF)
.addExtendedParam(new ExtendedParamType("X-BLA", "BLE", VCardTypeName.IMPP));
vcard.addImpp(impp);
((VCardErrorHandler)vcard).setThrowExceptions(false);
return vcard;
}