james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r420564 - in /james/server/trunk/src: java/org/apache/james/core/MimeMessageWrapper.java test/org/apache/james/core/MimeMessageWrapperTest.java test/org/apache/james/mailrepository/AvalonMailRepositoryTest.java
Date Mon, 10 Jul 2006 15:24:49 GMT
Author: bago
Date: Mon Jul 10 08:24:48 2006
New Revision: 420564

URL: http://svn.apache.org/viewvc?rev=420564&view=rev
Log:
Further mimemessage handling optimisation conservative changes (not a code revert, but a logical
revert) (JAMES-559)
It seems to work even without this change because of a weird behaviour of MimeMessage.saveChanges
in Sun Javamail.

Modified:
    james/server/trunk/src/java/org/apache/james/core/MimeMessageWrapper.java
    james/server/trunk/src/test/org/apache/james/core/MimeMessageWrapperTest.java
    james/server/trunk/src/test/org/apache/james/mailrepository/AvalonMailRepositoryTest.java

Modified: james/server/trunk/src/java/org/apache/james/core/MimeMessageWrapper.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/core/MimeMessageWrapper.java?rev=420564&r1=420563&r2=420564&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/core/MimeMessageWrapper.java (original)
+++ james/server/trunk/src/java/org/apache/james/core/MimeMessageWrapper.java Mon Jul 10 08:24:48
2006
@@ -410,10 +410,16 @@
 
 
     private synchronized void checkModifyHeaders() throws MessagingException {
+        // Disable only-header loading optimizations for JAMES-559
+        if (!messageParsed) {
+            loadMessage();
+        }
+        // End JAMES-559
         if (headers == null) {
             loadHeaders();
         }
         modified = true;
+        saved = false;
         headersModified = true;
     }
 
@@ -446,6 +452,7 @@
      */
     public synchronized void setDataHandler(DataHandler arg0) throws MessagingException {
         modified = true;
+        saved = false;
         bodyModified = true;
         super.setDataHandler(arg0);
     }

Modified: james/server/trunk/src/test/org/apache/james/core/MimeMessageWrapperTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/core/MimeMessageWrapperTest.java?rev=420564&r1=420563&r2=420564&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/core/MimeMessageWrapperTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/core/MimeMessageWrapperTest.java Mon Jul
10 08:24:48 2006
@@ -125,6 +125,7 @@
         assertFalse(mw.isModified());
     }
 
+    /** this is commented out due optimisation reverts (JAMES-559) 
     public void testDeferredMessageLoadingWhileWriting() throws MessagingException, IOException
{
         mw.setMessageLoadable(false);
         assertEquals("foo",mw.getSubject());
@@ -136,6 +137,7 @@
         mw.setMessageLoadable(true);
         
     }
+    */
 
     public void testDeferredHeaderLoading() throws MessagingException, IOException {
         mw.setHeadersLoadable(false);

Modified: james/server/trunk/src/test/org/apache/james/mailrepository/AvalonMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/mailrepository/AvalonMailRepositoryTest.java?rev=420564&r1=420563&r2=420564&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/mailrepository/AvalonMailRepositoryTest.java
(original)
+++ james/server/trunk/src/test/org/apache/james/mailrepository/AvalonMailRepositoryTest.java
Mon Jul 10 08:24:48 2006
@@ -108,5 +108,69 @@
         mr.remove("mail1");
 
     }
+
+
+    /**
+     * This test has been written as a proof to:
+     * http://issues.apache.org/jira/browse/JAMES-559
+     */
+    public void testJames559WithoutSaveChanges() throws Exception {
+        AvalonMailRepository mr = new AvalonMailRepository();
+        MockStore mockStore = new MockStore();
+        File_Persistent_Stream_Repository file_Persistent_Stream_Repository = new File_Persistent_Stream_Repository();
+        MockContext mockContext = new MockContext(new File("."));
+        file_Persistent_Stream_Repository.contextualize(mockContext);
+        file_Persistent_Stream_Repository.enableLogging(new MockLogger());
+        DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration("conf");
+        defaultConfiguration2.setAttribute("destinationURL", "file://var/mr");
+        file_Persistent_Stream_Repository.configure(defaultConfiguration2);
+        file_Persistent_Stream_Repository.initialize();
+        mockStore.add("STREAM.mr", file_Persistent_Stream_Repository);
+        File_Persistent_Object_Repository file_Persistent_Object_Repository = new File_Persistent_Object_Repository();
+        file_Persistent_Object_Repository.contextualize(mockContext);
+        file_Persistent_Object_Repository.enableLogging(new MockLogger());
+        DefaultConfiguration defaultConfiguration22 = new DefaultConfiguration("conf");
+        defaultConfiguration22.setAttribute("destinationURL", "file://var/mr");
+        file_Persistent_Object_Repository.configure(defaultConfiguration22);
+        file_Persistent_Object_Repository.initialize();
+        mockStore.add("OBJECT.mr", file_Persistent_Object_Repository);
+        mr.setStore(mockStore);
+
+        mr.enableLogging(new MockLogger());
+        DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf");
+        defaultConfiguration.setAttribute("destinationURL","file://var/mr");
+        defaultConfiguration.setAttribute("type","MAIL");
+        mr.configure(defaultConfiguration);
+        mr.initialize();
+
+        MimeMessageInputStreamSource mmis = null;
+        try {
+            mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream((content+sep+body).getBytes()));
+        } catch (MessagingException e) {
+        }
+        MimeMessage mimeMessage = new MimeMessageCopyOnWriteProxy(mmis);
+        Collection recipients = new ArrayList();
+        recipients.add(new MailAddress("rec1","domain.com"));
+        recipients.add(new MailAddress("rec2","domain.com"));
+        MailImpl m = new MailImpl("mail1",new MailAddress("sender","domain.com"),recipients,mimeMessage);
+        mr.store(m);
+        
+        Mail m2 = mr.retrieve("mail1");
+        m2.getMessage().setHeader("X-Header", "foobar");
+        
+        mr.store(m2);
+        // ALWAYS remember to dispose mails!
+        ContainerUtil.dispose(m2);
+        
+        m2 = mr.retrieve("mail1");
+        assertEquals(m.getMessage().getContent().toString(),m2.getMessage().getContent().toString());
+        
+        m.dispose();
+        ContainerUtil.dispose(m2);
+        
+        mr.remove("mail1");
+
+    }
+
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message