james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [2/7] james-project git commit: JAMES-2137 Provide a method for searching in attachments and associated capability
Date Fri, 08 Sep 2017 20:14:50 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/d76f8fc4/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
index efb6b80..2249dae 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
@@ -26,12 +26,14 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.Locale;
 import java.util.TimeZone;
 
 import javax.mail.Flags;
 
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.SearchQuery.AddressType;
 import org.apache.james.mailbox.model.SearchQuery.DateResolution;
@@ -61,6 +63,8 @@ public class SearchUtilsTest {
     MessageBuilder builder;
 
     Collection<MessageUid> recent;
+
+    private MessageSearches messageSearches;
     
     private Calendar getGMT() {
         return Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.UK);
@@ -76,19 +80,24 @@ public class SearchUtilsTest {
         recent = new ArrayList<>();
         builder = new MessageBuilder();
         builder.uid = MessageUid.of(1009);
+        
+        Iterator<MailboxMessage> messages = null;
+        SearchQuery query = null; 
+        TextExtractor textExtractor = null;
+        messageSearches = new MessageSearches(messages, query, textExtractor);
     }
     
     @Test
     public void testMatchSizeLessThan() throws Exception {
         builder.size = SIZE;
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeLessThan(SIZE - 1), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeLessThan(SIZE - 1), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeLessThan(SIZE), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeLessThan(SIZE), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.sizeLessThan(SIZE + 1), row,
+        assertTrue(messageSearches.isMatch(SearchQuery.sizeLessThan(SIZE + 1), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(
+        assertTrue(messageSearches.isMatch(
                 SearchQuery.sizeLessThan(Integer.MAX_VALUE), row, recent));
     }
 
@@ -96,13 +105,13 @@ public class SearchUtilsTest {
     public void testMatchSizeMoreThan() throws Exception {
         builder.size = SIZE;
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.sizeGreaterThan(SIZE - 1), row,
+        assertTrue(messageSearches.isMatch(SearchQuery.sizeGreaterThan(SIZE - 1), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeGreaterThan(SIZE), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeGreaterThan(SIZE), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeGreaterThan(SIZE + 1),
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeGreaterThan(SIZE + 1),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .sizeGreaterThan(Integer.MAX_VALUE), row, recent));
     }
 
@@ -110,12 +119,12 @@ public class SearchUtilsTest {
     public void testMatchSizeEquals() throws Exception {
         builder.size = SIZE;
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeEquals(SIZE - 1), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeEquals(SIZE - 1), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.sizeEquals(SIZE), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeEquals(SIZE + 1), row,
+        assertTrue(messageSearches.isMatch(SearchQuery.sizeEquals(SIZE), row, recent));
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeEquals(SIZE + 1), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.sizeEquals(Integer.MAX_VALUE),
+        assertFalse(messageSearches.isMatch(SearchQuery.sizeEquals(Integer.MAX_VALUE),
                 row, recent));
     }
 
@@ -123,15 +132,15 @@ public class SearchUtilsTest {
     public void testMatchInternalDateEquals() throws Exception {
         builder.internalDate = SUN_SEP_9TH_2001;
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2000), DateResolution.Day),
+        assertFalse(messageSearches.isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2000), DateResolution.Day),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.internalDateOn(getDate(8, 9, 2001), DateResolution.Day),
+        assertFalse(messageSearches.isMatch(SearchQuery.internalDateOn(getDate(8, 9, 2001), DateResolution.Day),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2001), DateResolution.Day),
+        assertTrue(messageSearches.isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2001), DateResolution.Day),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.internalDateOn(getDate(10, 9, 2001), DateResolution.Day),
+        assertFalse(messageSearches.isMatch(SearchQuery.internalDateOn(getDate(10, 9, 2001), DateResolution.Day),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2002), DateResolution.Day),
+        assertFalse(messageSearches.isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2002), DateResolution.Day),
                 row, recent));
     }
 
