james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r452965 - in /james/server/trunk: lib/ src/java/org/apache/james/smtpserver/core/ src/java/org/apache/james/transport/mailets/ src/test/org/apache/james/smtpserver/
Date Wed, 04 Oct 2006 18:29:23 GMT
Author: bago
Date: Wed Oct  4 11:29:22 2006
New Revision: 452965

URL: http://svn.apache.org/viewvc?view=rev&rev=452965
Log:
Updated javamail to 1.4.1ea 15/Sep/2006 (CDDL)
Re-enabled code previously disabled per javamail bugs and added few tests.
They seem to pass and 1.4.1ea works fine! (JAMES-52, JAMES-410)

Added:
    james/server/trunk/lib/mail-1.4.1ea-SNAPSHOT.jar   (with props)
Removed:
    james/server/trunk/lib/mail-1.4.jar
Modified:
    james/server/trunk/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
    james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
    james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java

Added: james/server/trunk/lib/mail-1.4.1ea-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/james/server/trunk/lib/mail-1.4.1ea-SNAPSHOT.jar?view=auto&rev=452965
==============================================================================
Binary file - no diff available.

Propchange: james/server/trunk/lib/mail-1.4.1ea-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java?view=diff&rev=452965&r1=452964&r2=452965
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java Wed Oct
 4 11:29:22 2006
@@ -83,7 +83,7 @@
         esmtpextensions.add("PIPELINING");
         esmtpextensions.add("ENHANCEDSTATUSCODES");
         // see http://issues.apache.org/jira/browse/JAMES-419 
