Modified: james/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java (original) +++ james/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java Tue Mar 16 19:47:58 2010 @@ -19,16 +19,18 @@ package org.apache.james.imap.store; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.Charset; import java.util.List; import org.apache.james.imap.mailbox.MessageResult.Header; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; - -public class PartContentBuilderMultipartAlternativeTest extends TestCase { +public class PartContentBuilderMultipartAlternativeTest { private static final String CONTENT_TYPE_PLAIN = "text/plain;charset=us-ascii"; @@ -68,27 +70,26 @@ public class PartContentBuilderMultipart PartContentBuilder builder; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { builder = new PartContentBuilder(); } - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testShouldLocatePartsOfMultipartAlterative() throws Exception { assertEquals(ALT_PLAIN_BODY, bodyContent(MULTIPART_ALTERNATIVE, 1)); assertEquals(ALT_HTML_BODY, bodyContent(MULTIPART_ALTERNATIVE, 2)); assertEquals(ALT_XHTML_BODY, bodyContent(MULTIPART_ALTERNATIVE, 3)); } + @Test public void testShouldLocateHeadersOfMultipartAlterative() throws Exception { checkContentType(CONTENT_TYPE_PLAIN, MULTIPART_ALTERNATIVE, 1); checkContentType(CONTENT_TYPE_HTML, MULTIPART_ALTERNATIVE, 2); checkContentType(CONTENT_TYPE_XHTML, MULTIPART_ALTERNATIVE, 3); } + @Test public void testShouldLocateFullContentOfMultipartAlterative() throws Exception { assertEquals(ALT_PART_PLAIN, fullContent(MULTIPART_ALTERNATIVE, 1));
Modified: james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsMultipartMixedTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsMultipartMixedTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsMultipartMixedTest.java (original) +++ james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsMultipartMixedTest.java Tue Mar 16 19:47:58 2010 @@ -19,17 +19,19 @@ package org.apache.james.imap.store; +import static org.junit.Assert.*; + import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; -import junit.framework.TestCase; - import org.apache.james.imap.api.ImapConstants; import org.apache.james.imap.mailbox.SearchQuery; import org.apache.james.imap.store.mail.model.MailboxMembership; +import org.junit.Before; +import org.junit.Test; -public class SearchUtilsMultipartMixedTest extends TestCase { +public class SearchUtilsMultipartMixedTest { private static final String SAMPLE_INNER_MAIL_BODY_ONE = "far a modern quill doth come too"; @@ -109,8 +111,8 @@ public class SearchUtilsMultipartMixedTe Collection recent; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { final MessageBuilder builder = new MessageBuilder(); builder.header(ImapConstants.RFC822_FROM, "Alex <[email protected]"); @@ -123,11 +125,9 @@ public class SearchUtilsMultipartMixedTe searches = new MessageSearches(); recent = new ArrayList(); } + - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testShouldNotFindWhatIsNotThere() throws Exception { assertFalse(searches.isMatch(SearchQuery.bodyContains("BOGUS"), row, recent)); @@ -135,6 +135,7 @@ public class SearchUtilsMultipartMixedTe recent)); } + @Test public void testBodyShouldFindTextInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery .bodyContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -144,6 +145,7 @@ public class SearchUtilsMultipartMixedTe row, recent)); } + @Test public void testBodyShouldFindTextInBodyCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery .bodyContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -167,6 +169,7 @@ public class SearchUtilsMultipartMixedTe .toUpperCase()), row, recent)); } + @Test public void testBodyShouldNotFindTextInHeaders() throws Exception { assertFalse(searches.isMatch(SearchQuery .bodyContains(SAMPLE_INNER_MAIL_FIELD), row, recent)); @@ -174,6 +177,7 @@ public class SearchUtilsMultipartMixedTe .bodyContains(SAMPLE_PART_TWO_FIELD), row, recent)); } + @Test public void testTextShouldFindTextInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery .mailContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -183,6 +187,7 @@ public class SearchUtilsMultipartMixedTe row, recent)); } + @Test public void testTextShouldFindTextInBodyCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery .mailContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -206,6 +211,7 @@ public class SearchUtilsMultipartMixedTe .toUpperCase()), row, recent)); } + @Test public void testTextShouldFindTextInHeaders() throws Exception { assertTrue(searches.isMatch(SearchQuery .mailContains(SAMPLE_INNER_MAIL_FIELD), row, recent)); Modified: james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsRFC822Test.java URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsRFC822Test.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsRFC822Test.java (original) +++ james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsRFC822Test.java Tue Mar 16 19:47:58 2010 @@ -19,17 +19,19 @@ package org.apache.james.imap.store; +import static org.junit.Assert.*; + import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; -import junit.framework.TestCase; - import org.apache.james.imap.api.ImapConstants; import org.apache.james.imap.mailbox.SearchQuery; import org.apache.james.imap.store.mail.model.MailboxMembership; +import org.junit.Before; +import org.junit.Test; -public class SearchUtilsRFC822Test extends TestCase { +public class SearchUtilsRFC822Test { private static final String FROM_ADDRESS = "Harry <[email protected]"; @@ -49,8 +51,8 @@ public class SearchUtilsRFC822Test exten Collection recent; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { recent = new ArrayList(); MessageBuilder builder = new MessageBuilder(); builder.header(ImapConstants.RFC822_FROM, "Alex <[email protected]"); @@ -62,10 +64,8 @@ public class SearchUtilsRFC822Test exten searches = new MessageSearches(); } - protected void tearDown() throws Exception { - super.tearDown(); - } + @Test public void testBodyShouldMatchPhraseInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery.bodyContains(CUSTARD), row, recent)); @@ -73,6 +73,7 @@ public class SearchUtilsRFC822Test exten .bodyContains(CUSTARD + CUSTARD), row, recent)); } + @Test public void testBodyMatchShouldBeCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery.bodyContains(RHUBARD), row, recent)); @@ -82,6 +83,7 @@ public class SearchUtilsRFC822Test exten .toLowerCase()), row, recent)); } + @Test public void testBodyShouldNotMatchPhraseOnlyInHeader() throws Exception { assertFalse(searches.isMatch(SearchQuery.bodyContains(FROM_ADDRESS), row, recent)); @@ -89,6 +91,7 @@ public class SearchUtilsRFC822Test exten row, recent)); } + @Test public void testTextShouldMatchPhraseInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery.mailContains(CUSTARD), row, recent)); @@ -96,6 +99,7 @@ public class SearchUtilsRFC822Test exten .mailContains(CUSTARD + CUSTARD), row, recent)); } + @Test public void testTextMatchShouldBeCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery.mailContains(RHUBARD), row, recent)); @@ -105,6 +109,7 @@ public class SearchUtilsRFC822Test exten .toLowerCase()), row, recent)); } + @Test public void testBodyShouldMatchPhraseOnlyInHeader() throws Exception { assertTrue(searches.isMatch(SearchQuery.mailContains(FROM_ADDRESS), row, recent)); Modified: james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsTest.java (original) +++ james/imap/trunk/store/src/test/java/org/apache/james/imap/store/SearchUtilsTest.java Tue Mar 16 19:47:58 2010 @@ -19,19 +19,21 @@ package org.apache.james.imap.store; +import static org.junit.Assert.*; + import java.util.ArrayList; import java.util.Collection; import java.util.Date; import javax.mail.Flags; -import junit.framework.TestCase; - import org.apache.james.imap.api.ImapConstants; import org.apache.james.imap.mailbox.SearchQuery; import org.apache.james.imap.store.mail.model.MailboxMembership; +import org.junit.Before; +import org.junit.Test; -public class SearchUtilsTest extends TestCase { +public class SearchUtilsTest { private static final String RHUBARD = "Rhubard"; @@ -55,18 +57,15 @@ public class SearchUtilsTest extends Tes Collection<Long> recent; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { recent = new ArrayList<Long>(); builder = new MessageBuilder(); builder.uid = 1009; searches = new MessageSearches(); } - - protected void tearDown() throws Exception { - super.tearDown(); - } - + + @Test public void testMatchSizeLessThan() throws Exception { builder.size = SIZE; MailboxMembership row = builder.build(); @@ -80,6 +79,7 @@ public class SearchUtilsTest extends Tes SearchQuery.sizeLessThan(Integer.MAX_VALUE), row, recent)); } + @Test public void testMatchSizeMoreThan() throws Exception { builder.size = SIZE; MailboxMembership row = builder.build(); @@ -93,6 +93,7 @@ public class SearchUtilsTest extends Tes .sizeGreaterThan(Integer.MAX_VALUE), row, recent)); } + @Test public void testMatchSizeEquals() throws Exception { builder.size = SIZE; MailboxMembership row = builder.build(); @@ -105,6 +106,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchInternalDateEquals() throws Exception { builder.internalDate = SUN_SEP_9TH_2001; MailboxMembership row = builder.build(); @@ -120,6 +122,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchInternalDateBefore() throws Exception { builder.internalDate = SUN_SEP_9TH_2001; MailboxMembership row = builder.build(); @@ -135,6 +138,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchInternalDateAfter() throws Exception { builder.internalDate = SUN_SEP_9TH_2001; MailboxMembership row = builder.build(); @@ -150,6 +154,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchHeaderDateAfter() throws Exception { builder.header(DATE_FIELD, RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -167,6 +172,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchCapsHeaderDateAfter() throws Exception { builder.header(DATE_FIELD.toUpperCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -184,6 +190,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchLowersHeaderDateAfter() throws Exception { builder.header(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -201,6 +208,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testMatchHeaderDateOn() throws Exception { builder.header(DATE_FIELD, RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -218,6 +226,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchCapsHeaderDateOn() throws Exception { builder.header(DATE_FIELD.toUpperCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -235,6 +244,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchLowersHeaderDateOn() throws Exception { builder.header(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -252,6 +262,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testMatchHeaderDateBefore() throws Exception { builder.header(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -269,6 +280,7 @@ public class SearchUtilsTest extends Tes 9, 2001), row, recent)); } + @Test public void testShouldMatchCapsHeaderDateBefore() throws Exception { builder.header(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -286,6 +298,7 @@ public class SearchUtilsTest extends Tes 9, 2001), row, recent)); } + @Test public void testShouldMatchLowersHeaderDateBefore() throws Exception { builder.header(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); MailboxMembership row = builder.build(); @@ -303,6 +316,7 @@ public class SearchUtilsTest extends Tes 9, 2001), row, recent)); } + @Test public void testMatchHeaderContainsCaps() throws Exception { builder.header(SUBJECT_FIELD, TEXT.toUpperCase()); MailboxMembership row = builder.build(); @@ -318,6 +332,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testMatchHeaderContainsLowers() throws Exception { builder.header(SUBJECT_FIELD, TEXT.toUpperCase()); MailboxMembership row = builder.build(); @@ -333,6 +348,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testMatchHeaderContains() throws Exception { builder.header(SUBJECT_FIELD, TEXT.toUpperCase()); MailboxMembership row = builder.build(); @@ -348,6 +364,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testShouldMatchLowerHeaderContains() throws Exception { builder.header(SUBJECT_FIELD.toLowerCase(), TEXT); MailboxMembership row = builder.build(); @@ -363,6 +380,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testShouldMatchCapsHeaderContains() throws Exception { builder.header(SUBJECT_FIELD.toUpperCase(), TEXT); MailboxMembership row = builder.build(); @@ -378,6 +396,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testMatchHeaderExists() throws Exception { builder.header(SUBJECT_FIELD, TEXT); MailboxMembership row = builder.build(); @@ -387,6 +406,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchLowersHeaderExists() throws Exception { builder.header(SUBJECT_FIELD.toLowerCase(), TEXT); MailboxMembership row = builder.build(); @@ -396,6 +416,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchUppersHeaderExists() throws Exception { builder.header(SUBJECT_FIELD.toLowerCase(), TEXT); MailboxMembership row = builder.build(); @@ -405,6 +426,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchUidRange() throws Exception { builder.setKey(1, 1729); MailboxMembership row = builder.build(); @@ -435,6 +457,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchSeenFlagSet() throws Exception { builder.setFlags(true, false, false, false, false, false); MailboxMembership row = builder.build(); @@ -452,6 +475,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchAnsweredFlagSet() throws Exception { builder.setFlags(false, false, true, false, false, false); MailboxMembership row = builder.build(); @@ -469,6 +493,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchFlaggedFlagSet() throws Exception { builder.setFlags(false, true, false, false, false, false); MailboxMembership row = builder.build(); @@ -486,6 +511,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchDraftFlagSet() throws Exception { builder.setFlags(false, false, false, true, false, false); MailboxMembership row = builder.build(); @@ -503,6 +529,8 @@ public class SearchUtilsTest extends Tes row, recent)); } + + @Test public void testShouldMatchDeletedFlagSet() throws Exception { builder.setFlags(false, false, false, false, true, false); MailboxMembership row = builder.build(); @@ -520,6 +548,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchSeenRecentSet() throws Exception { builder.setFlags(false, false, false, false, false, false); MailboxMembership row = builder.build(); @@ -538,6 +567,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchSeenFlagUnSet() throws Exception { builder.setFlags(false, true, true, true, true, true); MailboxMembership row = builder.build(); @@ -556,6 +586,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchAnsweredFlagUnSet() throws Exception { builder.setFlags(true, true, false, true, true, true); MailboxMembership row = builder.build(); @@ -574,6 +605,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchFlaggedFlagUnSet() throws Exception { builder.setFlags(true, false, true, true, true, true); MailboxMembership row = builder.build(); @@ -592,6 +624,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchDraftFlagUnSet() throws Exception { builder.setFlags(true, true, true, false, true, true); MailboxMembership row = builder.build(); @@ -610,6 +643,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchDeletedFlagUnSet() throws Exception { builder.setFlags(true, true, true, true, false, true); MailboxMembership row = builder.build(); @@ -628,6 +662,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchSeenRecentUnSet() throws Exception { builder.setFlags(true, true, true, true, true, true); MailboxMembership row = builder.build(); @@ -646,11 +681,13 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchAll() throws Exception { MailboxMembership row = builder.build(); assertTrue(searches.isMatch(SearchQuery.all(), row, recent)); } + @Test public void testShouldMatchNot() throws Exception { MailboxMembership row = builder.build(); assertFalse(searches.isMatch(SearchQuery.not(SearchQuery.all()), row, @@ -659,6 +696,7 @@ public class SearchUtilsTest extends Tes .headerExists(DATE_FIELD)), row, recent)); } + @Test public void testShouldMatchOr() throws Exception { MailboxMembership row = builder.build(); assertTrue(searches.isMatch(SearchQuery.or(SearchQuery.all(), @@ -672,6 +710,7 @@ public class SearchUtilsTest extends Tes SearchQuery.all()), row, recent)); } + @Test public void testShouldMatchAnd() throws Exception { MailboxMembership row = builder.build(); assertFalse(searches.isMatch(SearchQuery.and(SearchQuery.all(), Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageRowUtilsTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageRowUtilsTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageRowUtilsTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageRowUtilsTest.java Tue Mar 16 19:47:58 2010 @@ -19,20 +19,15 @@ package org.apache.james.mailboxmanager.torque; -import junit.framework.TestCase; +import static org.junit.Assert.*; import org.apache.james.mailboxmanager.torque.om.MessageRow; +import org.junit.Test; -public class MessageRowUtilsTest extends TestCase { +public class MessageRowUtilsTest { - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } + @Test public void testShouldReturnPositiveWhenFirstGreaterThanSecond() throws Exception { MessageRow one = new MessageRow(); @@ -42,6 +37,7 @@ public class MessageRowUtilsTest extends assertTrue(MessageRowUtils.getUidComparator().compare(one, two) > 0); } + @Test public void testShouldReturnNegativeWhenFirstLessThanSecond() throws Exception { MessageRow one = new MessageRow(); @@ -51,6 +47,7 @@ public class MessageRowUtilsTest extends assertTrue(MessageRowUtils.getUidComparator().compare(one, two) < 0); } + @Test public void testShouldReturnZeroWhenFirstEqualsSecond() throws Exception { MessageRow one = new MessageRow(); one.setUid(90); Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsCountUnnormalLinesTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsCountUnnormalLinesTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsCountUnnormalLinesTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsCountUnnormalLinesTest.java Tue Mar 16 19:47:58 2010 @@ -19,32 +19,32 @@ package org.apache.james.mailboxmanager.torque; -import junit.framework.TestCase; +import static org.junit.Assert.*; -public class MessageUtilsCountUnnormalLinesTest extends TestCase { +import org.junit.Test; - protected void setUp() throws Exception { - } - - protected void tearDown() throws Exception { - } +public class MessageUtilsCountUnnormalLinesTest { + @Test public void testEmpty() throws Exception { assertEquals("Check processing of empty array", 0, MessageUtils .countUnnormalLines("".getBytes())); } + @Test public void testNormal() throws Exception { assertEquals("Check processing of normal data", 0, MessageUtils .countUnnormalLines("One\r\nTwo\r\nThree\r\n".getBytes())); } + @Test public void testMissing() throws Exception { assertEquals("Check processing simple data containing unnormal lines", 2, MessageUtils.countUnnormalLines("One\rTwo\nThree\r\n" .getBytes())); } + @Test public void testBoundaries() throws Exception { assertEquals("CR at end", 1, MessageUtils .countUnnormalLines("One\r\nTwo\r\nThree\r".getBytes())); @@ -56,6 +56,7 @@ public class MessageUtilsCountUnnormalLi .countUnnormalLines("\nOne\r\nTwo\r\nThree".getBytes())); } + @Test public void testSwitchOrder() throws Exception { assertEquals("Check processing simple data containing unnormal lines", 8, MessageUtils Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsNormalisedWriteToTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsNormalisedWriteToTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsNormalisedWriteToTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/MessageUtilsNormalisedWriteToTest.java Tue Mar 16 19:47:58 2010 @@ -19,26 +19,22 @@ package org.apache.james.mailboxmanager.torque; -import junit.framework.TestCase; +import static org.junit.Assert.*; -public class MessageUtilsNormalisedWriteToTest extends TestCase { +import org.junit.Test; - StringBuffer buffer; - - protected void setUp() throws Exception { - super.setUp(); - buffer = new StringBuffer(); - } +public class MessageUtilsNormalisedWriteToTest { - protected void tearDown() throws Exception { - super.tearDown(); - } + StringBuffer buffer; + + @Test public void testEmpty() throws Exception { MessageUtils.normalisedWriteTo("".getBytes(), buffer); assertEquals("Check processing of empty array", "", buffer.toString()); } + @Test public void testNormal() throws Exception { MessageUtils.normalisedWriteTo("One\r\nTwo\r\nThree\r\n".getBytes(), buffer); @@ -46,6 +42,7 @@ public class MessageUtilsNormalisedWrite "One\r\nTwo\r\nThree\r\n", buffer.toString()); } + @Test public void testMissing() throws Exception { MessageUtils .normalisedWriteTo("One\rTwo\nThree\r\n".getBytes(), buffer); @@ -53,18 +50,21 @@ public class MessageUtilsNormalisedWrite "One\r\nTwo\r\nThree\r\n", buffer.toString()); } + @Test public void testCRAtEnd() throws Exception { MessageUtils.normalisedWriteTo("One\r\nTwo\r\nThree\r".getBytes(), buffer); assertEquals("CR at end", "One\r\nTwo\r\nThree\r\n", buffer.toString()); } + @Test public void testLFAtEnd() throws Exception { MessageUtils.normalisedWriteTo("One\r\nTwo\r\nThree\n".getBytes(), buffer); assertEquals("LF at end", "One\r\nTwo\r\nThree\r\n", buffer.toString()); } + @Test public void testCRAtStart() throws Exception { MessageUtils.normalisedWriteTo("\rOne\r\nTwo\r\nThree\r".getBytes(), buffer); @@ -72,6 +72,7 @@ public class MessageUtilsNormalisedWrite .toString()); } + @Test public void testLFAtStart() throws Exception { MessageUtils.normalisedWriteTo("\nOne\r\nTwo\r\nThree".getBytes(), buffer); @@ -79,6 +80,7 @@ public class MessageUtilsNormalisedWrite .toString()); } + @Test public void testSwitchOrder() throws Exception { MessageUtils.normalisedWriteTo( "\n\rOne\n\rTwo\n\rThree\n\r".getBytes(), buffer); Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java Tue Mar 16 19:47:58 2010 @@ -19,19 +19,20 @@ package org.apache.james.mailboxmanager.torque; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.Charset; import java.util.List; -import junit.framework.TestCase; - import org.apache.james.imap.mailbox.MessageResult.Header; import org.apache.james.imap.store.PartContentBuilder; import org.apache.james.imap.store.StringBuilderChannel; import org.apache.james.imap.store.PartContentBuilder.PartNotFoundException; +import org.junit.Before; -public class PartContentBuilderComplexMultipartTest extends TestCase { +public class PartContentBuilderComplexMultipartTest { private static final String PREAMBLE = "This is the preamble"; @@ -109,15 +110,12 @@ public class PartContentBuilderComplexMu PartContentBuilder builder; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { builder = new PartContentBuilder(); } - - protected void tearDown() throws Exception { - super.tearDown(); - } - + + @Before public void testShouldNotFoundSubPartOfNonMultiPartTopLevel() throws Exception { int[] path = { 1, 1 }; @@ -127,6 +125,7 @@ public class PartContentBuilderComplexMu } } + @Before public void testShouldNotFoundSubPartOfNonMultiInnerPart() throws Exception { int[] path = { 2, 2, 1 }; for (int i = 1; i < 10; i++) { @@ -135,32 +134,38 @@ public class PartContentBuilderComplexMu } } + @Before public void testShouldLocateOuterHtml() throws Exception { int[] path = { 1 }; check(FULL_OUTER_HTML, OUTER_HTML_BODY, CONTENT_TYPE_HTML, path); } + @Before public void testShouldLocateOuterMail() throws Exception { int[] path = { 2 }; check(FULL_INNER_MAIL, INNER_MAIL, CONTENT_TYPE_RFC822, path); } + @Before public void testShouldLocateOuterPlain() throws Exception { int[] path = { 3 }; check(FULL_OUTER_PLAIN, OUTER_PLAIN_BODY, CONTENT_TYPE_PLAIN, path); } + @Before public void testShouldLocateInnerHtml() throws Exception { int[] path = { 2, 2 }; check(FULL_INNER_HTML, INNER_HTML_BODY, CONTENT_TYPE_HTML, path); } + @Before public void testShouldLocateInnerMail() throws Exception { int[] path = { 2, 3 }; check(FULL_INNERMOST_EMAIL, RFC822_PLAIN_MAIL, CONTENT_TYPE_RFC822, path); } + @Before public void testShouldLocateInnerPlain() throws Exception { int[] path = { 2, 1 }; check(FULL_INNER_TXT, INNER_PLAIN_BODY, CONTENT_TYPE_PLAIN, path); Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java Tue Mar 16 19:47:58 2010 @@ -19,6 +19,8 @@ package org.apache.james.mailboxmanager.torque; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.Charset; @@ -27,10 +29,12 @@ import java.util.List; import org.apache.james.imap.mailbox.MessageResult.Header; import org.apache.james.imap.store.PartContentBuilder; import org.apache.james.imap.store.StringBuilderChannel; +import org.junit.Before; +import org.junit.Test; import junit.framework.TestCase; -public class PartContentBuilderMultipartAlternativeTest extends TestCase { +public class PartContentBuilderMultipartAlternativeTest { private static final String CONTENT_TYPE_PLAIN = "text/plain;charset=us-ascii"; @@ -70,27 +74,27 @@ public class PartContentBuilderMultipart PartContentBuilder builder; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { builder = new PartContentBuilder(); } - protected void tearDown() throws Exception { - super.tearDown(); - } - + + @Test public void testShouldLocatePartsOfMultipartAlterative() throws Exception { assertEquals(ALT_PLAIN_BODY, bodyContent(MULTIPART_ALTERNATIVE, 1)); assertEquals(ALT_HTML_BODY, bodyContent(MULTIPART_ALTERNATIVE, 2)); assertEquals(ALT_XHTML_BODY, bodyContent(MULTIPART_ALTERNATIVE, 3)); } + @Test public void testShouldLocateHeadersOfMultipartAlterative() throws Exception { checkContentType(CONTENT_TYPE_PLAIN, MULTIPART_ALTERNATIVE, 1); checkContentType(CONTENT_TYPE_HTML, MULTIPART_ALTERNATIVE, 2); checkContentType(CONTENT_TYPE_XHTML, MULTIPART_ALTERNATIVE, 3); } + @Test public void testShouldLocateFullContentOfMultipartAlterative() throws Exception { assertEquals(ALT_PART_PLAIN, fullContent(MULTIPART_ALTERNATIVE, 1)); Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsMultipartMixedTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsMultipartMixedTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsMultipartMixedTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsMultipartMixedTest.java Tue Mar 16 19:47:58 2010 @@ -19,6 +19,8 @@ package org.apache.james.mailboxmanager.torque; +import static org.junit.Assert.*; + import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; @@ -30,8 +32,10 @@ import org.apache.james.imap.mailbox.Sea import org.apache.james.mailboxmanager.torque.om.MessageBody; import org.apache.james.mailboxmanager.torque.om.MessageHeader; import org.apache.james.mailboxmanager.torque.om.MessageRow; +import org.junit.Before; +import org.junit.Test; -public class SearchUtilsMultipartMixedTest extends TestCase { +public class SearchUtilsMultipartMixedTest { private static final String SAMPLE_INNER_MAIL_BODY_ONE = "far a modern quill doth come too"; @@ -111,8 +115,8 @@ public class SearchUtilsMultipartMixedTe Collection recent; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { row = new MessageRow(); row.addMessageHeader(new MessageHeader(ImapConstants.RFC822_FROM, "Alex <[email protected]")); @@ -130,10 +134,7 @@ public class SearchUtilsMultipartMixedTe recent = new ArrayList(); } - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testShouldNotFindWhatIsNotThere() throws Exception { assertFalse(searches.isMatch(SearchQuery.bodyContains("BOGUS"), row, recent)); @@ -141,6 +142,7 @@ public class SearchUtilsMultipartMixedTe recent)); } + @Test public void testBodyShouldFindTextInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery .bodyContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -150,6 +152,7 @@ public class SearchUtilsMultipartMixedTe row, recent)); } + @Test public void testBodyShouldFindTextInBodyCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery .bodyContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -173,6 +176,7 @@ public class SearchUtilsMultipartMixedTe .toUpperCase()), row, recent)); } + @Test public void testBodyShouldNotFindTextInHeaders() throws Exception { assertFalse(searches.isMatch(SearchQuery .bodyContains(SAMPLE_INNER_MAIL_FIELD), row, recent)); @@ -180,6 +184,7 @@ public class SearchUtilsMultipartMixedTe .bodyContains(SAMPLE_PART_TWO_FIELD), row, recent)); } + @Test public void testTextShouldFindTextInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery .mailContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -189,6 +194,7 @@ public class SearchUtilsMultipartMixedTe row, recent)); } + @Test public void testTextShouldFindTextInBodyCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery .mailContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)); @@ -212,6 +218,7 @@ public class SearchUtilsMultipartMixedTe .toUpperCase()), row, recent)); } + @Test public void testTextShouldFindTextInHeaders() throws Exception { assertTrue(searches.isMatch(SearchQuery .mailContains(SAMPLE_INNER_MAIL_FIELD), row, recent)); Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsRFC822Test.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsRFC822Test.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsRFC822Test.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsRFC822Test.java Tue Mar 16 19:47:58 2010 @@ -19,6 +19,8 @@ package org.apache.james.mailboxmanager.torque; +import static org.junit.Assert.*; + import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; @@ -30,8 +32,10 @@ import org.apache.james.imap.mailbox.Sea import org.apache.james.mailboxmanager.torque.om.MessageBody; import org.apache.james.mailboxmanager.torque.om.MessageHeader; import org.apache.james.mailboxmanager.torque.om.MessageRow; +import org.junit.Before; +import org.junit.Test; -public class SearchUtilsRFC822Test extends TestCase { +public class SearchUtilsRFC822Test { private static final String FROM_ADDRESS = "Harry <[email protected]"; @@ -51,8 +55,8 @@ public class SearchUtilsRFC822Test exten Collection recent; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { recent = new ArrayList(); row = new MessageRow(); row.addMessageHeader(new MessageHeader(ImapConstants.RFC822_FROM, @@ -68,10 +72,9 @@ public class SearchUtilsRFC822Test exten searches = new MessageSearches(); } - protected void tearDown() throws Exception { - super.tearDown(); - } + + @Test public void testBodyShouldMatchPhraseInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery.bodyContains(CUSTARD), row, recent)); @@ -79,6 +82,7 @@ public class SearchUtilsRFC822Test exten .bodyContains(CUSTARD + CUSTARD), row, recent)); } + @Test public void testBodyMatchShouldBeCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery.bodyContains(RHUBARD), row, recent)); @@ -88,6 +92,7 @@ public class SearchUtilsRFC822Test exten .toLowerCase()), row, recent)); } + @Test public void testBodyShouldNotMatchPhraseOnlyInHeader() throws Exception { assertFalse(searches.isMatch(SearchQuery.bodyContains(FROM_ADDRESS), row, recent)); @@ -95,6 +100,7 @@ public class SearchUtilsRFC822Test exten row, recent)); } + @Test public void testTextShouldMatchPhraseInBody() throws Exception { assertTrue(searches.isMatch(SearchQuery.mailContains(CUSTARD), row, recent)); @@ -102,6 +108,7 @@ public class SearchUtilsRFC822Test exten .mailContains(CUSTARD + CUSTARD), row, recent)); } + @Test public void testTextMatchShouldBeCaseInsensitive() throws Exception { assertTrue(searches.isMatch(SearchQuery.mailContains(RHUBARD), row, recent)); @@ -111,6 +118,7 @@ public class SearchUtilsRFC822Test exten .toLowerCase()), row, recent)); } + @Test public void testBodyShouldMatchPhraseOnlyInHeader() throws Exception { assertTrue(searches.isMatch(SearchQuery.mailContains(FROM_ADDRESS), row, recent)); Modified: james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsTest.java?rev=923950&r1=923949&r2=923950&view=diff ============================================================================== --- james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsTest.java (original) +++ james/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/SearchUtilsTest.java Tue Mar 16 19:47:58 2010 @@ -19,22 +19,24 @@ package org.apache.james.mailboxmanager.torque; +import static org.junit.Assert.*; + import java.util.ArrayList; import java.util.Collection; import java.util.Date; import javax.mail.Flags; -import junit.framework.TestCase; - import org.apache.james.imap.api.ImapConstants; import org.apache.james.imap.mailbox.SearchQuery; import org.apache.james.mailboxmanager.torque.om.MessageFlags; import org.apache.james.mailboxmanager.torque.om.MessageHeader; import org.apache.james.mailboxmanager.torque.om.MessageRow; import org.apache.torque.TorqueException; +import org.junit.Before; +import org.junit.Test; -public class SearchUtilsTest extends TestCase { +public class SearchUtilsTest { private static final String RHUBARD = "Rhubard"; @@ -58,18 +60,15 @@ public class SearchUtilsTest extends Tes Collection recent; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { recent = new ArrayList(); row = new MessageRow(); row.setUid(1009); searches = new MessageSearches(); } - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testMatchSizeLessThan() throws Exception { row.setSize(SIZE); assertFalse(searches.isMatch(SearchQuery.sizeLessThan(SIZE - 1), row, @@ -82,6 +81,7 @@ public class SearchUtilsTest extends Tes SearchQuery.sizeLessThan(Integer.MAX_VALUE), row, recent)); } + @Test public void testMatchSizeMoreThan() throws Exception { row.setSize(SIZE); assertTrue(searches.isMatch(SearchQuery.sizeGreaterThan(SIZE - 1), row, @@ -94,6 +94,7 @@ public class SearchUtilsTest extends Tes .sizeGreaterThan(Integer.MAX_VALUE), row, recent)); } + @Test public void testMatchSizeEquals() throws Exception { row.setSize(SIZE); assertFalse(searches.isMatch(SearchQuery.sizeEquals(SIZE - 1), row, @@ -105,6 +106,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchInternalDateEquals() throws Exception { row.setInternalDate(SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.internalDateOn(9, 9, 2000), @@ -119,6 +121,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchInternalDateBefore() throws Exception { row.setInternalDate(SUN_SEP_9TH_2001); assertFalse(searches.isMatch( @@ -133,6 +136,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchInternalDateAfter() throws Exception { row.setInternalDate(SUN_SEP_9TH_2001); assertTrue(searches.isMatch(SearchQuery.internalDateAfter(9, 9, 2000), @@ -147,6 +151,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testMatchHeaderDateAfter() throws Exception { addHeader(DATE_FIELD, RFC822_SUN_SEP_9TH_2001); assertTrue(searches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, 9, @@ -163,6 +168,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchCapsHeaderDateAfter() throws Exception { addHeader(DATE_FIELD.toUpperCase(), RFC822_SUN_SEP_9TH_2001); assertTrue(searches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, 9, @@ -179,6 +185,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchLowersHeaderDateAfter() throws Exception { addHeader(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); assertTrue(searches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, 9, @@ -195,6 +202,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testMatchHeaderDateOn() throws Exception { addHeader(DATE_FIELD, RFC822_SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, 9, 9, @@ -211,6 +219,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchCapsHeaderDateOn() throws Exception { addHeader(DATE_FIELD.toUpperCase(), RFC822_SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, 9, 9, @@ -227,6 +236,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testShouldMatchLowersHeaderDateOn() throws Exception { addHeader(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, 9, 9, @@ -243,6 +253,7 @@ public class SearchUtilsTest extends Tes 2001), row, recent)); } + @Test public void testMatchHeaderDateBefore() throws Exception { addHeader(DATE_FIELD, RFC822_SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, @@ -259,6 +270,7 @@ public class SearchUtilsTest extends Tes 9, 2001), row, recent)); } + @Test public void testShouldMatchCapsHeaderDateBefore() throws Exception { addHeader(DATE_FIELD.toUpperCase(), RFC822_SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, @@ -275,6 +287,7 @@ public class SearchUtilsTest extends Tes 9, 2001), row, recent)); } + @Test public void testShouldMatchLowersHeaderDateBefore() throws Exception { addHeader(DATE_FIELD.toLowerCase(), RFC822_SUN_SEP_9TH_2001); assertFalse(searches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, @@ -291,6 +304,7 @@ public class SearchUtilsTest extends Tes 9, 2001), row, recent)); } + @Test public void testMatchHeaderContainsCaps() throws Exception { addHeader(SUBJECT_FIELD, TEXT.toUpperCase()); assertFalse(searches.isMatch(SearchQuery.headerContains(DATE_FIELD, @@ -305,6 +319,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testMatchHeaderContainsLowers() throws Exception { addHeader(SUBJECT_FIELD, TEXT.toLowerCase()); assertFalse(searches.isMatch(SearchQuery.headerContains(DATE_FIELD, @@ -319,6 +334,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testMatchHeaderContains() throws Exception { addHeader(SUBJECT_FIELD, TEXT); assertFalse(searches.isMatch(SearchQuery.headerContains(DATE_FIELD, @@ -333,6 +349,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testShouldMatchLowerHeaderContains() throws Exception { addHeader(SUBJECT_FIELD.toLowerCase(), TEXT); assertFalse(searches.isMatch(SearchQuery.headerContains(DATE_FIELD, @@ -347,6 +364,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testShouldMatchCapsHeaderContains() throws Exception { addHeader(SUBJECT_FIELD.toUpperCase(), TEXT); assertFalse(searches.isMatch(SearchQuery.headerContains(DATE_FIELD, @@ -361,6 +379,7 @@ public class SearchUtilsTest extends Tes CUSTARD), row, recent)); } + @Test public void testMatchHeaderExists() throws Exception { addHeader(SUBJECT_FIELD, TEXT); assertFalse(searches.isMatch(SearchQuery.headerExists(DATE_FIELD), row, @@ -369,6 +388,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchLowersHeaderExists() throws Exception { addHeader(SUBJECT_FIELD.toLowerCase(), TEXT); assertFalse(searches.isMatch(SearchQuery.headerExists(DATE_FIELD), row, @@ -377,6 +397,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchUppersHeaderExists() throws Exception { addHeader(SUBJECT_FIELD.toUpperCase(), TEXT); assertFalse(searches.isMatch(SearchQuery.headerExists(DATE_FIELD), row, @@ -385,6 +406,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchUidRange() throws Exception { row.setPrimaryKey(1, 1729); assertFalse(searches.isMatch(SearchQuery.uid(range(1, 1)), row, recent)); @@ -414,6 +436,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchSeenFlagSet() throws Exception { setFlags(true, false, false, false, false, false); assertTrue(searches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN), @@ -430,6 +453,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchAnsweredFlagSet() throws Exception { setFlags(false, false, true, false, false, false); assertFalse(searches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN), @@ -446,6 +470,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchFlaggedFlagSet() throws Exception { setFlags(false, true, false, false, false, false); assertFalse(searches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN), @@ -462,6 +487,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchDraftFlagSet() throws Exception { setFlags(false, false, false, true, false, false); assertFalse(searches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN), @@ -478,6 +504,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchDeletedFlagSet() throws Exception { setFlags(false, false, false, false, true, false); assertFalse(searches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN), @@ -494,6 +521,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchSeenRecentSet() throws Exception { setFlags(false, false, false, false, false, false); recent.add(new Long(row.getUid())); @@ -511,6 +539,7 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchSeenFlagUnSet() throws Exception { setFlags(false, true, true, true, true, true); recent.add(new Long(row.getUid())); @@ -528,6 +557,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchAnsweredFlagUnSet() throws Exception { setFlags(true, true, false, true, true, true); recent.add(new Long(row.getUid())); @@ -545,6 +575,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchFlaggedFlagUnSet() throws Exception { setFlags(true, false, true, true, true, true); recent.add(new Long(row.getUid())); @@ -562,6 +593,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchDraftFlagUnSet() throws Exception { setFlags(true, true, true, false, true, true); recent.add(new Long(row.getUid())); @@ -579,6 +611,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchDeletedFlagUnSet() throws Exception { setFlags(true, true, true, true, false, true); recent.add(new Long(row.getUid())); @@ -596,6 +629,7 @@ public class SearchUtilsTest extends Tes SearchQuery.flagIsUnSet(Flags.Flag.RECENT), row, recent)); } + @Test public void testShouldMatchSeenRecentUnSet() throws Exception { setFlags(true, true, true, true, true, true); recent.add(new Long(row.getUid() + 1)); @@ -613,10 +647,12 @@ public class SearchUtilsTest extends Tes row, recent)); } + @Test public void testShouldMatchAll() throws Exception { assertTrue(searches.isMatch(SearchQuery.all(), row, recent)); } + @Test public void testShouldMatchNot() throws Exception { assertFalse(searches.isMatch(SearchQuery.not(SearchQuery.all()), row, recent)); @@ -624,6 +660,7 @@ public class SearchUtilsTest extends Tes .headerExists(DATE_FIELD)), row, recent)); } + @Test public void testShouldMatchOr() throws Exception { assertTrue(searches.isMatch(SearchQuery.or(SearchQuery.all(), SearchQuery.headerExists(DATE_FIELD)), row, recent)); @@ -636,6 +673,7 @@ public class SearchUtilsTest extends Tes SearchQuery.all()), row, recent)); } + @Test public void testShouldMatchAnd() throws Exception { assertFalse(searches.isMatch(SearchQuery.and(SearchQuery.all(), SearchQuery.headerExists(DATE_FIELD)), row, recent)); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
