You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ba...@apache.org on 2006/08/04 03:07:20 UTC
svn commit: r428585 [3/3] - in
/james/server/branches/v2.3/src/test/org/apache/james: ./ core/ pop3server/
remotemanager/ services/ smtpserver/ test/mock/avalon/ test/mock/james/
test/mock/javaxmail/ test/mock/mailet/ transport/ userrepository/ util/
Modified: james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockMailRepository.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockMailRepository.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockMailRepository.java Thu Aug 3 18:07:18 2006
@@ -1,73 +1,73 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-
-
-package org.apache.james.test.mock.james;
-
-import org.apache.james.core.MailImpl;
-import org.apache.james.services.MailRepository;
-import org.apache.mailet.Mail;
-
-import javax.mail.MessagingException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Collection;
-
-public class MockMailRepository implements MailRepository {
-
- private HashMap messages = new HashMap();
-
- public void store(Mail mc) throws MessagingException {
- MailImpl m = new MailImpl(mc,mc.getName());
- m.setState(mc.getState());
- this.messages.put(mc.getName(),m);
- }
-
- public Iterator list() throws MessagingException {
- return messages.keySet().iterator(); // trivial implementation
- }
-
- public Mail retrieve(String key) throws MessagingException {
- Mail m2 = new MailImpl((Mail) messages.get(key),key);
- m2.setState(((Mail) messages.get(key)).getState());
- return m2; // trivial implementation
- }
-
- public void remove(Mail mail) throws MessagingException {
- messages.remove(mail.getName());
- }
-
- public void remove(Collection mails) throws MessagingException {
- for (Iterator i = mails.iterator(); i.hasNext(); ) {
- Mail m = (Mail) i.next();
- messages.remove(m.getName());
- }
- }
-
- public void remove(String key) throws MessagingException {
- messages.remove(key);
- }
-
- public boolean lock(String key) throws MessagingException {
- return false; // trivial implementation
- }
-
- public boolean unlock(String key) throws MessagingException {
- return false; // trivial implementation
- }
-}
+/***********************************************************************
+ * Copyright (c) 2000-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+
+
+package org.apache.james.test.mock.james;
+
+import org.apache.james.core.MailImpl;
+import org.apache.james.services.MailRepository;
+import org.apache.mailet.Mail;
+
+import javax.mail.MessagingException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collection;
+
+public class MockMailRepository implements MailRepository {
+
+ private HashMap messages = new HashMap();
+
+ public void store(Mail mc) throws MessagingException {
+ MailImpl m = new MailImpl(mc,mc.getName());
+ m.setState(mc.getState());
+ this.messages.put(mc.getName(),m);
+ }
+
+ public Iterator list() throws MessagingException {
+ return messages.keySet().iterator(); // trivial implementation
+ }
+
+ public Mail retrieve(String key) throws MessagingException {
+ Mail m2 = new MailImpl((Mail) messages.get(key),key);
+ m2.setState(((Mail) messages.get(key)).getState());
+ return m2; // trivial implementation
+ }
+
+ public void remove(Mail mail) throws MessagingException {
+ messages.remove(mail.getName());
+ }
+
+ public void remove(Collection mails) throws MessagingException {
+ for (Iterator i = mails.iterator(); i.hasNext(); ) {
+ Mail m = (Mail) i.next();
+ messages.remove(m.getName());
+ }
+ }
+
+ public void remove(String key) throws MessagingException {
+ messages.remove(key);
+ }
+
+ public boolean lock(String key) throws MessagingException {
+ return false; // trivial implementation
+ }
+
+ public boolean unlock(String key) throws MessagingException {
+ return false; // trivial implementation
+ }
+}
Modified: james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockSpoolRepository.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockSpoolRepository.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockSpoolRepository.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockSpoolRepository.java Thu Aug 3 18:07:18 2006
@@ -1,84 +1,84 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-package org.apache.james.test.mock.james;
-
-import org.apache.james.services.SpoolRepository;
-import org.apache.mailet.Mail;
-
-import javax.mail.MessagingException;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-public class MockSpoolRepository implements SpoolRepository {
- public ArrayList storedMails = new ArrayList();
-
- public Mail accept() throws InterruptedException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Mail accept(long delay) throws InterruptedException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Mail accept(AcceptFilter filter) throws InterruptedException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void store(Mail mc) throws MessagingException {
-
- }
-
- public Iterator list() throws MessagingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Mail retrieve(String key) throws MessagingException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void remove(Mail mail) throws MessagingException {
- // TODO Auto-generated method stub
-
- }
-
- public void remove(Collection mails) throws MessagingException {
- // TODO Auto-generated method stub
-
- }
-
- public void remove(String key) throws MessagingException {
- // TODO Auto-generated method stub
-
- }
-
- public boolean lock(String key) throws MessagingException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean unlock(String key) throws MessagingException {
- // TODO Auto-generated method stub
- return false;
- }
-}
\ No newline at end of file
+/***********************************************************************
+ * Copyright (c) 2000-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+package org.apache.james.test.mock.james;
+
+import org.apache.james.services.SpoolRepository;
+import org.apache.mailet.Mail;
+
+import javax.mail.MessagingException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class MockSpoolRepository implements SpoolRepository {
+ public ArrayList storedMails = new ArrayList();
+
+ public Mail accept() throws InterruptedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Mail accept(long delay) throws InterruptedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Mail accept(AcceptFilter filter) throws InterruptedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void store(Mail mc) throws MessagingException {
+
+ }
+
+ public Iterator list() throws MessagingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Mail retrieve(String key) throws MessagingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void remove(Mail mail) throws MessagingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void remove(Collection mails) throws MessagingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void remove(String key) throws MessagingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean lock(String key) throws MessagingException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean unlock(String key) throws MessagingException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
Modified: james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockUsersStore.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockUsersStore.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockUsersStore.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/test/mock/james/MockUsersStore.java Thu Aug 3 18:07:18 2006
@@ -1,43 +1,43 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-
-
-package org.apache.james.test.mock.james;
-
-import org.apache.james.services.UsersStore;
-import org.apache.james.services.UsersRepository;
-
-import java.util.Iterator;
-import java.util.ArrayList;
-
-public class MockUsersStore implements UsersStore {
- private UsersRepository m_usersRepository;
-
- public MockUsersStore(UsersRepository usersRepository) {
- m_usersRepository = usersRepository;
- }
-
- public UsersRepository getRepository(String name) {
- return m_usersRepository;
- }
-
- public Iterator getRepositoryNames() {
- ArrayList repositoryList = new ArrayList();
- repositoryList.add(m_usersRepository);
- return repositoryList.iterator();
- }
-}
+/***********************************************************************
+ * Copyright (c) 2000-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+
+
+package org.apache.james.test.mock.james;
+
+import org.apache.james.services.UsersStore;
+import org.apache.james.services.UsersRepository;
+
+import java.util.Iterator;
+import java.util.ArrayList;
+
+public class MockUsersStore implements UsersStore {
+ private UsersRepository m_usersRepository;
+
+ public MockUsersStore(UsersRepository usersRepository) {
+ m_usersRepository = usersRepository;
+ }
+
+ public UsersRepository getRepository(String name) {
+ return m_usersRepository;
+ }
+
+ public Iterator getRepositoryNames() {
+ ArrayList repositoryList = new ArrayList();
+ repositoryList.add(m_usersRepository);
+ return repositoryList.iterator();
+ }
+}
Modified: james/server/branches/v2.3/src/test/org/apache/james/test/mock/javaxmail/MockMimeMessage.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/test/mock/javaxmail/MockMimeMessage.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/test/mock/javaxmail/MockMimeMessage.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/test/mock/javaxmail/MockMimeMessage.java Thu Aug 3 18:07:18 2006
@@ -1,468 +1,468 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-
-
-package org.apache.james.test.mock.javaxmail;
-
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.InternetHeaders;
-import javax.mail.internet.InternetAddress;
-import javax.mail.*;
-import javax.mail.search.SearchTerm;
-import javax.activation.DataHandler;
-import java.util.*;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-public class MockMimeMessage extends MimeMessage {
-
- private final List m_fromAddresses = new ArrayList();
- private Address m_senderAddress;
- private final List m_toRecepients = new ArrayList();
- private final List m_ccRecepients = new ArrayList();
- private final List m_bccRecepients = new ArrayList();
- private final List m_replyToAddresses = new ArrayList();
- private String m_subject;
- private int m_iMessageNumber;
- private boolean m_bIsExpunged;
- private Object m_content;
- private Date m_sentDate;
- private String[] m_contentLanguage;
- private String m_fileName;
- private DataHandler m_dataHandler;
- private HashMap m_contentHeaders = new HashMap();
- private Flags m_setFlags = new Flags();
- private boolean m_doMatch;
-
- public MockMimeMessage() throws MessagingException {
- super((Session)null);
- }
-
- public MockMimeMessage(MimeMessage mimeMessage) throws MessagingException {
- super(mimeMessage); // trivial implementation
- }
-
- public Address[] getFrom() throws MessagingException {
- return (Address[])m_fromAddresses.toArray();
- }
-
- public void setFrom(Address address) throws MessagingException {
- m_fromAddresses.clear();
- m_fromAddresses.add(address);
- }
-
- public void setFrom() throws MessagingException {
- m_fromAddresses.clear();
- m_fromAddresses.add(InternetAddress.getLocalAddress(null));
- }
-
- public void addFrom(Address[] addresses) throws MessagingException {
- m_fromAddresses.add(addresses);
- }
-
- public Address getSender() throws MessagingException {
- return m_senderAddress;
- }
-
- public void setSender(Address address) throws MessagingException {
- m_senderAddress = address;
- }
-
- public Address[] getRecipients(Message.RecipientType recipientType) throws MessagingException {
- return (Address[]) getRecipientsList(recipientType).toArray();
- }
-
- private List getRecipientsList(Message.RecipientType recipientType) {
- if (Message.RecipientType.TO.equals(recipientType)) return m_toRecepients;
- if (Message.RecipientType.CC.equals(recipientType)) return m_ccRecepients;
- if (Message.RecipientType.BCC.equals(recipientType)) return m_bccRecepients;
- return null;
- }
-
- public Address[] getAllRecipients() throws MessagingException {
- List allRecipients = new ArrayList();
- allRecipients.addAll(m_toRecepients);
- allRecipients.addAll(m_ccRecepients);
- allRecipients.addAll(m_bccRecepients);
- return (Address[]) allRecipients.toArray();
- }
-
- public void setRecipients(Message.RecipientType recipientType, Address[] addresses) throws MessagingException {
- getRecipientsList(recipientType).addAll(Arrays.asList(addresses));
- }
-
- public void setRecipients(Message.RecipientType recipientType, String recipient) throws MessagingException {
- getRecipientsList(recipientType).add(recipient);
- }
-
- public void addRecipients(Message.RecipientType recipientType, Address[] addresses) throws MessagingException {
- getRecipientsList(recipientType).addAll(Arrays.asList(addresses));
- }
-
- public void addRecipients(Message.RecipientType recipientType, String recipient) throws MessagingException {
- getRecipientsList(recipientType).add(recipient);
- }
-
- public Address[] getReplyTo() throws MessagingException {
- return (Address[]) m_replyToAddresses.toArray();
- }
-
- public void setReplyTo(Address[] addresses) throws MessagingException {
- m_replyToAddresses.addAll(Arrays.asList(addresses));
- }
-
- public String getSubject() throws MessagingException {
- return m_subject;
- }
-
- public void setSubject(String subject) throws MessagingException {
- m_subject = subject;
- }
-
- public void setSubject(String subject, String charset) throws MessagingException {
- if (subject == null)
- {
- m_subject = null;
- return;
- }
- try {
- m_subject = new String(subject.getBytes(charset));
- } catch (UnsupportedEncodingException e) {
- throw new MessagingException("setting subject failed", e);
- }
- }
-
- public Date getSentDate() throws MessagingException {
- return m_sentDate;
- }
-
- public void setSentDate(Date date) throws MessagingException {
- m_sentDate = date;
- }
-
- public Date getReceivedDate() throws MessagingException {
- return null; // trivial implementation
- }
-
- public int getSize() throws MessagingException {
- return -1; // trivial implementation
- }
-
- public int getLineCount() throws MessagingException {
- return -1; // trivial implementation
- }
-
- public String getContentType() throws MessagingException {
- return getHeader("Content-Type", null);
- }
-
- public boolean isMimeType(String mimeType) throws MessagingException {
- return mimeType.startsWith(getContentType());
- }
-
- public String getDisposition() throws MessagingException {
- return getHeader("Content-Disposition", null);
- }
-
- public void setDisposition(String disposition) throws MessagingException {
- setHeader("Content-Disposition", disposition);
- }
-
- public String getEncoding() throws MessagingException {
- return getHeader("Content-Transfer-Encoding", null);
- }
-
- public String getContentID() throws MessagingException {
- return getHeader("Content-ID", null);
- }
-
- public void setContentID(String contentID) throws MessagingException {
- setHeader("Content-ID", contentID);
- }
-
- public String getContentMD5() throws MessagingException {
- return getHeader("Content-MD5", null);
- }
-
- public void setContentMD5(String value) throws MessagingException {
- setHeader("Content-MD5", value);
- }
-
- public String getDescription() throws MessagingException {
- return getHeader("Content-Description", null);
- }
-
- public void setDescription(String description) throws MessagingException {
- setHeader("Content-Description", description);
- }
-
- public void setDescription(String description, String charset) throws MessagingException {
- try {
- setDescription(new String(description.getBytes(charset)));
- } catch (UnsupportedEncodingException e) {
- throw new MessagingException("setting description failed", e);
- }
- }
-
- public String[] getContentLanguage() throws MessagingException {
- return m_contentLanguage;
- }
-
- public void setContentLanguage(String[] contentLanguage) throws MessagingException {
- m_contentLanguage = contentLanguage;
- }
-
- public String getMessageID() throws MessagingException {
- return "ID-" + m_iMessageNumber; // trivial implementation
- }
-
- public String getFileName() throws MessagingException {
- return m_fileName;
- }
-
- public void setFileName(String fileName) throws MessagingException {
- m_fileName = fileName;
- }
-
- public InputStream getInputStream() throws IOException, MessagingException {
- return null; // trivial implementation
- }
-
- protected InputStream getContentStream() throws MessagingException {
- return null; // trivial implementation
- }
-
- public InputStream getRawInputStream() throws MessagingException {
- return null; // trivial implementation
- }
-
- public synchronized DataHandler getDataHandler() throws MessagingException {
- return m_dataHandler;
- }
-
- public synchronized void setDataHandler(DataHandler dataHandler) throws MessagingException {
- m_dataHandler = dataHandler;
- }
-
- public Object getContent() throws IOException, MessagingException {
- return m_content;
- }
-
- public void setContent(Object object, String mimeType) throws MessagingException {
- m_content = object; // trivial implementation
- }
-
- public void setText(String string) throws MessagingException {
- setContent(string, "text/plain");
- }
-
- public void setText(String string, String charset) throws MessagingException {
- try {
- setContent(new String(string.getBytes(charset)) , "text/plain");
- } catch (UnsupportedEncodingException e) {
- throw new MessagingException("setting text content failed", e);
- }
- }
-
- public void setContent(Multipart multipart) throws MessagingException {
- m_content = multipart;
- }
-
- public Message reply(boolean b) throws MessagingException {
- return new MockMimeMessage(this); // trivial implementation
- }
-
- public void writeTo(OutputStream outputStream) throws IOException, MessagingException {
- ; // trivial implementation
- }
-
- public void writeTo(OutputStream outputStream, String[] strings) throws IOException, MessagingException {
- ; // trivial implementation
- }
-
- public String[] getHeader(String name) throws MessagingException {
- String value = (String) m_contentHeaders.get(name);
- if (value == null) return null;
- return new String[] {value};
- }
-
- public String getHeader(String name, String delimiter) throws MessagingException {
- String[] header = getHeader(name);
- if (header == null || header.length == 0) return null;
- return header[0];
- }
-
- public void setHeader(String name, String value) throws MessagingException {
- addHeader(name, value);
- }
-
- public void addHeader(String name, String value) throws MessagingException {
- m_contentHeaders.put(name, value);
- }
-
- public void removeHeader(String name) throws MessagingException {
- m_contentHeaders.remove(name);
- }
-
- public Enumeration getAllHeaders() throws MessagingException {
- return Collections.enumeration(m_contentHeaders.values());
- }
-
- public Enumeration getMatchingHeaders(String[] names) throws MessagingException {
- ArrayList matchingHeaders = new ArrayList();
- for (int i = 0; i < names.length; i++) {
- String name = names[i];
- String value = getHeader(name, null);
- if (value == null) continue;
- matchingHeaders.add(value);
- }
- return Collections.enumeration(matchingHeaders);
- }
-
- public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {
- List existingHeaders = Arrays.asList(names);
-
- ArrayList nonMatchingHeaders = new ArrayList();
-
- Iterator iterator = m_contentHeaders.keySet().iterator();
- while (iterator.hasNext()) {
- String name = (String) iterator.next();
- if (existingHeaders.contains(name)) continue;
- String value = getHeader(name, null);
- if (value == null) continue;
- nonMatchingHeaders.add(value);
- }
- return Collections.enumeration(nonMatchingHeaders);
- }
-
- public void addHeaderLine(String headerLine) throws MessagingException {
- int separatorIndex = headerLine.indexOf(":");
- if (separatorIndex < 0) throw new MessagingException("header line does not conform to standard");
-
- addHeader(headerLine.substring(0,separatorIndex), headerLine.substring(separatorIndex,headerLine.length()));
- }
-
- public Enumeration getAllHeaderLines() throws MessagingException {
- return Collections.enumeration(getHeadersAsStrings(m_contentHeaders));
- }
-
- private ArrayList getHeadersAsStrings(HashMap contentHeaders) {
- ArrayList headerLines = new ArrayList();
- Iterator iterator = contentHeaders.keySet().iterator();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
- String value = (String) contentHeaders.get(key);
- headerLines.add(key + ":" + value);
- }
- return headerLines;
- }
-
- public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException {
- ArrayList matchingHeaders = new ArrayList();
- for (int i = 0; i < names.length; i++) {
- String name = names[i];
- String value = getHeader(name, null);
- if (value == null) continue;
- matchingHeaders.add(name + ":" + value);
- }
- return Collections.enumeration(matchingHeaders);
- }
-
- public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException {
- List existingHeaders = names != null ? Arrays.asList(names) : null;
-
- ArrayList nonMatchingHeaders = new ArrayList();
-
- Iterator iterator = m_contentHeaders.keySet().iterator();
- while (iterator.hasNext()) {
- String name = (String) iterator.next();
- if (existingHeaders!=null && existingHeaders.contains(name)) continue;
- String value = getHeader(name, null);
- if (value == null) continue;
- nonMatchingHeaders.add(name + ":" + value);
- }
- return Collections.enumeration(nonMatchingHeaders);
- }
-
- public synchronized Flags getFlags() throws MessagingException {
- return new Flags(m_setFlags);
- }
-
- public synchronized boolean isSet(Flags.Flag flag) throws MessagingException {
- return m_setFlags.contains(flag);
- }
-
- public synchronized void setFlags(Flags flags, boolean set) throws MessagingException {
- if (set) m_setFlags.add(flags);
- else m_setFlags.remove(flags);
- }
-
- public void saveChanges() throws MessagingException {
- ; // trivial implementation
- }
-
- protected void updateHeaders() throws MessagingException {
- ; // trivial implementation
- }
-
- protected InternetHeaders createInternetHeaders(InputStream inputStream) throws MessagingException {
- return new InternetHeaders();
- }
-
- public void setRecipient(Message.RecipientType recipientType, Address address) throws MessagingException {
- setRecipients(recipientType, new Address[]{address});
- }
-
- public void addRecipient(Message.RecipientType recipientType, Address address) throws MessagingException {
- setRecipients(recipientType, new Address[]{address});
- }
-
- public void setFlag(Flags.Flag flag, boolean set) throws MessagingException {
- if (set) m_setFlags.add(flag);
- else m_setFlags.remove(flag);
- }
-
- public int getMessageNumber() {
- return m_iMessageNumber;
- }
-
- protected void setMessageNumber(int i) {
- m_iMessageNumber = i;
- }
-
- public Folder getFolder() {
- return null;
- }
-
- public boolean isExpunged() {
- return m_bIsExpunged;
- }
-
- protected void setExpunged(boolean b) {
- m_bIsExpunged = b;
- }
-
- public void setShouldMatch(boolean doMatch) {
- m_doMatch = doMatch;
- }
-
- public boolean match(SearchTerm searchTerm) throws MessagingException {
- return m_doMatch;
- }
-}
+/***********************************************************************
+ * Copyright (c) 2000-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+
+
+package org.apache.james.test.mock.javaxmail;
+
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.InternetHeaders;
+import javax.mail.internet.InternetAddress;
+import javax.mail.*;
+import javax.mail.search.SearchTerm;
+import javax.activation.DataHandler;
+import java.util.*;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+public class MockMimeMessage extends MimeMessage {
+
+ private final List m_fromAddresses = new ArrayList();
+ private Address m_senderAddress;
+ private final List m_toRecepients = new ArrayList();
+ private final List m_ccRecepients = new ArrayList();
+ private final List m_bccRecepients = new ArrayList();
+ private final List m_replyToAddresses = new ArrayList();
+ private String m_subject;
+ private int m_iMessageNumber;
+ private boolean m_bIsExpunged;
+ private Object m_content;
+ private Date m_sentDate;
+ private String[] m_contentLanguage;
+ private String m_fileName;
+ private DataHandler m_dataHandler;
+ private HashMap m_contentHeaders = new HashMap();
+ private Flags m_setFlags = new Flags();
+ private boolean m_doMatch;
+
+ public MockMimeMessage() throws MessagingException {
+ super((Session)null);
+ }
+
+ public MockMimeMessage(MimeMessage mimeMessage) throws MessagingException {
+ super(mimeMessage); // trivial implementation
+ }
+
+ public Address[] getFrom() throws MessagingException {
+ return (Address[])m_fromAddresses.toArray();
+ }
+
+ public void setFrom(Address address) throws MessagingException {
+ m_fromAddresses.clear();
+ m_fromAddresses.add(address);
+ }
+
+ public void setFrom() throws MessagingException {
+ m_fromAddresses.clear();
+ m_fromAddresses.add(InternetAddress.getLocalAddress(null));
+ }
+
+ public void addFrom(Address[] addresses) throws MessagingException {
+ m_fromAddresses.add(addresses);
+ }
+
+ public Address getSender() throws MessagingException {
+ return m_senderAddress;
+ }
+
+ public void setSender(Address address) throws MessagingException {
+ m_senderAddress = address;
+ }
+
+ public Address[] getRecipients(Message.RecipientType recipientType) throws MessagingException {
+ return (Address[]) getRecipientsList(recipientType).toArray();
+ }
+
+ private List getRecipientsList(Message.RecipientType recipientType) {
+ if (Message.RecipientType.TO.equals(recipientType)) return m_toRecepients;
+ if (Message.RecipientType.CC.equals(recipientType)) return m_ccRecepients;
+ if (Message.RecipientType.BCC.equals(recipientType)) return m_bccRecepients;
+ return null;
+ }
+
+ public Address[] getAllRecipients() throws MessagingException {
+ List allRecipients = new ArrayList();
+ allRecipients.addAll(m_toRecepients);
+ allRecipients.addAll(m_ccRecepients);
+ allRecipients.addAll(m_bccRecepients);
+ return (Address[]) allRecipients.toArray();
+ }
+
+ public void setRecipients(Message.RecipientType recipientType, Address[] addresses) throws MessagingException {
+ getRecipientsList(recipientType).addAll(Arrays.asList(addresses));
+ }
+
+ public void setRecipients(Message.RecipientType recipientType, String recipient) throws MessagingException {
+ getRecipientsList(recipientType).add(recipient);
+ }
+
+ public void addRecipients(Message.RecipientType recipientType, Address[] addresses) throws MessagingException {
+ getRecipientsList(recipientType).addAll(Arrays.asList(addresses));
+ }
+
+ public void addRecipients(Message.RecipientType recipientType, String recipient) throws MessagingException {
+ getRecipientsList(recipientType).add(recipient);
+ }
+
+ public Address[] getReplyTo() throws MessagingException {
+ return (Address[]) m_replyToAddresses.toArray();
+ }
+
+ public void setReplyTo(Address[] addresses) throws MessagingException {
+ m_replyToAddresses.addAll(Arrays.asList(addresses));
+ }
+
+ public String getSubject() throws MessagingException {
+ return m_subject;
+ }
+
+ public void setSubject(String subject) throws MessagingException {
+ m_subject = subject;
+ }
+
+ public void setSubject(String subject, String charset) throws MessagingException {
+ if (subject == null)
+ {
+ m_subject = null;
+ return;
+ }
+ try {
+ m_subject = new String(subject.getBytes(charset));
+ } catch (UnsupportedEncodingException e) {
+ throw new MessagingException("setting subject failed", e);
+ }
+ }
+
+ public Date getSentDate() throws MessagingException {
+ return m_sentDate;
+ }
+
+ public void setSentDate(Date date) throws MessagingException {
+ m_sentDate = date;
+ }
+
+ public Date getReceivedDate() throws MessagingException {
+ return null; // trivial implementation
+ }
+
+ public int getSize() throws MessagingException {
+ return -1; // trivial implementation
+ }
+
+ public int getLineCount() throws MessagingException {
+ return -1; // trivial implementation
+ }
+
+ public String getContentType() throws MessagingException {
+ return getHeader("Content-Type", null);
+ }
+
+ public boolean isMimeType(String mimeType) throws MessagingException {
+ return mimeType.startsWith(getContentType());
+ }
+
+ public String getDisposition() throws MessagingException {
+ return getHeader("Content-Disposition", null);
+ }
+
+ public void setDisposition(String disposition) throws MessagingException {
+ setHeader("Content-Disposition", disposition);
+ }
+
+ public String getEncoding() throws MessagingException {
+ return getHeader("Content-Transfer-Encoding", null);
+ }
+
+ public String getContentID() throws MessagingException {
+ return getHeader("Content-ID", null);
+ }
+
+ public void setContentID(String contentID) throws MessagingException {
+ setHeader("Content-ID", contentID);
+ }
+
+ public String getContentMD5() throws MessagingException {
+ return getHeader("Content-MD5", null);
+ }
+
+ public void setContentMD5(String value) throws MessagingException {
+ setHeader("Content-MD5", value);
+ }
+
+ public String getDescription() throws MessagingException {
+ return getHeader("Content-Description", null);
+ }
+
+ public void setDescription(String description) throws MessagingException {
+ setHeader("Content-Description", description);
+ }
+
+ public void setDescription(String description, String charset) throws MessagingException {
+ try {
+ setDescription(new String(description.getBytes(charset)));
+ } catch (UnsupportedEncodingException e) {
+ throw new MessagingException("setting description failed", e);
+ }
+ }
+
+ public String[] getContentLanguage() throws MessagingException {
+ return m_contentLanguage;
+ }
+
+ public void setContentLanguage(String[] contentLanguage) throws MessagingException {
+ m_contentLanguage = contentLanguage;
+ }
+
+ public String getMessageID() throws MessagingException {
+ return "ID-" + m_iMessageNumber; // trivial implementation
+ }
+
+ public String getFileName() throws MessagingException {
+ return m_fileName;
+ }
+
+ public void setFileName(String fileName) throws MessagingException {
+ m_fileName = fileName;
+ }
+
+ public InputStream getInputStream() throws IOException, MessagingException {
+ return null; // trivial implementation
+ }
+
+ protected InputStream getContentStream() throws MessagingException {
+ return null; // trivial implementation
+ }
+
+ public InputStream getRawInputStream() throws MessagingException {
+ return null; // trivial implementation
+ }
+
+ public synchronized DataHandler getDataHandler() throws MessagingException {
+ return m_dataHandler;
+ }
+
+ public synchronized void setDataHandler(DataHandler dataHandler) throws MessagingException {
+ m_dataHandler = dataHandler;
+ }
+
+ public Object getContent() throws IOException, MessagingException {
+ return m_content;
+ }
+
+ public void setContent(Object object, String mimeType) throws MessagingException {
+ m_content = object; // trivial implementation
+ }
+
+ public void setText(String string) throws MessagingException {
+ setContent(string, "text/plain");
+ }
+
+ public void setText(String string, String charset) throws MessagingException {
+ try {
+ setContent(new String(string.getBytes(charset)) , "text/plain");
+ } catch (UnsupportedEncodingException e) {
+ throw new MessagingException("setting text content failed", e);
+ }
+ }
+
+ public void setContent(Multipart multipart) throws MessagingException {
+ m_content = multipart;
+ }
+
+ public Message reply(boolean b) throws MessagingException {
+ return new MockMimeMessage(this); // trivial implementation
+ }
+
+ public void writeTo(OutputStream outputStream) throws IOException, MessagingException {
+ ; // trivial implementation
+ }
+
+ public void writeTo(OutputStream outputStream, String[] strings) throws IOException, MessagingException {
+ ; // trivial implementation
+ }
+
+ public String[] getHeader(String name) throws MessagingException {
+ String value = (String) m_contentHeaders.get(name);
+ if (value == null) return null;
+ return new String[] {value};
+ }
+
+ public String getHeader(String name, String delimiter) throws MessagingException {
+ String[] header = getHeader(name);
+ if (header == null || header.length == 0) return null;
+ return header[0];
+ }
+
+ public void setHeader(String name, String value) throws MessagingException {
+ addHeader(name, value);
+ }
+
+ public void addHeader(String name, String value) throws MessagingException {
+ m_contentHeaders.put(name, value);
+ }
+
+ public void removeHeader(String name) throws MessagingException {
+ m_contentHeaders.remove(name);
+ }
+
+ public Enumeration getAllHeaders() throws MessagingException {
+ return Collections.enumeration(m_contentHeaders.values());
+ }
+
+ public Enumeration getMatchingHeaders(String[] names) throws MessagingException {
+ ArrayList matchingHeaders = new ArrayList();
+ for (int i = 0; i < names.length; i++) {
+ String name = names[i];
+ String value = getHeader(name, null);
+ if (value == null) continue;
+ matchingHeaders.add(value);
+ }
+ return Collections.enumeration(matchingHeaders);
+ }
+
+ public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {
+ List existingHeaders = Arrays.asList(names);
+
+ ArrayList nonMatchingHeaders = new ArrayList();
+
+ Iterator iterator = m_contentHeaders.keySet().iterator();
+ while (iterator.hasNext()) {
+ String name = (String) iterator.next();
+ if (existingHeaders.contains(name)) continue;
+ String value = getHeader(name, null);
+ if (value == null) continue;
+ nonMatchingHeaders.add(value);
+ }
+ return Collections.enumeration(nonMatchingHeaders);
+ }
+
+ public void addHeaderLine(String headerLine) throws MessagingException {
+ int separatorIndex = headerLine.indexOf(":");
+ if (separatorIndex < 0) throw new MessagingException("header line does not conform to standard");
+
+ addHeader(headerLine.substring(0,separatorIndex), headerLine.substring(separatorIndex,headerLine.length()));
+ }
+
+ public Enumeration getAllHeaderLines() throws MessagingException {
+ return Collections.enumeration(getHeadersAsStrings(m_contentHeaders));
+ }
+
+ private ArrayList getHeadersAsStrings(HashMap contentHeaders) {
+ ArrayList headerLines = new ArrayList();
+ Iterator iterator = contentHeaders.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ String value = (String) contentHeaders.get(key);
+ headerLines.add(key + ":" + value);
+ }
+ return headerLines;
+ }
+
+ public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException {
+ ArrayList matchingHeaders = new ArrayList();
+ for (int i = 0; i < names.length; i++) {
+ String name = names[i];
+ String value = getHeader(name, null);
+ if (value == null) continue;
+ matchingHeaders.add(name + ":" + value);
+ }
+ return Collections.enumeration(matchingHeaders);
+ }
+
+ public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException {
+ List existingHeaders = names != null ? Arrays.asList(names) : null;
+
+ ArrayList nonMatchingHeaders = new ArrayList();
+
+ Iterator iterator = m_contentHeaders.keySet().iterator();
+ while (iterator.hasNext()) {
+ String name = (String) iterator.next();
+ if (existingHeaders!=null && existingHeaders.contains(name)) continue;
+ String value = getHeader(name, null);
+ if (value == null) continue;
+ nonMatchingHeaders.add(name + ":" + value);
+ }
+ return Collections.enumeration(nonMatchingHeaders);
+ }
+
+ public synchronized Flags getFlags() throws MessagingException {
+ return new Flags(m_setFlags);
+ }
+
+ public synchronized boolean isSet(Flags.Flag flag) throws MessagingException {
+ return m_setFlags.contains(flag);
+ }
+
+ public synchronized void setFlags(Flags flags, boolean set) throws MessagingException {
+ if (set) m_setFlags.add(flags);
+ else m_setFlags.remove(flags);
+ }
+
+ public void saveChanges() throws MessagingException {
+ ; // trivial implementation
+ }
+
+ protected void updateHeaders() throws MessagingException {
+ ; // trivial implementation
+ }
+
+ protected InternetHeaders createInternetHeaders(InputStream inputStream) throws MessagingException {
+ return new InternetHeaders();
+ }
+
+ public void setRecipient(Message.RecipientType recipientType, Address address) throws MessagingException {
+ setRecipients(recipientType, new Address[]{address});
+ }
+
+ public void addRecipient(Message.RecipientType recipientType, Address address) throws MessagingException {
+ setRecipients(recipientType, new Address[]{address});
+ }
+
+ public void setFlag(Flags.Flag flag, boolean set) throws MessagingException {
+ if (set) m_setFlags.add(flag);
+ else m_setFlags.remove(flag);
+ }
+
+ public int getMessageNumber() {
+ return m_iMessageNumber;
+ }
+
+ protected void setMessageNumber(int i) {
+ m_iMessageNumber = i;
+ }
+
+ public Folder getFolder() {
+ return null;
+ }
+
+ public boolean isExpunged() {
+ return m_bIsExpunged;
+ }
+
+ protected void setExpunged(boolean b) {
+ m_bIsExpunged = b;
+ }
+
+ public void setShouldMatch(boolean doMatch) {
+ m_doMatch = doMatch;
+ }
+
+ public boolean match(SearchTerm searchTerm) throws MessagingException {
+ return m_doMatch;
+ }
+}
Modified: james/server/branches/v2.3/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java Thu Aug 3 18:07:18 2006
@@ -1,72 +1,72 @@
-/***********************************************************************
- * Copyright (c) 1999-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-package org.apache.james.test.mock.mailet;
-
-import org.apache.mailet.MailetConfig;
-import org.apache.mailet.MailetContext;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-/**
- * MailetConfig over Properties
- */
-public class MockMailetConfig extends Properties implements MailetConfig {
-
- private String mailetName;
- private MailetContext mc;
-
- public MockMailetConfig(String mailetName, MailetContext mc) {
- super();
- this.mailetName = mailetName;
- this.mc = mc;
- }
-
- public MockMailetConfig(String mailetName, MailetContext mc, Properties arg0) {
- super(arg0);
- this.mailetName = mailetName;
- this.mc = mc;
- }
-
- public String getInitParameter(String name) {
- return getProperty(name);
- }
-
- public Iterator getInitParameterNames() {
- return keySet().iterator();
- }
-
- public MailetContext getMailetContext() {
- return mc;
- }
-
- public String getMailetName() {
- return mailetName;
- }
-
- // Override setProperty to work like it should in this MockMailetConfig
- public Object setProperty(String key, String value) {
- String oldValue = getProperty(key);
- String newValue = value;
-
- if (oldValue != null) {
- newValue = oldValue + "," + value;
- }
- return super.setProperty(key, newValue);
- }
-
-}
+/***********************************************************************
+ * Copyright (c) 1999-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+package org.apache.james.test.mock.mailet;
+
+import org.apache.mailet.MailetConfig;
+import org.apache.mailet.MailetContext;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * MailetConfig over Properties
+ */
+public class MockMailetConfig extends Properties implements MailetConfig {
+
+ private String mailetName;
+ private MailetContext mc;
+
+ public MockMailetConfig(String mailetName, MailetContext mc) {
+ super();
+ this.mailetName = mailetName;
+ this.mc = mc;
+ }
+
+ public MockMailetConfig(String mailetName, MailetContext mc, Properties arg0) {
+ super(arg0);
+ this.mailetName = mailetName;
+ this.mc = mc;
+ }
+
+ public String getInitParameter(String name) {
+ return getProperty(name);
+ }
+
+ public Iterator getInitParameterNames() {
+ return keySet().iterator();
+ }
+
+ public MailetContext getMailetContext() {
+ return mc;
+ }
+
+ public String getMailetName() {
+ return mailetName;
+ }
+
+ // Override setProperty to work like it should in this MockMailetConfig
+ public Object setProperty(String key, String value) {
+ String oldValue = getProperty(key);
+ String newValue = value;
+
+ if (oldValue != null) {
+ newValue = oldValue + "," + value;
+ }
+ return super.setProperty(key, newValue);
+ }
+
+}
Modified: james/server/branches/v2.3/src/test/org/apache/james/transport/LinearProcessorTest.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/transport/LinearProcessorTest.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/transport/LinearProcessorTest.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/transport/LinearProcessorTest.java Thu Aug 3 18:07:18 2006
@@ -165,6 +165,7 @@
assertNotSame(m1,m2);
assertEquals(m1.getSubject(),"new text 1");
assertEquals(m2.getSubject(),"new text 2");
+ m.dispose();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -207,6 +208,7 @@
assertNotSame(m1,m2);
assertEquals("MYSTATE",((Mail) a.get(0)).getState());
assertEquals("MYSTATE",((Mail) a.get(1)).getState());
+ m.dispose();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Modified: james/server/branches/v2.3/src/test/org/apache/james/userrepository/MockUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/userrepository/MockUsersRepository.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/userrepository/MockUsersRepository.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/userrepository/MockUsersRepository.java Thu Aug 3 18:07:18 2006
@@ -1,79 +1,79 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-package org.apache.james.userrepository;
-
-import org.apache.james.security.DigestUtil;
-import org.apache.james.services.User;
-import org.apache.james.services.UsersRepository;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-public class MockUsersRepository implements UsersRepository {
-
- private final HashMap m_users = new HashMap();
-
- /**
- * force the repository to hold implementations of JamesUser interface, instead of User
- * JamesUser is _not_ required as of the UsersRepository interface, so the necessarity forcing it
- * is due to code using UsersRepository while at the same time expecting it to hold JamesUsers
- * (like in RemoteManagerHandler)
- */
- private boolean m_forceUseJamesUser = false;
-
- public void setForceUseJamesUser() {
- m_forceUseJamesUser = true;
- }
-
- public boolean addUser(User user) {
-
- if (m_forceUseJamesUser && user instanceof DefaultUser ) {
- DefaultUser aUser = (DefaultUser)user;
- user = new DefaultJamesUser(aUser.getUserName(),
- aUser.getHashedPassword(),
- aUser.getHashAlgorithm());
- }
-
- String key = user.getUserName();
- if (m_users.containsKey(key)) return false;
- m_users.put(key, user);
- return true;
- }
-
- public void addUser(String name, Object attributes) {
- try {
- String passwordHash = DigestUtil.digestString(((String) attributes), "SHA");
-
- User user;
-
- if (m_forceUseJamesUser) {
- user = new DefaultJamesUser(name, passwordHash, "SHA");
- } else {
- user = new DefaultUser(name, passwordHash, "SHA");
- }
-
- addUser(user);
- } catch (Exception e) {
- e.printStackTrace(); // encoding failed
- }
- }
-
+/***********************************************************************
+ * Copyright (c) 2000-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+package org.apache.james.userrepository;
+
+import org.apache.james.security.DigestUtil;
+import org.apache.james.services.User;
+import org.apache.james.services.UsersRepository;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+public class MockUsersRepository implements UsersRepository {
+
+ private final HashMap m_users = new HashMap();
+
+ /**
+ * force the repository to hold implementations of JamesUser interface, instead of User
+ * JamesUser is _not_ required as of the UsersRepository interface, so the necessarity forcing it
+ * is due to code using UsersRepository while at the same time expecting it to hold JamesUsers
+ * (like in RemoteManagerHandler)
+ */
+ private boolean m_forceUseJamesUser = false;
+
+ public void setForceUseJamesUser() {
+ m_forceUseJamesUser = true;
+ }
+
+ public boolean addUser(User user) {
+
+ if (m_forceUseJamesUser && user instanceof DefaultUser ) {
+ DefaultUser aUser = (DefaultUser)user;
+ user = new DefaultJamesUser(aUser.getUserName(),
+ aUser.getHashedPassword(),
+ aUser.getHashAlgorithm());
+ }
+
+ String key = user.getUserName();
+ if (m_users.containsKey(key)) return false;
+ m_users.put(key, user);
+ return true;
+ }
+
+ public void addUser(String name, Object attributes) {
+ try {
+ String passwordHash = DigestUtil.digestString(((String) attributes), "SHA");
+
+ User user;
+
+ if (m_forceUseJamesUser) {
+ user = new DefaultJamesUser(name, passwordHash, "SHA");
+ } else {
+ user = new DefaultUser(name, passwordHash, "SHA");
+ }
+
+ addUser(user);
+ } catch (Exception e) {
+ e.printStackTrace(); // encoding failed
+ }
+ }
+
public boolean addUser(String username, String password) {
if (m_users.containsKey(username)) return false;
try {
@@ -94,63 +94,63 @@
return false;
}
- public Object getAttributes(String name) {
- return null; // trivial implementation
- }
-
- public User getUserByName(String name) {
- return (User) m_users.get(name);
- }
-
- public User getUserByNameCaseInsensitive(String name) {
- return null; // trivial implementation
- }
-
- public String getRealName(String name) {
- return ((User) m_users.get(name)).getUserName();
- }
-
- public boolean updateUser(User user) {
- return false; // trivial implementation
- }
-
- public void removeUser(String name) {
- m_users.remove(name);
- }
-
- public boolean contains(String name) {
- return m_users.containsKey(name);
- }
-
- public boolean containsCaseInsensitive(String name) {
- return false; // trivial implementation
- }
-
- public boolean test(String name, Object attributes) {
- return false; // trivial implementation
- }
-
- public boolean test(String name, String password) {
- User user = getUserByName(name);
- if (user == null) return false;
- return user.verifyPassword(password);
- }
-
- public int countUsers() {
- return m_users.size();
- }
-
- protected List listUserNames() {
- Iterator users = m_users.values().iterator();
- List userNames = new LinkedList();
- while ( users.hasNext() ) {
- User user = (User)users.next();
- userNames.add(user.getUserName());
- }
-
- return userNames;
- }
- public Iterator list() {
- return listUserNames().iterator();
- }
-}
+ public Object getAttributes(String name) {
+ return null; // trivial implementation
+ }
+
+ public User getUserByName(String name) {
+ return (User) m_users.get(name);
+ }
+
+ public User getUserByNameCaseInsensitive(String name) {
+ return null; // trivial implementation
+ }
+
+ public String getRealName(String name) {
+ return ((User) m_users.get(name)).getUserName();
+ }
+
+ public boolean updateUser(User user) {
+ return false; // trivial implementation
+ }
+
+ public void removeUser(String name) {
+ m_users.remove(name);
+ }
+
+ public boolean contains(String name) {
+ return m_users.containsKey(name);
+ }
+
+ public boolean containsCaseInsensitive(String name) {
+ return false; // trivial implementation
+ }
+
+ public boolean test(String name, Object attributes) {
+ return false; // trivial implementation
+ }
+
+ public boolean test(String name, String password) {
+ User user = getUserByName(name);
+ if (user == null) return false;
+ return user.verifyPassword(password);
+ }
+
+ public int countUsers() {
+ return m_users.size();
+ }
+
+ protected List listUserNames() {
+ Iterator users = m_users.values().iterator();
+ List userNames = new LinkedList();
+ while ( users.hasNext() ) {
+ User user = (User)users.next();
+ userNames.add(user.getUserName());
+ }
+
+ return userNames;
+ }
+ public Iterator list() {
+ return listUserNames().iterator();
+ }
+}
Modified: james/server/branches/v2.3/src/test/org/apache/james/util/ExtraDotOutputStreamTest.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/test/org/apache/james/util/ExtraDotOutputStreamTest.java?rev=428585&r1=428584&r2=428585&view=diff
==============================================================================
--- james/server/branches/v2.3/src/test/org/apache/james/util/ExtraDotOutputStreamTest.java (original)
+++ james/server/branches/v2.3/src/test/org/apache/james/util/ExtraDotOutputStreamTest.java Thu Aug 3 18:07:18 2006
@@ -1,69 +1,69 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation. *
- * All rights reserved. *
- * ------------------------------------------------------------------- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you *
- * may not use this file except in compliance with the License. You *
- * may obtain a copy of the License at: *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, software *
- * distributed under the License is distributed on an "AS IS" BASIS, *
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
- * implied. See the License for the specific language governing *
- * permissions and limitations under the License. *
- ***********************************************************************/
-package org.apache.james.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for the ExtraDotOutputStream
- */
-public class ExtraDotOutputStreamTest extends TestCase {
-
- public void testMain() throws IOException {
- String data = ".This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n.doubled?\r\nor not?\n.doubled\nor not?\r\n\r\n\n\n\r\r\r\n";
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- OutputStream os = new ExtraDotOutputStream(bOut);
- os.write(data.getBytes());
- os.flush();
- String expected = "..This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n..doubled?\r\nor not?\r\n..doubled\r\nor not?\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
- assertEquals(expected,bOut.toString());
- }
-
- /*
- * Test method for 'org.apache.james.util.ExtraDotOutputStream.checkCRLFTerminator()'
- */
- public void testCheckCRLFTerminator() throws IOException {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- ExtraDotOutputStream os = new ExtraDotOutputStream(bOut);
- // if the stream is empty then we should not add the CRLF.
- os.checkCRLFTerminator();
- os.flush();
- assertEquals("",bOut.toString());
- os.write("Test".getBytes());
- os.flush();
- assertEquals("Test",bOut.toString());
- os.checkCRLFTerminator();
- os.flush();
- assertEquals("Test\r\n",bOut.toString());
- // if the stream ends with \r we should simply add the \n
- os.write("A line with incomplete ending\r".getBytes());
- os.flush();
- assertEquals("Test\r\nA line with incomplete ending\r",bOut.toString());
- os.checkCRLFTerminator();
- os.flush();
- assertEquals("Test\r\nA line with incomplete ending\r\n",bOut.toString());
- // already correctly terminated, should leave the output untouched
- os.checkCRLFTerminator();
- os.flush();
- assertEquals("Test\r\nA line with incomplete ending\r\n",bOut.toString());
- }
-
-}
+/***********************************************************************
+ * Copyright (c) 2000-2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You *
+ * may obtain a copy of the License at: *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
+ * implied. See the License for the specific language governing *
+ * permissions and limitations under the License. *
+ ***********************************************************************/
+package org.apache.james.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the ExtraDotOutputStream
+ */
+public class ExtraDotOutputStreamTest extends TestCase {
+
+ public void testMain() throws IOException {
+ String data = ".This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n.doubled?\r\nor not?\n.doubled\nor not?\r\n\r\n\n\n\r\r\r\n";
+ ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+ OutputStream os = new ExtraDotOutputStream(bOut);
+ os.write(data.getBytes());
+ os.flush();
+ String expected = "..This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n..doubled?\r\nor not?\r\n..doubled\r\nor not?\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
+ assertEquals(expected,bOut.toString());
+ }
+
+ /*
+ * Test method for 'org.apache.james.util.ExtraDotOutputStream.checkCRLFTerminator()'
+ */
+ public void testCheckCRLFTerminator() throws IOException {
+ ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+ ExtraDotOutputStream os = new ExtraDotOutputStream(bOut);
+ // if the stream is empty then we should not add the CRLF.
+ os.checkCRLFTerminator();
+ os.flush();
+ assertEquals("",bOut.toString());
+ os.write("Test".getBytes());
+ os.flush();
+ assertEquals("Test",bOut.toString());
+ os.checkCRLFTerminator();
+ os.flush();
+ assertEquals("Test\r\n",bOut.toString());
+ // if the stream ends with \r we should simply add the \n
+ os.write("A line with incomplete ending\r".getBytes());
+ os.flush();
+ assertEquals("Test\r\nA line with incomplete ending\r",bOut.toString());
+ os.checkCRLFTerminator();
+ os.flush();
+ assertEquals("Test\r\nA line with incomplete ending\r\n",bOut.toString());
+ // already correctly terminated, should leave the output untouched
+ os.checkCRLFTerminator();
+ os.flush();
+ assertEquals("Test\r\nA line with incomplete ending\r\n",bOut.toString());
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org