@@ -140,15 +149,15 @@ public class SearchUtilsTest {
     public void testMatchInternalDateBefore() throws Exception {
         builder.internalDate = SUN_SEP_9TH_2001;
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.internalDateBefore(getDate(9, 9, 2000), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.internalDateBefore(getDate(8, 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.internalDateBefore(getDate(9, 9, 2001), DateResolution.Day), row, recent));
-        assertTrue(new MessageSearches().isMatch(
+        assertTrue(messageSearches.isMatch(
                 SearchQuery.internalDateBefore(getDate(10, 9, 2001), DateResolution.Day), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.internalDateBefore(getDate(9, 9, 2002), DateResolution.Day),
+        assertTrue(messageSearches.isMatch(SearchQuery.internalDateBefore(getDate(9, 9, 2002), DateResolution.Day),
                 row, recent));
     }
 
@@ -156,15 +165,15 @@ public class SearchUtilsTest {
     public void testMatchInternalDateAfter() throws Exception {
         builder.internalDate = SUN_SEP_9TH_2001;
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2000), DateResolution.Day),
+        assertTrue(messageSearches.isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2000), DateResolution.Day),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.internalDateAfter(getDate(8, 9, 2001), DateResolution.Day),
+        assertTrue(messageSearches.isMatch(SearchQuery.internalDateAfter(getDate(8, 9, 2001), DateResolution.Day),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2001), DateResolution.Day),
+        assertFalse(messageSearches.isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2001), DateResolution.Day),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.internalDateAfter(getDate(10, 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2002), DateResolution.Day),
+        assertFalse(messageSearches.isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2002), DateResolution.Day),
                 row, recent));
     }
 
@@ -172,17 +181,17 @@ public class SearchUtilsTest {
     public void testMatchHeaderDateAfter() throws Exception {
         builder.header(DATE_FIELD, RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2000), DateResolution.Day), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(8,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(8,
                 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD,
                 getDate(10, 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2002), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter("BOGUS", getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter("BOGUS", getDate(9, 9,
                 2001), DateResolution.Day), row, recent));
     }
 
@@ -190,17 +199,17 @@ public class SearchUtilsTest {
     public void testShouldMatchCapsHeaderDateAfter() throws Exception {
         builder.header(DATE_FIELD.toUpperCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2000), DateResolution.Day), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(8,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(8,
                 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD,
                 getDate(10, 9, 2001), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2002), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter("BOGUS", getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter("BOGUS", getDate(9, 9,
                 2001), DateResolution.Day), row, recent));
     }
 
@@ -208,17 +217,17 @@ public class SearchUtilsTest {
     public void testShouldMatchLowersHeaderDateAfter() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2000), DateResolution.Day), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(8,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(8,
                 9, 2001),DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD,
                 getDate(10, 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
                 9, 2002), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter("BOGUS", getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter("BOGUS", getDate(9, 9,
                 2001), DateResolution.Day),row, recent));
     }
 
@@ -226,17 +235,17 @@ public class SearchUtilsTest {
     public void testMatchHeaderDateOn() throws Exception {
         builder.header(DATE_FIELD, RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2000), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(8, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(8, 9,
                 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(10,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(10,
                 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2002), DateResolution.Day), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn("BOGUS", getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn("BOGUS", getDate(9, 9,
                 2001), DateResolution.Day), row, recent));
     }
 
@@ -244,17 +253,17 @@ public class SearchUtilsTest {
     public void testShouldMatchCapsHeaderDateOn() throws Exception {
         builder.header(DATE_FIELD.toUpperCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2000), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(8, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(8, 9,
                 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(10,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(10,
                 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2002), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn("BOGUS", getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn("BOGUS", getDate(9, 9,
                 2001), DateResolution.Day),row, recent));
     }
 
@@ -262,17 +271,17 @@ public class SearchUtilsTest {
     public void testShouldMatchLowersHeaderDateOn() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2000), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(8, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(8, 9,
                 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(10,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(10,
                 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
                 2002), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn("BOGUS", getDate(9, 9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn("BOGUS", getDate(9, 9,
                 2001), DateResolution.Day),row, recent));
     }
 
@@ -280,17 +289,17 @@ public class SearchUtilsTest {
     public void testMatchHeaderDateBefore() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(9, 9, 2000), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(8, 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(9, 9, 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(10, 9, 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(9,
                 9, 2002), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore("BOGUS", getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore("BOGUS", getDate(9,
                 9, 2001), DateResolution.Day),row, recent));
     }
 
@@ -298,17 +307,17 @@ public class SearchUtilsTest {
     public void testShouldMatchCapsHeaderDateBefore() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(9, 9, 2000), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(8, 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(9, 9, 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(10, 9, 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(9,
                 9, 2002), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore("BOGUS", getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore("BOGUS", getDate(9,
                 9, 2001), DateResolution.Day),row, recent));
     }
 
@@ -316,17 +325,17 @@ public class SearchUtilsTest {
     public void testShouldMatchLowersHeaderDateBefore() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(9, 9, 2000), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(8, 9, 2001), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(9, 9, 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
                 getDate(10, 9, 2001), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(9,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(9,
                 9, 2002), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore("BOGUS", getDate(9,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore("BOGUS", getDate(9,
                 9, 2001), DateResolution.Day),row, recent));
     }
 
@@ -334,15 +343,15 @@ public class SearchUtilsTest {
     public void testMatchHeaderContainsCaps() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT.toUpperCase(Locale.US));
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 CUSTARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 RHUBARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 CUSTARD), row, recent));
     }
 
@@ -350,15 +359,15 @@ public class SearchUtilsTest {
     public void testMatchHeaderContainsLowers() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT.toUpperCase(Locale.US));
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 CUSTARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 RHUBARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 CUSTARD), row, recent));
     }
 
@@ -366,15 +375,15 @@ public class SearchUtilsTest {
     public void testMatchHeaderContains() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT.toUpperCase(Locale.US));
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 CUSTARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 RHUBARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 CUSTARD), row, recent));
     }
 
@@ -382,15 +391,15 @@ public class SearchUtilsTest {
     public void testShouldMatchLowerHeaderContains() throws Exception {
         builder.header(SUBJECT_FIELD.toLowerCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 CUSTARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 RHUBARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 CUSTARD), row, recent));
     }
 
