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 2008/09/27 15:36:11 UTC

svn commit: r699641 - in /james/mailet/standard/trunk/src: main/java/org/apache/james/transport/mailets/ test/java/org/apache/james/transport/mailets/

Author: bago
Date: Sat Sep 27 06:36:11 2008
New Revision: 699641

URL: http://svn.apache.org/viewvc?rev=699641&view=rev
Log:
Added support for storing into attributes to StripAttachment mailet (JAMES-235).
Added RecoverAttachment mailet ro restore attachments stored in a mail attributes.
Added tests for StripAttachment and a simple Recover test.

Added:
    james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java   (with props)
    james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java   (with props)
Modified:
    james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/StripAttachment.java

Added: james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java
URL: http://svn.apache.org/viewvc/james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java?rev=699641&view=auto
==============================================================================
--- james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java (added)
+++ james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java Sat Sep 27 06:36:11 2008
@@ -0,0 +1,118 @@
+package org.apache.james.transport.mailets;
+
+import org.apache.mailet.GenericMailet;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailetException;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * <p>
+ * This mailet takes an attachment stored in an attribute and
+ * attach it back to the message
+ * </p>
+ * <p>
+ * This may be used to place back attachment stripped by StripAttachment and stored in the
+ * attribute <code>org.apache.james.transport.mailets.StripAttachment.saved</code>
+ * </p>
+ * <p>
+ * 
+ * <pre>
+ *   &lt;mailet match=&quot;All&quot; class=&quot;RecoverAttachment&quot; &gt;
+ *     &lt;attribute&gt;my.attribute.name&lt;/attribute&gt;
+ *   &lt;/mailet &gt;
+ * </pre>
+ * 
+ * </p>
+ */
+public class RecoverAttachment extends GenericMailet {
+
+	public static final String ATTRIBUTE_PARAMETER_NAME = "attribute";
+	private String attributeName = null;
+
+	/**
+	 * Checks if the mandatory parameters are present
+	 * 
+	 * @throws MailetException
+	 */
+	public void init() throws MailetException {
+		attributeName = getInitParameter(ATTRIBUTE_PARAMETER_NAME);
+		
+		if (attributeName == null) {
+			throw new MailetException(ATTRIBUTE_PARAMETER_NAME+" is a mandatory parameter");
+		}
+		
+		log("RecoverAttachment is initialised with attribute ["+attributeName+"]");
+	}
+
+	/**
+	 * Service the mail: check for the attribute and attach the attachment
+	 * to the mail.
+	 * 
+	 * @param mail
+	 *          The mail to service
+	 * @throws MailetException
+	 *           Thrown when an error situation is encountered.
+	 */
+	public void service(Mail mail) throws MailetException {
+		Map attachments = (Map) mail.getAttribute(attributeName);
+		if (attachments != null) {
+
+			MimeMessage message = null;
+			try {
+				message = mail.getMessage();
+			} catch (MessagingException e) {
+				throw new MailetException("Could not retrieve message from Mail object",
+						e);
+			}
+
+			Iterator i = attachments.values().iterator();
+			try {
+				while (i.hasNext()) {
+					byte[] bytes = (byte[]) i.next();
+					InputStream is = new BufferedInputStream(new ByteArrayInputStream(bytes));
+					MimeBodyPart p = new MimeBodyPart(is);
+					if (!(message.isMimeType("multipart/*") && (message.getContent() instanceof MimeMultipart))) {
+						Object content = message.getContent();
+						String contentType = message.getContentType();
+						MimeMultipart mimeMultipart = new MimeMultipart();
+						message.setContent(mimeMultipart);
+						// This saveChanges is required when the MimeMessage has been created from
+						// an InputStream, otherwise it is not saved correctly.
+						message.saveChanges();
+						mimeMultipart.setParent(message);
+						MimeBodyPart bodyPart = new MimeBodyPart();
+						mimeMultipart.addBodyPart(bodyPart);
+						bodyPart.setContent(content, contentType);
+					}
+					((MimeMultipart) message.getContent()).addBodyPart(p);
+				}
+				message.saveChanges();
+			} catch (MessagingException e) {
+				log("MessagingException in recoverAttachment", e);
+			} catch (IOException e) {
+				log("IOException in recoverAttachment", e);
+			}
+		}
+	}
+
+	/**
+	 * returns a String describing this mailet.
+	 * 
+	 * @return A desciption of this mailet
+	 */
+	public String getMailetInfo() {
+		return "RecoverAttachment Mailet";
+	}
+
+}

