diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 89840ee8..e3afd213 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -53,6 +53,7 @@ import java.util.*; * Exchange session through Outlook Web Access (DAV) */ public abstract class ExchangeSession { + protected static final Logger LOGGER = Logger.getLogger("davmail.exchange.ExchangeSession"); /** @@ -977,6 +978,16 @@ public abstract class ExchangeSession { createFolder(folderName, "IPF.Appointment"); } + /** + * Create Exchange contact folder. + * + * @param folderName logical folder name + * @throws IOException on error + */ + public void createContactFolder(String folderName) throws IOException { + createFolder(folderName, "IPF.Contact"); + } + /** * Create Exchange folder with given folder class. * diff --git a/src/test/davmail/exchange/AbstractExchangeSessionTestCase.java b/src/test/davmail/exchange/AbstractExchangeSessionTestCase.java index 8b69564e..899a3ec1 100644 --- a/src/test/davmail/exchange/AbstractExchangeSessionTestCase.java +++ b/src/test/davmail/exchange/AbstractExchangeSessionTestCase.java @@ -58,6 +58,9 @@ public class AbstractExchangeSessionTestCase extends TestCase { Settings.setProperty("davmail.username", username); Settings.setProperty("davmail.password", password); } + + //Settings.setProperty("davmail.enableEws", "true"); + DavGatewaySSLProtocolSocketFactory.register(); // force server mode Settings.setProperty("davmail.server", "true"); diff --git a/src/test/davmail/exchange/TestExchangeSessionFolder.java b/src/test/davmail/exchange/TestExchangeSessionFolder.java new file mode 100644 index 00000000..9f653e84 --- /dev/null +++ b/src/test/davmail/exchange/TestExchangeSessionFolder.java @@ -0,0 +1,105 @@ +/* + * 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 java.io.IOException; + +/** + * Test folder methods. + */ +public class TestExchangeSessionFolder extends AbstractExchangeSessionTestCase { + public void testCreateFolder() throws IOException { + session.createMessageFolder("test"); + } + + public void testGetFolder() throws IOException { + ExchangeSession.Folder folder = session.getFolder("test"); + assertNotNull(folder); + assertEquals("test", folder.folderPath); + assertEquals("test", folder.displayName); + assertEquals("IPF.Note", folder.folderClass); + assertEquals(0, folder.unreadCount); + assertFalse(folder.hasChildren); + assertFalse(folder.noInferiors); + assertNotNull(folder.ctag); + assertNotNull(folder.etag); + } + + public void testSubFolder() throws IOException { + session.createMessageFolder("test/subfolder"); + ExchangeSession.Folder folder = session.getFolder("test/subfolder"); + assertNotNull(folder); + assertEquals("test/subfolder", folder.folderPath); + assertEquals("subfolder", folder.displayName); + session.deleteFolder("test/subfolder"); + } + + public void testUpdateFolder() throws IOException { + // TODO: implement + } + + public void testMoveFolder() throws IOException { + session.createMessageFolder("tomove"); + session.moveFolder("tomove", "test/moved"); + session.deleteFolder("test/moved"); + } + + public void testDeleteFolder() throws IOException { + session.deleteFolder("test"); + } + + public void testCalendarFolder() throws IOException { + String folderName = "testcalendar"; + session.createCalendarFolder(folderName); + ExchangeSession.Folder folder = session.getFolder(folderName); + assertNotNull(folder); + assertEquals("IPF.Appointment", folder.folderClass); + session.deleteFolder(folderName); + } + + public void testContactFolder() throws IOException { + String folderName = "testcontact"; + session.createContactFolder(folderName); + ExchangeSession.Folder folder = session.getFolder(folderName); + assertNotNull(folder); + assertEquals("IPF.Contact", folder.folderClass); + session.deleteFolder(folderName); + } + + + public void testFolderAccent() throws IOException { + String folderName = "test้"; + session.createMessageFolder(folderName); + ExchangeSession.Folder folder = session.getFolder(folderName); + assertNotNull(folder); + assertEquals(folderName, folder.displayName); + assertEquals(folderName, folder.folderPath); + session.deleteFolder(folderName); + } + + public void testFolderSpace() throws IOException { + String folderName = "test space"; + session.createMessageFolder(folderName); + ExchangeSession.Folder folder = session.getFolder(folderName); + assertNotNull(folder); + assertEquals(folderName, folder.displayName); + assertEquals(folderName, folder.folderPath); + session.deleteFolder(folderName); + } +}