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("[EMAIL PROTECTED]"));
@@ -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("[EMAIL PROTECTED]"));
+ MimeMessage m = new MimeMessage(Session.getDefaultInstance(new
Properties(null)));
+ m.setText("CIPS");
+ MailImpl mail = new MailImpl("test",new
MailAddress("[email protected]"),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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]