@@ -398,15 +407,15 @@ public class SearchUtilsTest {
     public void testShouldMatchCapsHeaderContains() throws Exception {
         builder.header(SUBJECT_FIELD.toUpperCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 CUSTARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(DATE_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 TEXT), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 RHUBARD), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerContains(SUBJECT_FIELD,
                 CUSTARD), row, recent));
     }
 
@@ -414,9 +423,9 @@ public class SearchUtilsTest {
     public void testMatchHeaderExists() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerExists(DATE_FIELD), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerExists(DATE_FIELD), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerExists(SUBJECT_FIELD),
+        assertTrue(messageSearches.isMatch(SearchQuery.headerExists(SUBJECT_FIELD),
                 row, recent));
     }
 
@@ -424,9 +433,9 @@ public class SearchUtilsTest {
     public void testShouldMatchLowersHeaderExists() throws Exception {
         builder.header(SUBJECT_FIELD.toLowerCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerExists(DATE_FIELD), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerExists(DATE_FIELD), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerExists(SUBJECT_FIELD),
+        assertTrue(messageSearches.isMatch(SearchQuery.headerExists(SUBJECT_FIELD),
                 row, recent));
     }
 
@@ -434,9 +443,9 @@ public class SearchUtilsTest {
     public void testShouldMatchUppersHeaderExists() throws Exception {
         builder.header(SUBJECT_FIELD.toLowerCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerExists(DATE_FIELD), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerExists(DATE_FIELD), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerExists(SUBJECT_FIELD),
+        assertTrue(messageSearches.isMatch(SearchQuery.headerExists(SUBJECT_FIELD),
                 row, recent));
     }
 
@@ -444,30 +453,30 @@ public class SearchUtilsTest {
     public void testShouldMatchUidRange() throws Exception {
         builder.setKey(1, MessageUid.of(1729));
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1))), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1728), MessageUid.of(1728))), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1))), row, recent));
+        assertFalse(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1728), MessageUid.of(1728))), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1729), MessageUid.of(1729))), row,
+        assertTrue(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1729), MessageUid.of(1729))), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1730), MessageUid.of(1730))), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1730), MessageUid.of(1730))), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1728))), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1728))), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1729))), row,
+        assertTrue(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1729))), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1729), MessageUid.of(1800))), row,
+        assertTrue(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1729), MessageUid.of(1800))), row,
                 recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .uid(range(MessageUid.of(1730), MessageUid.MAX_VALUE)), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1730),
+        assertFalse(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1730),
                 MessageUid.MAX_VALUE, MessageUid.of(1), MessageUid.of(1728))), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1730), MessageUid.MAX_VALUE,
+        assertTrue(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1730), MessageUid.MAX_VALUE,
                 MessageUid.of(1), MessageUid.of(1729))), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .uid(range(MessageUid.of(1), MessageUid.of(1728), MessageUid.of(1800), MessageUid.of(1810))), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1), MessageUid.of(1729), MessageUid.of(1729))),
+        assertTrue(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1), MessageUid.of(1729), MessageUid.of(1729))),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1), MessageUid.of(1800), MessageUid.of(1800))),
+        assertFalse(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1), MessageUid.of(1800), MessageUid.of(1800))),
                 row, recent));
     }
 
