From 5248350953f4de2d47e495217c392624f087d2d9 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Wed, 17 Dec 2014 12:46:53 +0100 Subject: [PATCH] Clean up tests --- .../fsck/k9/activity/TextBodyBuilderTest.java | 92 ++++++++++--------- .../k9/mail/internet/CharsetSupportTest.java | 2 +- .../k9/mail/internet/DecoderUtilTest.java | 8 -- .../k9/mail/internet/MimeUtilityTest.java | 5 - 4 files changed, 48 insertions(+), 59 deletions(-) diff --git a/tests-on-jvm/src/com/fsck/k9/activity/TextBodyBuilderTest.java b/tests-on-jvm/src/com/fsck/k9/activity/TextBodyBuilderTest.java index 1a924ea0c..7977ab337 100644 --- a/tests-on-jvm/src/com/fsck/k9/activity/TextBodyBuilderTest.java +++ b/tests-on-jvm/src/com/fsck/k9/activity/TextBodyBuilderTest.java @@ -1,54 +1,16 @@ package com.fsck.k9.activity; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.experimental.theories.*; -import org.junit.runner.RunWith; - import com.fsck.k9.Account.QuoteStyle; -import com.fsck.k9.activity.TextBodyBuilder; import com.fsck.k9.mail.internet.TextBody; -class TestingTextBodyBuilder extends TextBodyBuilder { +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.runner.RunWith; - public TestingTextBodyBuilder(boolean includeQuotedText, - boolean isDraft, - QuoteStyle quoteStyle, - boolean replyAfterQuote, - boolean signatureBeforeQuotedText, - boolean useSignature, - String messageText, - String signatureText) { - super(messageText); - - includeQuotedText = (isDraft || includeQuotedText); - if (includeQuotedText) { - this.setIncludeQuotedText(true); - this.setReplyAfterQuote(quoteStyle == QuoteStyle.PREFIX && replyAfterQuote); - } else { - this.setIncludeQuotedText(false); - } - - this.setInsertSeparator(!isDraft); - - useSignature = (!isDraft && useSignature); - if (useSignature) { - this.setAppendSignature(true); - this.setSignature(signatureText); - this.setSignatureBeforeQuotedText(signatureBeforeQuotedText); - } else { - this.setAppendSignature(false); - } - } - - // HtmlConverter depends on Android. - // So we use dummy method for tests. - @Override - protected String textToHtmlFragment(String text) { - return "" + text + ""; - } -} +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; @RunWith(Theories.class) public class TextBodyBuilderTest { @@ -326,4 +288,44 @@ public class TextBodyBuilderTest { assertThat(insertableHtmlContent.toDebugString(), is(expectedHtmlContent)); } + + static class TestingTextBodyBuilder extends TextBodyBuilder { + + public TestingTextBodyBuilder(boolean includeQuotedText, + boolean isDraft, + QuoteStyle quoteStyle, + boolean replyAfterQuote, + boolean signatureBeforeQuotedText, + boolean useSignature, + String messageText, + String signatureText) { + super(messageText); + + includeQuotedText = (isDraft || includeQuotedText); + if (includeQuotedText) { + this.setIncludeQuotedText(true); + this.setReplyAfterQuote(quoteStyle == QuoteStyle.PREFIX && replyAfterQuote); + } else { + this.setIncludeQuotedText(false); + } + + this.setInsertSeparator(!isDraft); + + useSignature = (!isDraft && useSignature); + if (useSignature) { + this.setAppendSignature(true); + this.setSignature(signatureText); + this.setSignatureBeforeQuotedText(signatureBeforeQuotedText); + } else { + this.setAppendSignature(false); + } + } + + // HtmlConverter depends on Android. + // So we use dummy method for tests. + @Override + protected String textToHtmlFragment(String text) { + return "" + text + ""; + } + } } diff --git a/tests-on-jvm/src/com/fsck/k9/mail/internet/CharsetSupportTest.java b/tests-on-jvm/src/com/fsck/k9/mail/internet/CharsetSupportTest.java index 1b314642c..dcf65dd8a 100644 --- a/tests-on-jvm/src/com/fsck/k9/mail/internet/CharsetSupportTest.java +++ b/tests-on-jvm/src/com/fsck/k9/mail/internet/CharsetSupportTest.java @@ -91,4 +91,4 @@ public class CharsetSupportTest extends TestCase { assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message)); } -} \ No newline at end of file +} diff --git a/tests-on-jvm/src/com/fsck/k9/mail/internet/DecoderUtilTest.java b/tests-on-jvm/src/com/fsck/k9/mail/internet/DecoderUtilTest.java index b1d25c873..e0e4feea5 100644 --- a/tests-on-jvm/src/com/fsck/k9/mail/internet/DecoderUtilTest.java +++ b/tests-on-jvm/src/com/fsck/k9/mail/internet/DecoderUtilTest.java @@ -4,14 +4,6 @@ import junit.framework.TestCase; public class DecoderUtilTest extends TestCase { - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - public void testDecodeEncodedWords() { String body, expect; MimeMessage message; diff --git a/tests-on-jvm/src/com/fsck/k9/mail/internet/MimeUtilityTest.java b/tests-on-jvm/src/com/fsck/k9/mail/internet/MimeUtilityTest.java index fe07dddcb..7b86df546 100644 --- a/tests-on-jvm/src/com/fsck/k9/mail/internet/MimeUtilityTest.java +++ b/tests-on-jvm/src/com/fsck/k9/mail/internet/MimeUtilityTest.java @@ -1,10 +1,5 @@ package com.fsck.k9.mail.internet; -import java.util.Locale; - -import com.fsck.k9.K9; -import com.fsck.k9.mail.MessagingException; - import junit.framework.TestCase; public class MimeUtilityTest extends TestCase {