-        //esmtpextensions.add("8BITMIME");
+        esmtpextensions.add("8BITMIME");
 
         // Iterator i = esmtpextensions.iterator();
         for (int i = 0; i < esmtpextensions.size(); i++) {

Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java?view=diff&rev=452965&r1=452964&r2=452965
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java Wed
Oct  4 11:29:22 2006
@@ -215,7 +215,7 @@
 
     private Perl5Matcher delayTimeMatcher; //matcher use at init time to parse delaytime
parameters
     private MultipleDelayFilter delayFilter = new MultipleDelayFilter ();//used by accept
to selcet the next mail ready for processing
-
+    private Properties defprops = new Properties(); // default properties for the javamail
Session
     
     /**
      * Initialize the mailet
@@ -361,6 +361,14 @@
         } catch (UnknownHostException e) {
             log("Invalid bind setting (" + bindAddress + "): " + e.toString());
         }
+        Iterator i = getInitParameterNames();
+        while (i.hasNext()) {
+            String name = (String) i.next();
+            if (name.startsWith("mail.")) {
+                defprops.put(name,getInitParameter(name));
+            }
+            
+        }  
     }
 
     /*
@@ -517,7 +525,6 @@
                             // rfc-compliant smtp server.
                             
                             // Temporarily disabled. See JAMES-638
-                            /*
                             if (!smtpTransport.supportsExtension("8BITMIME")) { 
                                 try {
                                     convertTo7Bit(message);
@@ -528,20 +535,6 @@
                                     log("Error during the conversion to 7 bit.", e);
                                 }
                             }
-                            */
-                            
-                            /*
-                             * Workaround for a javamail 1.3.2 bug: if
-                             * a message is sent without encoding information
-                             * and the 8bit allow property is set an exception
-                             * is trown during the mail delivery.
-                             */
-                            
-                            try {
-                                setEncodingIfMissing(message);
-                            } catch (IOException e) {
-                                log("Error while adding encoding information to the message",
e);
-                            }
                         } else {
                             // If the transport is not the one
                             // developed by Sun we are not sure of how it
@@ -782,32 +775,6 @@
     }
     
     /**
-     * Adds an encoding information to each text mime part. This is a workaround
-     * for a javamail 1.3.2 bug: if a message is sent without encoding
-     * information a null pointer exception is thrown during the message
-     * delivery.
-     * 
-     * @param part
-     * @throws MessagingException
-     * @throws IOException
-     */
-    private void setEncodingIfMissing(MimePart part) throws MessagingException, IOException
{
-        if (part.isMimeType("text/*")) {
-            String enc = part.getEncoding();
-            if (enc == null) part.setHeader("Content-Transfer-Encoding", "7bit");
-        } else if (part.isMimeType("multipart/*")) {
-            Object content = part.getContent();
-            if (content instanceof MimeMultipart) {
-                MimeMultipart parts = (MimeMultipart) content;
-                int count = parts.getCount();
-                for (int i = 0; i < count; i++) {
-                    setEncodingIfMissing((MimePart)parts.getBodyPart(i));
-                }
-            }
-        }
-    }
-    
-    /**
      * Insert the method's description here.
      * Creation date: (2/25/00 1:14:18 AM)
      * @param mail org.apache.james.core.MailImpl
@@ -1066,7 +1033,7 @@
         // send 8 bit data to the server (if it supports the 8bitmime extension).
         // 2006/03/01 reverted to false because of a javamail bug converting to 8bit
         // messages created by an inputstream.
-        props.setProperty("mail.smtp.allow8bitmime", "false");
+        props.setProperty("mail.smtp.allow8bitmime", "true");
         //Sets timeout on going connections
         props.put("mail.smtp.timeout", smtpTimeout + "");
 
@@ -1096,6 +1063,8 @@
         if (authUser != null) {
             props.put("mail.smtp.auth","true");
         }
+        
+        props.putAll(defprops);
 
         Session session = Session.getInstance(props, null);
         try {

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java?view=diff&rev=452965&r1=452964&r2=452965
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java Wed Oct  4
11:29:22 2006
@@ -227,10 +227,10 @@
             capabilitieslist.add(capabilityRes[i].substring(4));
         }
         
-        assertEquals("capabilities", 2, capabilitieslist.size());
+        assertEquals("capabilities", 3, capabilitieslist.size());
         assertTrue("capabilities present PIPELINING", capabilitieslist.contains("PIPELINING"));
         assertTrue("capabilities present ENHANCEDSTATUSCODES", capabilitieslist.contains("ENHANCEDSTATUSCODES"));
-        //assertTrue("capabilities present 8BITMIME", capabilitieslist.contains("8BITMIME"));
+        assertTrue("capabilities present 8BITMIME", capabilitieslist.contains("8BITMIME"));
 
         smtpProtocol.setSender("mail@localhost");
         smtpProtocol.addRecipient("mail@localhost");
@@ -1098,7 +1098,7 @@
      * This is useful code to run tests on javamail bugs 
      * http://issues.apache.org/jira/browse/JAMES-52
      * 
-     * This 
+     * This one passes with javamail 1.4.1EA
      * @throws Exception
      */
     public void test8bitmimeFromStream() throws Exception {
@@ -1116,7 +1116,97 @@
         mci.setProperty("gatewayPort",""+m_smtpListenerPort);
         rd.init(mci);
         
-        String sources = "Content-Type: text/plain;\r\nContent-Transfer-Encoding: quoted-printable\r\nSubject:
test\r\n\r\nBody=80\r\n";
+        //String sources = "Content-Type: text/plain;\r\nContent-Transfer-Encoding: quoted-printable\r\nSubject:
test\r\n\r\nBody=80\r\n";
+        String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
quoted-printable\r\nSubject: test\r\n\r\nBody=80\r\n";
+        //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
8bit\r\nSubject: test\r\n\r\nBody\u20AC\r\n";
+        String sender = "test@localhost";
+        String recipient = "test@localhost";
+        MimeMessage mm = new MimeMessage(Session.getDefaultInstance(new Properties()),new
ByteArrayInputStream(sources.getBytes()));
+        MailImpl mail = new MailImpl("name",new MailAddress(sender),Arrays.asList(new MailAddress[]
{new MailAddress(recipient)}),mm);
+        
+        rd.service(mail);
+        
+        while (outgoingSpool.size() > 0) {
+            Thread.sleep(1000);
+        }
+
+        // verifyLastMail(sender, recipient, mm);
+        verifyLastMail(sender, recipient, null);
+        
+        // THIS WOULD FAIL BECAUSE OF THE JAVAMAIL BUG
+        assertEquals(mm.getContent(),m_mailServer.getLastMail().getMessage().getContent());
+        
+        mail.dispose();
+    }
+    
+    /**
+     * This is useful code to run tests on javamail bugs 
+     * http://issues.apache.org/jira/browse/JAMES-52
+     * 
+     * This one passes with javamail 1.4.1EA
+     * @throws Exception
+     */
+    public void test8bitmimeFromStreamWith8bitContent() throws Exception {
+        finishSetUp(m_testConfiguration);
+        outgoingSpool = new InMemorySpoolRepository();
+        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
+        
+        RemoteDelivery rd = new RemoteDelivery();
+        
+        MockMailContext mmc = new MockMailContext();
+        mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
+        mmc.setAttribute(Constants.HELLO_NAME,"localhost");
+        MockMailetConfig mci = new MockMailetConfig("Test",mmc,getStandardParameters());
+        mci.setProperty("gateway","127.0.0.1");
+        mci.setProperty("gatewayPort",""+m_smtpListenerPort);
+        rd.init(mci);
+        
+        //String sources = "Content-Type: text/plain;\r\nContent-Transfer-Encoding: quoted-printable\r\nSubject:
test\r\n\r\nBody=80\r\n";
+        //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
quoted-printable\r\nSubject: test\r\n\r\nBody=80\r\n";
+        String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
8bit\r\nSubject: test\r\n\r\nBody\u20AC\r\n";
+        String sender = "test@localhost";
+        String recipient = "test@localhost";
+        MimeMessage mm = new MimeMessage(Session.getDefaultInstance(new Properties()),new
ByteArrayInputStream(sources.getBytes()));
+        MailImpl mail = new MailImpl("name",new MailAddress(sender),Arrays.asList(new MailAddress[]
{new MailAddress(recipient)}),mm);
+        
+        rd.service(mail);
+        
+        while (outgoingSpool.size() > 0) {
+            Thread.sleep(1000);
+        }
+
+        // verifyLastMail(sender, recipient, mm);
+        verifyLastMail(sender, recipient, null);
+        
+        // THIS WOULD FAIL BECAUSE OF THE JAVAMAIL BUG
+        assertEquals(mm.getContent(),m_mailServer.getLastMail().getMessage().getContent());
+        
+        mail.dispose();
+    }
+    
+    /**
+     * This is useful code to run tests on javamail bugs 
+     * http://issues.apache.org/jira/browse/JAMES-52
+     * 
+     * This one passes with javamail 1.4.1EA
+     * @throws Exception
+     */
+    public void test8bitmimeFromStreamWithoutContentTransferEncoding() throws Exception {
+        finishSetUp(m_testConfiguration);
+        outgoingSpool = new InMemorySpoolRepository();
+        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
+        
+        RemoteDelivery rd = new RemoteDelivery();
+        
+        MockMailContext mmc = new MockMailContext();
+        mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
+        mmc.setAttribute(Constants.HELLO_NAME,"localhost");
+        MockMailetConfig mci = new MockMailetConfig("Test",mmc,getStandardParameters());
+        mci.setProperty("gateway","127.0.0.1");
+        mci.setProperty("gatewayPort",""+m_smtpListenerPort);
+        rd.init(mci);
+        
+        String sources = "Content-Type: text/plain;\r\nSubject: test\r\n\r\nBody\u03B2\r\n";
         //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
quoted-printable\r\nSubject: test\r\n\r\nBody=80\r\n";
         //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
8bit\r\nSubject: test\r\n\r\nBody\u20AC\r\n";
         String sender = "test@localhost";
@@ -1134,7 +1224,98 @@
         verifyLastMail(sender, recipient, null);
         
         // THIS WOULD FAIL BECAUSE OF THE JAVAMAIL BUG
-        // assertEquals(mm.getContent(),((MimeMessage) m_mailServer.getLastMail()[2]).getContent());
+        assertEquals(mm.getContent(),m_mailServer.getLastMail().getMessage().getContent());
+        
+        mail.dispose();
+    }
+    
+    /**
+     * This is useful code to run tests on javamail bugs 
+     * http://issues.apache.org/jira/browse/JAMES-52
+     * 
+     * This one passes with javamail 1.4.1EA
+     * @throws Exception
+     */
+    public void test8bitmimeFromStreamWithoutContentTransferEncodingSentAs8bit() throws Exception
{
+        finishSetUp(m_testConfiguration);
+        outgoingSpool = new InMemorySpoolRepository();
+        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
+        
+        RemoteDelivery rd = new RemoteDelivery();
+        
+        MockMailContext mmc = new MockMailContext();
+        mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
+        mmc.setAttribute(Constants.HELLO_NAME,"localhost");
+        MockMailetConfig mci = new MockMailetConfig("Test",mmc,getStandardParameters());
+        mci.setProperty("gateway","127.0.0.1");
+        mci.setProperty("gatewayPort",""+m_smtpListenerPort);
+        rd.init(mci);
+        
+        String sources = "Content-Type: text/plain;\r\nSubject: test\r\n\r\nBody=32=48\r\n";
+        //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
quoted-printable\r\nSubject: test\r\n\r\nBody=80\r\n";
+        //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
8bit\r\nSubject: test\r\n\r\nBody\u20AC\r\n";
+        String sender = "test@localhost";
+        String recipient = "test@localhost";
+        MimeMessage mm = new MimeMessage(Session.getDefaultInstance(new Properties()),new
ByteArrayInputStream(sources.getBytes()));
+        MailImpl mail = new MailImpl("name",new MailAddress(sender),Arrays.asList(new MailAddress[]
{new MailAddress(recipient)}),mm);
+        
+        rd.service(mail);
+        
+        while (outgoingSpool.size() > 0) {
+            Thread.sleep(1000);
+        }
+
+        // verifyLastMail(sender, recipient, mm);
+        verifyLastMail(sender, recipient, null);
+        
+        // THIS WOULD FAIL BECAUSE OF THE JAVAMAIL BUG
+        assertEquals(mm.getContent(),m_mailServer.getLastMail().getMessage().getContent());
+        
+        mail.dispose();
+    }
+    
+    /**
+     * This is useful code to run tests on javamail bugs 
+     * http://issues.apache.org/jira/browse/JAMES-52
+     * 
+     * This one passes with javamail 1.4.1EA
+     * @throws Exception
+     */
+    public void test8bitmimeWith8bitmimeDisabledInServer() throws Exception {
+        finishSetUp(m_testConfiguration);
+        outgoingSpool = new InMemorySpoolRepository();
+        ((MockStore) m_serviceManager.lookup(Store.ROLE)).add("outgoing", outgoingSpool);
+        
+        RemoteDelivery rd = new RemoteDelivery();
+        
+        MockMailContext mmc = new MockMailContext();
+        mmc.setAttribute(Constants.AVALON_COMPONENT_MANAGER,m_serviceManager);
+        mmc.setAttribute(Constants.HELLO_NAME,"localhost");
+        MockMailetConfig mci = new MockMailetConfig("Test",mmc,getStandardParameters());
+        mci.setProperty("gateway","127.0.0.1");
+        mci.setProperty("gatewayPort",""+m_smtpListenerPort);
+        mci.setProperty("mail.smtp.allow8bitmime", "false");
+        rd.init(mci);
+        
+        //String sources = "Content-Type: text/plain;\r\nSubject: test\r\n\r\nBody=32=48\r\n";
+        //String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
quoted-printable\r\nSubject: test\r\n\r\nBody=80\r\n";
+        String sources = "Content-Type: text/plain; charset=iso-8859-15\r\nContent-Transfer-Encoding:
8bit\r\nSubject: test\r\n\r\nBody\u20AC\r\n";
+        String sender = "test@localhost";
+        String recipient = "test@localhost";
+        MimeMessage mm = new MimeMessage(Session.getDefaultInstance(new Properties()),new
ByteArrayInputStream(sources.getBytes()));
+        MailImpl mail = new MailImpl("name",new MailAddress(sender),Arrays.asList(new MailAddress[]
{new MailAddress(recipient)}),mm);
+        
+        rd.service(mail);
+        
+        while (outgoingSpool.size() > 0) {
+            Thread.sleep(1000);
+        }
+
+        // verifyLastMail(sender, recipient, mm);
+        verifyLastMail(sender, recipient, null);
+        
+        // THIS WOULD FAIL BECAUSE OF THE JAVAMAIL BUG
+        assertEquals(mm.getContent(),m_mailServer.getLastMail().getMessage().getContent());
         
         mail.dispose();
     }



---------------------------------------------------------------------
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