001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.test.mock.mailet;
019:
020: import org.apache.mailet.MailetContext;
021: import org.apache.mailet.Mail;
022: import org.apache.mailet.MailAddress;
023:
024: import javax.mail.MessagingException;
025: import javax.mail.internet.MimeMessage;
026: import java.util.Collection;
027: import java.util.HashMap;
028: import java.util.Iterator;
029:
030: public class MockMailContext implements MailetContext {
031:
032: HashMap attributes = new HashMap();
033:
034: public void bounce(Mail mail, String message)
035: throws MessagingException {
036: // trivial implementation
037: }
038:
039: public void bounce(Mail mail, String message, MailAddress bouncer)
040: throws MessagingException {
041: // trivial implementation
042: }
043:
044: public Collection getMailServers(String host) {
045: return null; // trivial implementation
046: }
047:
048: public MailAddress getPostmaster() {
049: return null; // trivial implementation
050: }
051:
052: public Object getAttribute(String name) {
053: return attributes.get(name);
054: }
055:
056: public Iterator getAttributeNames() {
057: return attributes.keySet().iterator();
058: }
059:
060: public int getMajorVersion() {
061: return 0; // trivial implementation
062: }
063:
064: public int getMinorVersion() {
065: return 0; // trivial implementation
066: }
067:
068: public String getServerInfo() {
069: return "Mock Server";
070: }
071:
072: public boolean isLocalServer(String serverName) {
073: return false; // trivial implementation
074: }
075:
076: public boolean isLocalUser(String userAccount) {
077: return false; // trivial implementation
078: }
079:
080: public void log(String message) {
081: System.out.println(message);
082: }
083:
084: public void log(String message, Throwable t) {
085: System.out.println(message);
086: t.printStackTrace(System.out);
087: }
088:
089: public void removeAttribute(String name) {
090: // trivial implementation
091: }
092:
093: public void sendMail(MimeMessage msg) throws MessagingException {
094: // trivial implementation
095: }
096:
097: public void sendMail(MailAddress sender, Collection recipients,
098: MimeMessage msg) throws MessagingException {
099: // trivial implementation
100: }
101:
102: public void sendMail(MailAddress sender, Collection recipients,
103: MimeMessage msg, String state) throws MessagingException {
104: // trivial implementation
105: }
106:
107: public void sendMail(Mail mail) throws MessagingException {
108: // trivial implementation
109: }
110:
111: public void setAttribute(String name, Object object) {
112: attributes.put(name, object);
113: }
114:
115: public void storeMail(MailAddress sender, MailAddress recipient,
116: MimeMessage msg) throws MessagingException {
117: // trivial implementation
118: }
119:
120: public Iterator getSMTPHostAddresses(String domainName) {
121: return null; // trivial implementation
122: }
123: }
|