diff --git a/src/java/davmail/exchange/VCardReader.java b/src/java/davmail/exchange/VCardReader.java index e9443d26..2d5c0516 100644 --- a/src/java/davmail/exchange/VCardReader.java +++ b/src/java/davmail/exchange/VCardReader.java @@ -73,7 +73,12 @@ public class VCardReader extends ICSBufferedReader { if (params == null) { params = new HashMap>(); } - params.put(paramName, paramValues); + if (params.get(paramName) == null) { + params.put(paramName, paramValues); + } else { + params.get(paramName).addAll(paramValues); + } + } protected void addValue(String value) { diff --git a/src/test/davmail/exchange/TestExchangeSessionContact.java b/src/test/davmail/exchange/TestExchangeSessionContact.java index edcc26de..fa107ae7 100644 --- a/src/test/davmail/exchange/TestExchangeSessionContact.java +++ b/src/test/davmail/exchange/TestExchangeSessionContact.java @@ -18,14 +18,12 @@ */ package davmail.exchange; -import davmail.Settings; import org.apache.commons.codec.binary.Base64; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.List; import java.util.UUID; /** @@ -295,22 +293,21 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase } - public void testSearchPublicContacts() throws IOException { - String folderPath = Settings.getProperty("davmail.publicContactFolder"); - List contacts = session.searchContacts(folderPath, ExchangeSession.CONTACT_ATTRIBUTES, null); - int count = 0; - for (ExchangeSession.Contact contact : contacts) { - System.out.println("Contact "+(++count)+ '/' +contacts.size()+session.getItem(folderPath, contact.getName())); - } + public void testMultipleTypesParamName() throws IOException { + ExchangeSession.Contact contact = (ExchangeSession.Contact) session.getItem("testcontactfolder", itemName); + + VCardWriter vCardWriter = new VCardWriter(); + vCardWriter.startCard(); + vCardWriter.appendProperty("TEL;TYPE=CELL;TYPE=PREF", "mobile"); + vCardWriter.endCard(); + + ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), contact.etag, null); + assertEquals(200, result.status); + + contact = (ExchangeSession.Contact) session.getItem("testcontactfolder", itemName); + + assertEquals("mobile", contact.get("mobile")); + } - public void testSearchPublicContactsWithPicture() throws IOException { - String folderPath = Settings.getProperty("davmail.publicContactFolder"); - List contacts = session.searchContacts(folderPath, ExchangeSession.CONTACT_ATTRIBUTES, session.isTrue("haspicture")); - int count = 0; - for (ExchangeSession.Contact contact : contacts) { - System.out.println("Contact "+(++count)+ '/' +contacts.size()+contact.getBody()); - assertNotNull(session.getContactPhoto(contact)); - } - } } diff --git a/src/test/davmail/exchange/TestExchangeSessionSearchContact.java b/src/test/davmail/exchange/TestExchangeSessionSearchContact.java new file mode 100644 index 00000000..4391257b --- /dev/null +++ b/src/test/davmail/exchange/TestExchangeSessionSearchContact.java @@ -0,0 +1,50 @@ +/* + * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway + * Copyright (C) 2010 Mickael Guessant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package davmail.exchange; + +import davmail.Settings; + +import java.io.IOException; +import java.util.List; + +/** + * Test contact search. + */ +@SuppressWarnings({"UseOfSystemOutOrSystemErr"}) +public class TestExchangeSessionSearchContact extends AbstractExchangeSessionTestCase { + public void testSearchPublicContacts() throws IOException { + String folderPath = Settings.getProperty("davmail.publicContactFolder"); + List contacts = session.searchContacts(folderPath, ExchangeSession.CONTACT_ATTRIBUTES, null); + int count = 0; + for (ExchangeSession.Contact contact : contacts) { + System.out.println("Contact " + (++count) + '/' + contacts.size() + session.getItem(folderPath, contact.getName())); + } + } + + public void testSearchPublicContactsWithPicture() throws IOException { + String folderPath = Settings.getProperty("davmail.publicContactFolder"); + List contacts = session.searchContacts(folderPath, ExchangeSession.CONTACT_ATTRIBUTES, session.isTrue("haspicture")); + int count = 0; + for (ExchangeSession.Contact contact : contacts) { + System.out.println("Contact " + (++count) + '/' + contacts.size() + contact.getBody()); + assertNotNull(session.getContactPhoto(contact)); + } + } + +}