Propchange: james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/RecoverAttachment.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/StripAttachment.java
URL: http://svn.apache.org/viewvc/james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/StripAttachment.java?rev=699641&r1=699640&r2=699641&view=diff
==============================================================================
--- james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/StripAttachment.java (original)
+++ james/mailet/standard/trunk/src/main/java/org/apache/james/transport/mailets/StripAttachment.java Sat Sep 27 06:36:11 2008
@@ -13,25 +13,35 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.Pattern;
 
 /**
  * <p>
+ * Remove attachments from a Message.
+ * Supports simple removal, storing to file, or storing to mail attributes. 
+ * </p>
+ * <p>
  * Configuration:
  * </p>
  * <p>
  * 
  * <pre>
  *   &lt;mailet match=&quot;All&quot; class=&quot;StripAttachment&quot; &gt;
- *     &lt;pattern &gt;.*\.xls &lt;/pattern &gt;  &lt;!-- The regular expression that must be matched -- &gt;
- *     &lt;directory &gt;c:\temp\james_attach &lt;/directory &gt;   &lt;!-- The directory to save to -- &gt;
- *     &lt;remove &gt;all &lt;/remove &gt;   &lt;!-- either &quot;no&quot;, &quot;matched&quot;, &quot;all&quot; -- &gt;
+ *     &lt;pattern &gt;.*\.xls &lt;/pattern&gt;  &lt;!-- The regular expression that must be matched -- &gt;
+ *     &lt;!-- notpattern &gt;.*\.xls &lt;/notpattern--&gt;  &lt;!-- The regular expression that must be matched -- &gt;
+ *     &lt;directory &gt;c:\temp\james_attach &lt;/directory&gt;   &lt;!-- The directory to save to -- &gt;
+ *     &lt;remove &gt;all &lt;/remove&gt;   &lt;!-- either &quot;no&quot;, &quot;matched&quot;, &quot;all&quot; -- &gt;
+ *     &lt;!-- attribute&gt;my.attribute.name&lt;/attribute --&gt;
  *   &lt;/mailet &gt;
  * </pre>
  * 
@@ -41,6 +51,7 @@
 
 	public static final String PATTERN_PARAMETER_NAME = "pattern";
 	public static final String NOTPATTERN_PARAMETER_NAME = "notpattern";
+	public static final String ATTRIBUTE_PARAMETER_NAME = "attribute";
 	public static final String DIRECTORY_PARAMETER_NAME = "directory";
 	public static final String REMOVE_ATTACHMENT_PARAMETER_NAME = "remove"; // either "no", "matched", "all"
 	public static final String DECODE_FILENAME_PARAMETER_NAME = "decodeFilename"; // either "true", "false"
@@ -55,6 +66,7 @@
 	private String notpatternString = null;
 	private String removeAttachments = null;
 	private String directoryName = null;
+	private String attributeName = null;
 	private Pattern regExPattern = null;
 	private Pattern notregExPattern = null;
 	
@@ -84,6 +96,7 @@
 		}
 
 		directoryName = getInitParameter(DIRECTORY_PARAMETER_NAME);
+		attributeName = getInitParameter(ATTRIBUTE_PARAMETER_NAME);
 
 		removeAttachments = getInitParameter(REMOVE_ATTACHMENT_PARAMETER_NAME,
 				REMOVE_NONE).toLowerCase();
@@ -131,6 +144,9 @@
 		if (directoryName != null) {
 			toLog += " and will save to directory [" + directoryName + "]";
 		}
+		if (attributeName != null) {
+			toLog += " and will store attachments to attribute [" + attributeName + "]";
+		}
 		log(toLog);
 	}
 
@@ -249,11 +265,24 @@
 						c.add(filename);
 					}
 				}
+				if (attributeName != null) {
+					Map m = (Map) mail.getAttribute(attributeName);
+					if (m == null) {
+						m = new LinkedHashMap();
+						mail.setAttribute(attributeName, (LinkedHashMap) m);
+					}
+					ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+					OutputStream os = new BufferedOutputStream(byteArrayOutputStream);
+					part.writeTo(os);
+					m.put(fileName, byteArrayOutputStream.toByteArray());
+				}
 				if (removeAttachments.equals(REMOVE_MATCHED)) {
 					ret = true;
 				}
 			}
-			ret = removeAttachments.equals(REMOVE_ALL);
+			if (!ret) {
+				ret = removeAttachments.equals(REMOVE_ALL);
+			}
 			if (ret) {
 				Collection c = (Collection) mail
 						.getAttribute(REMOVED_ATTACHMENTS_ATTRIBUTE_KEY);
@@ -307,10 +336,11 @@
 			if (fileName != null) {
 				pos = fileName.lastIndexOf(".");
 			}
-			String ext = pos > 0 ? (fileName.substring(pos)) : ".bin";
-			fileName = pos > 0 ? (fileName.substring(0, pos)) : fileName;
-			while (fileName.length() < 3) fileName += "_";
-			f = File.createTempFile(fileName,ext,new File(directoryName));
+			String prefix = pos > 0 ? (fileName.substring(0, pos)) : fileName;
+			String suffix = pos > 0 ? (fileName.substring(pos)) : ".bin";
+			while (prefix.length() < 3) prefix += "_";
+			if (suffix.length() == 0) suffix = ".bin";
+			f = File.createTempFile(prefix,suffix,new File(directoryName));
 			log("saving content of " + f.getName() + "...");
 			os = new BufferedOutputStream(new FileOutputStream(f));
 			is = part.getInputStream();
@@ -325,7 +355,7 @@
 			return f.getName();
 		} catch (Exception e) {
 			log("Error while saving contents of ["
-					+ (f != null ? f.getName() : part.getFileName()) + "].", e);
+					+ (f != null ? f.getName() : (part != null ? part.getFileName() : "NULL")) + "].", e);
 			throw e;
 		} finally {
 			is.close();

Added: james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
URL: http://svn.apache.org/viewvc/james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java?rev=699641&view=auto
==============================================================================
--- james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java (added)
+++ james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java Sat Sep 27 06:36:11 2008
@@ -0,0 +1,314 @@
+package org.apache.james.transport.mailets;
+
+import org.apache.james.test.mock.mailet.MockMail;
+import org.apache.james.test.mock.mailet.MockMailContext;
+import org.apache.james.test.mock.mailet.MockMailetConfig;
+import org.apache.mailet.Mail;
+import org.apache.mailet.Mailet;
+import org.codehaus.plexus.util.IOUtil;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+public class StripAttachmentTest extends TestCase {
+
+	public void testNoAttachment() {
+
+	}
+
+	public void testSimpleAttachment() throws MessagingException, IOException {
+		Mailet mailet = initMailet();
+
+		MimeMessage message = new MimeMessage(Session
+				.getDefaultInstance(new Properties()));
+		
+		MimeMultipart mm = new MimeMultipart();
+		MimeBodyPart mp = new MimeBodyPart();
+		mp.setText("simple text");
+		mm.addBodyPart(mp);
+		String body = "ùàòòùàòùàòùàòùàòù";
+		MimeBodyPart mp2 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body).getBytes()));
+		mp2.setDisposition("attachment");
+		mp2.setFileName("10.tmp");
+		mm.addBodyPart(mp2);
+		String body2 = "dglkjhdfòlgkj";
+		MimeBodyPart mp3 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body2).getBytes()));
+		mp3.setDisposition("attachment");
+		mp3.setFileName("temp.zip");
+		mm.addBodyPart(mp3);
+		message.setSubject("test");
+		message.setContent(mm);
+		message.saveChanges();
+		
+		Mail mail = new MockMail();
+		mail.setMessage(message);
+
+		mailet.service(mail);
+
+		ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
+		mail.getMessage().writeTo(rawMessage,
+				new String[] { "Bcc", "Content-Length", "Message-ID" });
+		String res = rawMessage.toString();
+		
+		System.out.println(res);
+		
+		Collection c = (Collection) mail.getAttribute(StripAttachment.SAVED_ATTACHMENTS_ATTRIBUTE_KEY);
+		assertNotNull(c);
+		
+		assertEquals(1,c.size());
+
+		String name = (String) c.iterator().next();
+
+		File f = new File("c:/"+name);
+		InputStream is = new FileInputStream(f);
+		String savedFile = toString(is);
+		is.close();
+		assertEquals(body,savedFile);
+		
+		f.delete();
+		
+	}
+	
+	public String toString( final InputStream is ) throws IOException {
+		final ByteArrayOutputStream sw = new ByteArrayOutputStream();
+    final byte[] buffer = new byte[1024];
+    int n = 0;
+    while (-1 != (n = is.read(buffer))) {
+        sw.write( buffer, 0, n );
+    }
+    return sw.toString();
+	}
+
+	public void testSimpleAttachment2() throws MessagingException, IOException {
+		Mailet mailet = new StripAttachment();
+
+		MockMailetConfig mci = new MockMailetConfig("Test",new MockMailContext());
+		mci.setProperty("directory","c:/");
+		mci.setProperty("remove","all");
+		mci.setProperty("notpattern","^(winmail\\.dat$)");
+		mailet.init(mci);
+
+		MimeMessage message = new MimeMessage(Session
+				.getDefaultInstance(new Properties()));
+		
+		MimeMultipart mm = new MimeMultipart();
+		MimeBodyPart mp = new MimeBodyPart();
+		mp.setText("simple text");
+		mm.addBodyPart(mp);
+		String body = "ùàòòùàòùàòùàòùàòù";
+		MimeBodyPart mp2 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body).getBytes()));
+		mp2.setDisposition("attachment");
+		mp2.setFileName("temp.tmp");
+		mm.addBodyPart(mp2);
+		String body2 = "dglkjhdfòlgkj";
+		MimeBodyPart mp3 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body2).getBytes()));
+		mp3.setDisposition("attachment");
+		mp3.setFileName("winmail.dat");
+		mm.addBodyPart(mp3);
+		message.setSubject("test");
+		message.setContent(mm);
+		message.saveChanges();
+		
+		Mail mail = new MockMail();
+		mail.setMessage(message);
+
+		mailet.service(mail);
+
+		ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
+		mail.getMessage().writeTo(rawMessage,
+				new String[] { "Bcc", "Content-Length", "Message-ID" });
+		String res = rawMessage.toString();
+		
+		System.out.println(res);
+		
+		Collection c = (Collection) mail.getAttribute(StripAttachment.SAVED_ATTACHMENTS_ATTRIBUTE_KEY);
+		assertNotNull(c);
+		
+		assertEquals(1,c.size());
+
+		String name = (String) c.iterator().next();
+
+		File f = new File("c:/"+name);
+		InputStream is = new FileInputStream(f);
+		String savedFile = IOUtil.toString(is);
+		is.close();
+		assertEquals(body,savedFile);
+		
+		f.delete();
+		
+	}
+
+	public void testSimpleAttachment3() throws MessagingException, IOException {
+		Mailet mailet = initMailet();
+		
+		//System.setProperty("mail.mime.decodefilename", "true");
+
+		MimeMessage message = new MimeMessage(Session
+				.getDefaultInstance(new Properties()));
+		
+		MimeMultipart mm = new MimeMultipart();
+		MimeBodyPart mp = new MimeBodyPart();
+		mp.setText("simple text");
+		mm.addBodyPart(mp);
+		String body = "ùàòòùàòùàòùàòùàòù";
+		MimeBodyPart mp2 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body).getBytes()));
+		mp2.setDisposition("attachment");
+		mp2.setFileName("=?iso-8859-15?Q?=E9_++++Pubblicit=E0_=E9_vietata____Milano9052.tmp?=");
+		mm.addBodyPart(mp2);
+		String body2 = "dglkjhdfòlgkj";
+		MimeBodyPart mp3 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body2).getBytes()));
+		mp3.setDisposition("attachment");
+		mp3.setFileName("temp.zip");
+		mm.addBodyPart(mp3);
+		message.setSubject("test");
+		message.setContent(mm);
+		message.saveChanges();
+		
+		//message.writeTo(System.out);
+		//System.out.println("--------------------------\n\n\n");
+		
+		Mail mail = new MockMail();
+		mail.setMessage(message);
+
+		mailet.service(mail);
+
+		ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
+		mail.getMessage().writeTo(rawMessage,
+				new String[] { "Bcc", "Content-Length", "Message-ID" });
+		String res = rawMessage.toString();
+		
+		System.out.println(res);
+		
+		Collection c = (Collection) mail.getAttribute(StripAttachment.SAVED_ATTACHMENTS_ATTRIBUTE_KEY);
+		assertNotNull(c);
+		
+		assertEquals(1,c.size());
+
+		String name = (String) c.iterator().next();
+		//System.out.println("--------------------------\n\n\n");
+		//System.out.println(name);
+		
+		assertTrue(name.startsWith("e_Pubblicita_e_vietata_Milano9052"));
+
+		File f = new File("c:/"+name);
+		InputStream is = new FileInputStream(f);
+		String savedFile = IOUtil.toString(is);
+		is.close();
+		assertEquals(body,savedFile);
+		
+		f.delete();
+		
+	}
+	
+	public void testToAndFromAttributes() throws MessagingException, IOException {
+		Mailet strip = new StripAttachment();
+		MockMailetConfig mci = new MockMailetConfig("Test",new MockMailContext());
+		mci.setProperty("attribute","my.attribute");
+		mci.setProperty("remove","all");
+		mci.setProperty("notpattern",".*\\.tmp.*");
+		strip.init(mci);
+
+		Mailet recover = new RecoverAttachment();
+		MockMailetConfig mci2 = new MockMailetConfig("Test",new MockMailContext());
+		mci2.setProperty("attribute","my.attribute");
+		recover.init(mci2);
+		
+		Mailet onlyText = new OnlyText();
+		onlyText.init(new MockMailetConfig("Test", new MockMailContext()));
+		
+		MimeMessage message = new MimeMessage(Session
+				.getDefaultInstance(new Properties()));
+		
+		MimeMultipart mm = new MimeMultipart();
+		MimeBodyPart mp = new MimeBodyPart();
+		mp.setText("simple text");
+		mm.addBodyPart(mp);
+		String body = "\u0023\u00A4\u00E3\u00E0\u00E9";
+		MimeBodyPart mp2 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body).getBytes()));
+		mp2.setDisposition("attachment");
+		mp2.setFileName("=?iso-8859-15?Q?=E9_++++Pubblicit=E0_=E9_vietata____Milano9052.tmp?=");
+		mm.addBodyPart(mp2);
+		String body2 = "dglkjhdfòlgkj";
+		MimeBodyPart mp3 = new MimeBodyPart(new ByteArrayInputStream(("Content-Transfer-Encoding: 8bit\r\n\r\n"+body2).getBytes()));
+		mp3.setDisposition("attachment");
+		mp3.setFileName("temp.zip");
+		mm.addBodyPart(mp3);
+		message.setSubject("test");
+		message.setContent(mm);
+		message.saveChanges();
+		Mail mail = new MockMail();
+		mail.setMessage(message);
+
+		assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
+		assertEquals(3, ((MimeMultipart) mail.getMessage().getContent()).getCount());
+		
+		strip.service(mail);
+
+		assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
+		assertEquals(1, ((MimeMultipart) mail.getMessage().getContent()).getCount());
+
+		onlyText.service(mail);
+
+		assertFalse(mail.getMessage().getContent() instanceof MimeMultipart);
+		
+		// prova per caricare il mime message da input  stream che altrimenti javamail si comporta differentemente.
+		String mimeSource = "Message-ID: <26...@bagovista>\r\nSubject: test\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=us-ascii\r\nContent-Transfer-Encoding: 7bit\r\n\r\nsimple text";
+		
+		MimeMessage mmNew = new MimeMessage(Session
+				.getDefaultInstance(new Properties()), new ByteArrayInputStream(mimeSource.getBytes()));
+		
+		mmNew.writeTo(System.out);
+
+		recover.service(mail);
+
+		assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
+		assertEquals(2, ((MimeMultipart) mail.getMessage().getContent()).getCount());
+		
+		assertEquals(body2, (((MimeMultipart) mail.getMessage().getContent()).getBodyPart(1).getContent()));
+		
+	}
+	
+
+	private Mailet initMailet() throws MessagingException {
+		Mailet mailet = new StripAttachment();
+
+		MockMailetConfig mci = new MockMailetConfig("Test",new MockMailContext());
+		mci.setProperty("directory","c:/");
+		mci.setProperty("remove","all");
+		mci.setProperty("pattern",".*\\.tmp");
+		mci.setProperty("decodeFilename", "true");
+		mci.setProperty("replaceFilenamePattern",
+				"/[\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5]/A//,"+
+				"/[\u00C6]/AE//,"+
+				"/[\u00C8\u00C9\u00CA\u00CB]/E//,"+
+				"/[\u00CC\u00CD\u00CE\u00CF]/I//,"+
+				"/[\u00D2\u00D3\u00D4\u00D5\u00D6]/O//,"+
+				"/[\u00D7]/x//,"+
+				"/[\u00D9\u00DA\u00DB\u00DC]/U//,"+
+				"/[\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5]/a//,"+
+				"/[\u00E6]/ae//,"+
+				"/[\u00E8\u00E9\u00EA\u00EB]/e//,"+
+				"/[\u00EC\u00ED\u00EE\u00EF]/i//,"+
+				"/[\u00F2\u00F3\u00F4\u00F5\u00F6]/o//,"+
+				"/[\u00F9\u00FA\u00FB\u00FC]/u//,"+
+				"/[^A-Za-z0-9._-]+/_//");
+
+		mailet.init(mci);
+		return mailet;
+	}
+
+}

Propchange: james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mailet/standard/trunk/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



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