@@ -475,17 +484,17 @@ public class SearchUtilsTest {
     public void testShouldMatchSeenFlagSet() throws Exception {
         builder.setFlags(true, false, false, false, false, false);
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
@@ -493,17 +502,17 @@ public class SearchUtilsTest {
     public void testShouldMatchAnsweredFlagSet() throws Exception {
         builder.setFlags(false, false, true, false, false, false);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.ANSWERED),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.ANSWERED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
@@ -511,17 +520,17 @@ public class SearchUtilsTest {
     public void testShouldMatchFlaggedFlagSet() throws Exception {
         builder.setFlags(false, true, false, false, false, false);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
@@ -529,17 +538,17 @@ public class SearchUtilsTest {
     public void testShouldMatchDraftFlagSet() throws Exception {
         builder.setFlags(false, false, false, true, false, false);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsSet(Flags.Flag.ANSWERED), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
@@ -548,17 +557,17 @@ public class SearchUtilsTest {
     public void testShouldMatchDeletedFlagSet() throws Exception {
         builder.setFlags(false, false, false, false, true, false);
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
@@ -567,17 +576,17 @@ public class SearchUtilsTest {
         builder.setFlags(false, false, false, false, false, false);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.FLAGGED),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.DELETED),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
@@ -586,17 +595,17 @@ public class SearchUtilsTest {
         builder.setFlags(false, true, true, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.FLAGGED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.DELETED), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent));
     }
 
@@ -605,17 +614,17 @@ public class SearchUtilsTest {
         builder.setFlags(true, true, false, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.FLAGGED), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery
+        assertTrue(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.DELETED), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent));
     }
 
@@ -624,17 +633,17 @@ public class SearchUtilsTest {
         builder.setFlags(true, false, true, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(
+        assertTrue(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.FLAGGED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.DELETED), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent));
     }
 
@@ -643,17 +652,17 @@ public class SearchUtilsTest {
         builder.setFlags(true, true, true, false, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.FLAGGED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.ANSWERED), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.DELETED), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent));
     }
 
@@ -662,17 +671,17 @@ public class SearchUtilsTest {
         builder.setFlags(true, true, true, true, false, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.FLAGGED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertTrue(new MessageSearches().isMatch(
+        assertTrue(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.DELETED), row, recent));
-        assertFalse(new MessageSearches().isMatch(
+        assertFalse(messageSearches.isMatch(
                 SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent));
     }
 
@@ -681,60 +690,60 @@ public class SearchUtilsTest {
         builder.setFlags(true, true, true, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid().next());
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.SEEN),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.FLAGGED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.ANSWERED), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
+        assertFalse(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.DRAFT),
                 row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .flagIsUnSet(Flags.Flag.DELETED), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.flagIsUnSet(Flags.Flag.RECENT),
+        assertTrue(messageSearches.isMatch(SearchQuery.flagIsUnSet(Flags.Flag.RECENT),
                 row, recent));
     }
 
     @Test
     public void testShouldMatchAll() throws Exception {
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.all(), row, recent));
+        assertTrue(messageSearches.isMatch(SearchQuery.all(), row, recent));
     }
 
     @Test
     public void testShouldMatchNot() throws Exception {
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.not(SearchQuery.all()), row,
+        assertFalse(messageSearches.isMatch(SearchQuery.not(SearchQuery.all()), row,
                 recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.not(SearchQuery
+        assertTrue(messageSearches.isMatch(SearchQuery.not(SearchQuery
                 .headerExists(DATE_FIELD)), row, recent));
     }
 
     @Test
     public void testShouldMatchOr() throws Exception {
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.or(SearchQuery.all(),
+        assertTrue(messageSearches.isMatch(SearchQuery.or(SearchQuery.all(),
                 SearchQuery.headerExists(DATE_FIELD)), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.or(SearchQuery
+        assertTrue(messageSearches.isMatch(SearchQuery.or(SearchQuery
                 .headerExists(DATE_FIELD), SearchQuery.all()), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .or(SearchQuery.headerExists(DATE_FIELD), SearchQuery
                         .headerExists(DATE_FIELD)), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.or(SearchQuery.all(),
+        assertTrue(messageSearches.isMatch(SearchQuery.or(SearchQuery.all(),
                 SearchQuery.all()), row, recent));
     }
 
     @Test
     public void testShouldMatchAnd() throws Exception {
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.and(SearchQuery.all(),
+        assertFalse(messageSearches.isMatch(SearchQuery.and(SearchQuery.all(),
                 SearchQuery.headerExists(DATE_FIELD)), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.and(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery.and(SearchQuery
                 .headerExists(DATE_FIELD), SearchQuery.all()), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery
+        assertFalse(messageSearches.isMatch(SearchQuery
                 .and(SearchQuery.headerExists(DATE_FIELD), SearchQuery
                         .headerExists(DATE_FIELD)), row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.and(SearchQuery.all(),
+        assertTrue(messageSearches.isMatch(SearchQuery.and(SearchQuery.all(),
                 SearchQuery.all()), row, recent));
     }
     
@@ -754,12 +763,12 @@ public class SearchUtilsTest {
     public void testMatchHeaderDateOnWithOffset() throws Exception {
         builder.header(DATE_FIELD, "Mon, 26 Mar 2007 00:00:00 +0300");
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(26, 3,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(26, 3,
                 2007), DateResolution.Day),row, recent));
         
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(25, 3,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(25, 3,
                 2007), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(27, 3,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(27, 3,
                 2007), DateResolution.Day),row, recent));
     }
     
@@ -768,12 +777,12 @@ public class SearchUtilsTest {
     public void testShouldMatchHeaderDateBeforeWithOffset() throws Exception {
         builder.header(DATE_FIELD, "Mon, 26 Mar 2007 00:00:00 +0300");
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(26, 3,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(26, 3,
                 2007), DateResolution.Day),row, recent));
         
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(27, 3,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(27, 3,
                 2007), DateResolution.Day),row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(25, 3,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(25, 3,
                 2007), DateResolution.Day),row, recent));
     }
 
@@ -781,12 +790,12 @@ public class SearchUtilsTest {
     public void testShouldMatchHeaderDateAfterWithOffset() throws Exception {
         builder.header(DATE_FIELD, "Mon, 26 Mar 2007 00:00:00 +0300");
         MailboxMessage row = builder.build();
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(26, 3,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(26, 3,
                 2007), DateResolution.Day),row, recent));
         
-        assertFalse(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(27, 3,
+        assertFalse(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(27, 3,
                 2007), DateResolution.Day),row, recent));
-        assertTrue(new MessageSearches().isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(25, 3,
+        assertTrue(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(25, 3,
                 2007), DateResolution.Day),row, recent));
     }
     
@@ -794,8 +803,8 @@ public class SearchUtilsTest {
     public void testShouldMatchAddressHeaderWithComments() throws Exception {
         builder.header("To", "<user-from (comment)@ (comment) domain.org>");
         MailboxMessage row = builder.build();
-        assertTrue(new MessageSearches().isMatch(SearchQuery.address(AddressType.To, "user-from@domain.org"), row, recent));
-        assertFalse(new MessageSearches().isMatch(SearchQuery.address(AddressType.From, "user-from@domain.org"), row, recent));
+        assertTrue(messageSearches.isMatch(SearchQuery.address(AddressType.To, "user-from@domain.org"), row, recent));
+        assertFalse(messageSearches.isMatch(SearchQuery.address(AddressType.From, "user-from@domain.org"), row, recent));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/d76f8fc4/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index fd9d173..a2686f3 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -22,12 +22,14 @@ package org.apache.james.mailbox.store.search;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
 import javax.mail.Flags;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
@@ -47,10 +49,18 @@ import org.apache.james.mailbox.model.SearchQuery.Sort.SortClause;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreMessageManager;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mime4j.dom.Message;
+import org.apache.james.mime4j.dom.MessageWriter;
+import org.apache.james.mime4j.dom.Multipart;
+import org.apache.james.mime4j.message.BodyPart;
+import org.apache.james.mime4j.message.BodyPartBuilder;
+import org.apache.james.mime4j.message.DefaultMessageWriter;
+import org.apache.james.mime4j.message.MultipartBuilder;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
 
 public abstract class AbstractMessageSearchIndexTest {
@@ -208,6 +218,7 @@ public abstract class AbstractMessageSearchIndexTest {
             otherSession,
             RECENT,
             new Flags());
+
         await();
     }
 
@@ -574,7 +585,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void flagIsUnSetShouldReturnUidOfMessageNotMarkedAsSeendWhenUsedWithFlagSeen() throws MailboxException {
+    public void flagIsUnSetShouldReturnUidOfMessageNotMarkedAsSeenWhenUsedWithFlagSeen() throws MailboxException {
         // Only message 6 is marked as read.
         SearchQuery searchQuery = new SearchQuery(SearchQuery.flagIsUnSet(Flags.Flag.SEEN));
 
@@ -1102,6 +1113,56 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
+    public void searchWithTextAttachmentShouldReturnMailsWhenAttachmentContentMatches() throws Exception {
+        Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Attachment));
+        ComposedMessageId messageWithBeautifulBananaAsTextAttachment = myFolderMessageManager.appendMessage(
+                ClassLoader.getSystemResourceAsStream("eml/emailWithTextAttachment.eml"),
+                new Date(1404252000000L),
+                session,
+                RECENT,
+                new Flags());
+        await();
+
+        SearchQuery searchQuery = new SearchQuery(SearchQuery.attachmentContains("beautiful banana"));
+
+        assertThat(messageSearchIndex.search(session, mailbox2, searchQuery))
+            .containsExactly(messageWithBeautifulBananaAsTextAttachment.getUid());
+    }
+
+    @Test
+    public void searchWithPDFAttachmentShouldReturnMailsWhenAttachmentContentMatches() throws Exception {
+        Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Attachment));
+        byte[] attachmentContent = IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/attachment.pdf"));
+        BodyPart attachment = BodyPartBuilder.create()
+                .setBody(attachmentContent, "application/pdf")
+                .setContentDisposition("attachment")
+                .build();
+        BodyPart textPart = BodyPartBuilder.create().setBody("The message has a PDF attachment.", "plain", Charsets.UTF_8).build();
+        Multipart multipart = MultipartBuilder.create("mixed")
+                .addBodyPart(attachment)
+                .addBodyPart(textPart)
+                .build();
+        Message message = Message.Builder.of()
+                .setBody(multipart)
+                .build();
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        MessageWriter writer = new DefaultMessageWriter();
+        writer.writeMessage(message, outputStream);
+        ComposedMessageId messageWithBeautifulBananaAsPDFAttachment = myFolderMessageManager.appendMessage(
+                new ByteArrayInputStream(outputStream.toByteArray()),
+                new Date(1404252000000L),
+                session,
+                RECENT,
+                new Flags());
+        await();
+
+        SearchQuery searchQuery = new SearchQuery(SearchQuery.attachmentContains("beautiful banana"));
+
+        assertThat(messageSearchIndex.search(session, mailbox2, searchQuery))
+            .containsExactly(messageWithBeautifulBananaAsPDFAttachment.getUid());
+    }
+
+    @Test
     public void sortShouldNotDiscardResultWhenSearchingFieldIsIdentical() throws Exception {
         SearchQuery searchQuery = new SearchQuery(SearchQuery.all());
         searchQuery.setSorts(ImmutableList.of(new Sort(SortClause.Arrival)));

http://git-wip-us.apache.org/repos/asf/james-project/blob/d76f8fc4/mailbox/store/src/test/resources/eml/attachment.pdf
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/resources/eml/attachment.pdf b/mailbox/store/src/test/resources/eml/attachment.pdf
new file mode 100644
index 0000000..6db56a2
Binary files /dev/null and b/mailbox/store/src/test/resources/eml/attachment.pdf differ

http://git-wip-us.apache.org/repos/asf/james-project/blob/d76f8fc4/mailbox/store/src/test/resources/eml/emailWithTextAttachment.eml
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/resources/eml/emailWithTextAttachment.eml b/mailbox/store/src/test/resources/eml/emailWithTextAttachment.eml
new file mode 100644
index 0000000..0a487ef
--- /dev/null
+++ b/mailbox/store/src/test/resources/eml/emailWithTextAttachment.eml
@@ -0,0 +1,26 @@
+To: James User <user@james.org>
+From: James Sender <sender@james.org>
+Subject: Message with text attachment
+Message-ID: <ffaa7bce-fbe3-83b5-de3f-9a7301233615@linagora.com>
+Date: Tue, 5 Sep 2017 09:54:16 +0200
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="------------D24E361990BDBA143D4D8794"
+Content-Language: en-US
+
+This is a multi-part message in MIME format.
+--------------D24E361990BDBA143D4D8794
+Content-Type: text/plain; charset=utf-8; format=flowed
+Content-Transfer-Encoding: 7bit
+
+The message has a text attachment.
+
+--------------D24E361990BDBA143D4D8794
+Content-Type: text/plain; charset=UTF-8;
+ name="attachment.txt"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment;
+ filename="attachment.txt"
+
+VGhpcyBpcyBhIGJlYXV0aWZ1bCBiYW5hbmEuCg==
+--------------D24E361990BDBA143D4D8794--


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