Use JUnit 5 for tests, bump dependencies

This commit is contained in:
2018-02-20 14:04:40 +01:00
parent 681ea148db
commit c425298b67
45 changed files with 613 additions and 567 deletions

View File

@ -13,7 +13,8 @@ uploadArchives {
dependencies {
compile project(':core')
compile 'org.ini4j:ini4j'
testCompile 'junit:junit'
testCompile 'com.nhaarman:mockito-kotlin'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
testCompile project(':cryptography-bc')
}

View File

@ -37,9 +37,10 @@ import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography
import ch.dissem.bitmessage.ports.AddressRepository
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.whenever
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assumptions.assumeTrue
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
class WifExporterTest {
private val repo = mock<AddressRepository>()
@ -47,7 +48,7 @@ class WifExporterTest {
private lateinit var importer: WifImporter
private lateinit var exporter: WifExporter
@Before
@BeforeEach
fun setUp() {
ctx = BitmessageContext.build {
cryptography = BouncyCryptography()
@ -61,7 +62,7 @@ class WifExporterTest {
listener {}
}
importer = WifImporter(ctx, javaClass.classLoader.getResourceAsStream("nuked.dat"))
assertEquals(81, importer.getIdentities().size)
assumeTrue(importer.getIdentities().size == 81)
exporter = WifExporter(ctx)
}
@ -70,10 +71,7 @@ class WifExporterTest {
whenever(repo.getIdentities()).thenReturn(importer.getIdentities())
exporter.addAll()
val result = exporter.toString()
var count = 0
for (i in 0..result.length - 1) {
if (result[i] == '[') count++
}
val count = result.count { it == '[' }
assertEquals(importer.getIdentities().size, count)
}
@ -81,10 +79,7 @@ class WifExporterTest {
fun `ensure all from a collection are added`() {
exporter.addAll(importer.getIdentities())
val result = exporter.toString()
var count = 0
for (i in 0..result.length - 1) {
if (result[i] == '[') count++
}
val count = result.count { it == '[' }
assertEquals(importer.getIdentities().size, count)
}

View File

@ -39,16 +39,16 @@ import com.nhaarman.mockito_kotlin.any
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.times
import com.nhaarman.mockito_kotlin.verify
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
class WifImporterTest {
private val repo = mock<AddressRepository>()
private lateinit var ctx: BitmessageContext
private lateinit var importer: WifImporter
@Before
@BeforeEach
fun setUp() {
ctx = BitmessageContext.build {
cryptography = BouncyCryptography()
@ -81,7 +81,7 @@ class WifImporterTest {
assertEquals("Nuked Address", identity.alias)
assertEquals(320L, identity.pubkey?.nonceTrialsPerByte)
assertEquals(14000L, identity.pubkey?.extraBytes)
assertNotNull("Private key", identity.privateKey)
assertNotNull(identity.privateKey, "Private key")
assertEquals(32, identity.privateKey?.privateEncryptionKey?.size)
assertEquals(32, identity.privateKey?.privateSigningKey?.size)
assertFalse(identity.isChan)