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/05/07 17:19:48 UTC
svn commit: r404782 -
/james/server/trunk/src/test/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
Author: bago
Date: Sun May 7 08:19:44 2006
New Revision: 404782
URL: http://svn.apache.org/viewcvs?rev=404782&view=rev
Log:
One more test for the MMCoW object (still investigating on JAMES-474)
Modified:
james/server/trunk/src/test/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
Modified: james/server/trunk/src/test/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java?rev=404782&r1=404781&r2=404782&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java Sun May 7 08:19:44 2006
@@ -21,10 +21,12 @@
import org.apache.mailet.MailAddress;
import javax.mail.MessagingException;
+import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.mail.util.SharedByteArrayInputStream;
import java.util.ArrayList;
+import java.util.Properties;
public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest {
@@ -109,6 +111,10 @@
ContainerUtil.dispose(messageFromSources);
}
+ /**
+ * If I create a new MimeMessageCopyOnWriteProxy from another MimeMessageCopyOnWriteProxy,
+ * I remove references to the first and I change the second, then it should not clone
+ */
public void testMessageAvoidCloning() throws Exception {
ArrayList r = new ArrayList();
r.add(new MailAddress("recipient@test.com"));
@@ -134,6 +140,31 @@
assertTrue(isSameMimeMessage(mailClone.getMessage(),mm));
ContainerUtil.dispose(mailClone);
ContainerUtil.dispose(mm);
+ }
+
+
+ /**
+ * If I create a new MimeMessageCopyOnWriteProxy from a MimeMessage and I change the new
+ * message, the original should be unaltered and the proxy should clone the message.
+ */
+ public void testMessageCloning3() throws Exception {
+ ArrayList r = new ArrayList();
+ r.add(new MailAddress("recipient@test.com"));
+ MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties(null)));
+ m.setText("CIPS");
+ MailImpl mail = new MailImpl("test",new MailAddress("test@test.com"),r,m);
+ assertTrue(isSameMimeMessage(m,mail.getMessage()));
+ // change the message that should be not referenced by mail that has
+ // been disposed, so it should not clone it!
+ System.gc();
+ Thread.sleep(100);
+ mail.getMessage().setSubject("new Subject 2");
+ mail.getMessage().setText("new Body 3");
+ System.gc();
+ Thread.sleep(100);
+ assertFalse(isSameMimeMessage(m,mail.getMessage()));
+ ContainerUtil.dispose(mail);
+ ContainerUtil.dispose(m);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org