001 /*********************************************************************************************************************** 002 * 003 * JavaMail Mock2 Provider - open source mock classes for mock up JavaMail 004 * ======================================================================= 005 * 006 * Copyright (C) 2014 by Hendrik Saly (http://saly.de) 007 * 008 * Based on ideas from Kohsuke Kawaguchi's Mock-javamail (https://java.net/projects/mock-javamail) 009 * 010 *********************************************************************************************************************** 011 * 012 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 013 * the License. You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 018 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 019 * specific language governing permissions and limitations under the License. 020 * 021 *********************************************************************************************************************** 022 * 023 * $Id:$ 024 * 025 **********************************************************************************************************************/ 026 package de.saly.javamail.mock2; 027 028 import javax.mail.Provider; 029 030 public final class Providers { 031 032 public static Provider getIMAPProvider(final String protocol, final boolean secure, final boolean mock) { 033 if (mock) { 034 return new Provider(Provider.Type.STORE, protocol, secure ? "de.saly.javamail.mock2.IMAPSSLMockStore" 035 : "de.saly.javamail.mock2.IMAPMockStore", "JavaMail Mock2 provider", null); 036 } 037 038 return new Provider(Provider.Type.STORE, protocol, secure ? "com.sun.mail.imap.IMAPSSLStore" : "com.sun.mail.imap.IMAPStore", 039 "Oracle", null); 040 041 } 042 043 public static Provider getPOP3Provider(final String protocol, final boolean secure, final boolean mock) { 044 if (mock) { 045 return new Provider(Provider.Type.STORE, protocol, secure ? "de.saly.javamail.mock2.POP3SSLMockStore" 046 : "de.saly.javamail.mock2.POP3MockStore", "JavaMail Mock2 provider", null); 047 } 048 049 return new Provider(Provider.Type.STORE, protocol, secure ? "com.sun.mail.pop3.POP3SSLStore" : "com.sun.mail.pop3.POP3Store", 050 "Oracle", null); 051 052 } 053 054 public static Provider getSMTPProvider(final String protocol, final boolean secure, final boolean mock) { 055 if (mock) { 056 return new Provider(Provider.Type.TRANSPORT, protocol, "de.saly.javamail.mock2.MockTransport", "JavaMail Mock2 provider", null); 057 } 058 059 return new Provider(Provider.Type.TRANSPORT, protocol, secure ? "com.sun.mail.smtp.SMTPSSLTransport" 060 : "com.sun.mail.smtp.SMTPTransport", "Oracle", null); 061 } 062 063 private Providers() { 064 // empty 065 } 066 067 }