001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Alexandre Russel
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.mail.test;
021
022import java.io.File;
023import java.net.URL;
024
025import com.ericdaugherty.mail.server.Mail;
026
027/**
028 * @author Alexandre Russel
029 */
030public class Server {
031
032    private static final String MAIL_CONF = "/mail.conf";
033
034    public static void start() {
035        URL mailConfUrl = Server.class.getResource(MAIL_CONF);
036        String confDirectory = mailConfUrl.getPath().substring(0, mailConfUrl.getPath().lastIndexOf(File.separatorChar));
037        Mail.main(new String[] { confDirectory });
038    }
039
040    public static void shutdown() {
041        try {
042            Mail.shutdown();
043        } catch (Throwable t) {
044            // TODO: handle exception
045        }
046    }
047
048}