Remove Robolectric from a lot of tests

This commit is contained in:
cketti 2022-05-02 15:39:41 +02:00
parent 7135afb162
commit fdb8655f3a
19 changed files with 47 additions and 87 deletions

View file

@ -1,19 +1,17 @@
package com.fsck.k9.helper;
import com.fsck.k9.RobolectricTest;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.internet.MimeMessage;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@RunWith(K9LibRobolectricTestRunner.class)
public class ListHeadersTest {
public class ListHeadersTest extends RobolectricTest {
private static final String[] TEST_EMAIL_ADDRESSES = new String[] {
"prettyandsimple@example.com",
"very.common@example.com",

View file

@ -1,21 +1,19 @@
package com.fsck.k9.helper;
import android.net.Uri;
import com.fsck.k9.helper.MailTo.CaseInsensitiveParamWrapper;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import android.net.Uri;
import com.fsck.k9.RobolectricTest;
import com.fsck.k9.helper.MailTo.CaseInsensitiveParamWrapper;
import com.fsck.k9.mail.Address;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@ -23,8 +21,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@RunWith(K9LibRobolectricTestRunner.class)
public class MailToTest {
public class MailToTest extends RobolectricTest {
@Rule
public ExpectedException exception = ExpectedException.none();
@ -235,4 +232,4 @@ public class MailToTest {
}
}
}

View file

@ -15,7 +15,6 @@ dependencies {
implementation "com.squareup.moshi:moshi:${versions.moshi}"
testImplementation project(":mail:testing")
testImplementation "org.robolectric:robolectric:${versions.robolectric}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "com.google.truth:truth:${versions.truth}"
testImplementation "org.mockito:mockito-inline:${versions.mockito}"

View file

@ -2,7 +2,6 @@ package com.fsck.k9.mail;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -10,7 +9,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@RunWith(K9LibRobolectricTestRunner.class)
public class AddressTest {
/**
* test the possibility to parse "From:" fields with no email.

View file

@ -2,12 +2,10 @@ package com.fsck.k9.mail;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
@RunWith(K9LibRobolectricTestRunner.class)
public class Address_quoteAtoms {
@Test
public void testNoQuote() {

View file

@ -10,24 +10,30 @@ import com.fsck.k9.mail.internet.MimeMultipart
import com.fsck.k9.mail.internet.TextBody
import com.google.common.truth.Truth.assertThat
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.file.Files
import java.util.Date
import java.util.TimeZone
import okio.Buffer
import org.apache.james.mime4j.util.MimeUtil
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RuntimeEnvironment
@RunWith(K9LibRobolectricTestRunner::class)
class MessageTest {
private val context = RuntimeEnvironment.application
private lateinit var tempDirectory: File
private var mimeBoundary: Int = 0
@Before
fun setUp() {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tokyo"))
BinaryTempFileBody.setTempDirectory(context.cacheDir)
tempDirectory = Files.createTempDirectory("MessageTest").toFile()
BinaryTempFileBody.setTempDirectory(tempDirectory)
}
@After
fun tearDown() {
tempDirectory.deleteRecursively()
}
@Test

View file

@ -1,13 +1,10 @@
package com.fsck.k9.mail.internet
import com.fsck.k9.mail.Address
import com.fsck.k9.mail.K9LibRobolectricTestRunner
import com.fsck.k9.mail.crlf
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(K9LibRobolectricTestRunner::class)
class AddressHeaderBuilderTest {
@Test

View file

@ -1,15 +1,11 @@
package com.fsck.k9.mail.internet;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
@RunWith(K9LibRobolectricTestRunner.class)
public class CharsetSupportTest {
@Test

View file

@ -1,12 +1,9 @@
package com.fsck.k9.mail.internet
import com.fsck.k9.mail.Address
import com.fsck.k9.mail.K9LibRobolectricTestRunner
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(K9LibRobolectricTestRunner::class)
class MessageIdGeneratorTest {
private val messageIdGenerator = MessageIdGenerator(
object : UuidGenerator {

View file

@ -9,23 +9,18 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.Message.RecipientType;
import com.fsck.k9.mail.Multipart;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import com.fsck.k9.mail.Message.RecipientType;
import com.fsck.k9.mail.Multipart;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
@RunWith(K9LibRobolectricTestRunner.class)
public class MimeMessageParseTest {
@Before
public void setup() {

View file

@ -13,7 +13,6 @@ dependencies {
implementation "commons-io:commons-io:${versions.commonsIo}"
testImplementation project(":mail:testing")
testImplementation "org.robolectric:robolectric:${versions.robolectric}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "com.google.truth:truth:${versions.truth}"
testImplementation "org.mockito:mockito-core:${versions.mockito}"

View file

@ -10,7 +10,6 @@ import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.CertificateValidationException.Reason;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.XOAuth2ChallengeParserTest;
@ -21,8 +20,6 @@ import com.fsck.k9.mail.store.imap.mockserver.MockImapServer;
import okio.ByteString;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.shadows.ShadowLog;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
@ -32,7 +29,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@RunWith(K9LibRobolectricTestRunner.class)
public class RealImapConnectionTest {
private static final boolean DEBUGGING = false;
@ -63,7 +59,6 @@ public class RealImapConnectionTest {
settings.setPassword(PASSWORD);
if (DEBUGGING) {
ShadowLog.stream = System.out;
K9MailLib.setDebug(true);
K9MailLib.setDebugSensitive(true);
}

View file

@ -4,7 +4,6 @@ import com.fsck.k9.mail.Body
import com.fsck.k9.mail.DefaultBodyFactory
import com.fsck.k9.mail.FetchProfile
import com.fsck.k9.mail.Flag
import com.fsck.k9.mail.K9LibRobolectricTestRunner
import com.fsck.k9.mail.MessageRetrievalListener
import com.fsck.k9.mail.MessagingException
import com.fsck.k9.mail.Part
@ -12,11 +11,14 @@ import com.fsck.k9.mail.internet.BinaryTempFileBody
import com.fsck.k9.mail.internet.MimeHeader
import com.fsck.k9.mail.store.imap.ImapResponseHelper.createImapResponse
import com.google.common.truth.Truth.assertThat
import java.io.File
import java.io.IOException
import java.nio.file.Files
import java.util.Date
import java.util.TimeZone
import okio.Buffer
import org.apache.james.mime4j.util.MimeUtil
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
@ -25,7 +27,6 @@ import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anySet
import org.mockito.ArgumentMatchers.anyString
import org.mockito.ArgumentMatchers.eq
@ -40,9 +41,7 @@ import org.mockito.kotlin.doReturn
import org.mockito.kotlin.doThrow
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import org.robolectric.RuntimeEnvironment
@RunWith(K9LibRobolectricTestRunner::class)
class RealImapFolderTest {
private val internalImapStore = object : InternalImapStore {
override val logLabel = "Account"
@ -52,9 +51,17 @@ class RealImapFolderTest {
private val imapConnection = mock<RealImapConnection>()
private val testConnectionManager = TestConnectionManager(imapConnection)
private lateinit var tempDirectory: File
@Before
fun setUp() {
BinaryTempFileBody.setTempDirectory(RuntimeEnvironment.application.cacheDir)
tempDirectory = Files.createTempDirectory("RealImapFolderTest").toFile()
BinaryTempFileBody.setTempDirectory(tempDirectory)
}
@After
fun tearDown() {
tempDirectory.deleteRecursively()
}
@Test

View file

@ -8,7 +8,6 @@ dependencies {
api project(":mail:common")
testImplementation project(":mail:testing")
testImplementation "org.robolectric:robolectric:${versions.robolectric}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "com.google.truth:truth:${versions.truth}"
testImplementation "org.mockito:mockito-core:${versions.mockito}"

View file

@ -12,7 +12,6 @@ dependencies {
implementation "com.squareup.okio:okio:${versions.okio}"
testImplementation project(":mail:testing")
testImplementation "org.robolectric:robolectric:${versions.robolectric}"
testImplementation "junit:junit:${versions.junit}"
testImplementation "com.google.truth:truth:${versions.truth}"
testImplementation "org.mockito.kotlin:mockito-kotlin:${versions.mockitoKotlin}"

View file

@ -4,7 +4,6 @@ import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.AuthenticationFailedException
import com.fsck.k9.mail.CertificateValidationException
import com.fsck.k9.mail.ConnectionSecurity
import com.fsck.k9.mail.K9LibRobolectricTestRunner
import com.fsck.k9.mail.Message
import com.fsck.k9.mail.MessagingException
import com.fsck.k9.mail.ServerSettings
@ -18,7 +17,6 @@ import com.fsck.k9.mail.transport.mockServer.MockSmtpServer
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyLong
import org.mockito.ArgumentMatchers.anyString
import org.mockito.kotlin.doReturn
@ -32,7 +30,6 @@ private const val USERNAME = "user"
private const val PASSWORD = "password"
private val CLIENT_CERTIFICATE_ALIAS: String? = null
@RunWith(K9LibRobolectricTestRunner::class)
class SmtpTransportTest {
private val socketFactory = TestTrustedSocketFactory.newInstance()
private val oAuth2TokenProvider = createMockOAuth2TokenProvider()

View file

@ -8,11 +8,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Application;
import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.FolderType;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.filter.Base64;
@ -44,6 +45,8 @@ import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.OngoingStubbing;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static junit.framework.Assert.assertSame;
import static org.junit.Assert.assertEquals;
@ -52,7 +55,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9LibRobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
@Config(application = Application.class)
public class WebDavStoreTest {
private static final HttpResponse OK_200_RESPONSE = createOkResponse();
private static final HttpResponse UNAUTHORIZED_401_RESPONSE = createResponse(401);

View file

@ -5,7 +5,6 @@ dependencies {
api project(":mail:common")
api "com.squareup.okio:okio:${versions.okio}"
api "org.robolectric:robolectric:${versions.robolectric}"
api "junit:junit:${versions.junit}"
}

View file

@ -1,20 +0,0 @@
package com.fsck.k9.mail;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
public class K9LibRobolectricTestRunner extends RobolectricTestRunner {
public K9LibRobolectricTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
protected Config buildGlobalConfig() {
return new Config.Builder()
.setSdk(22)
.setManifest(Config.NONE)
.build();
}
}