Remove JUnit 4 dependency from all modules except spring-test

This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

- migration from JUnit 4 assertions to JUnit Jupiter assertions in all
  Kotlin tests
- migration from JUnit 4 assumptions in Spring's TestGroup support to
  JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException
- introduction of a new TestGroups utility class than can be used from
  existing JUnit 4 tests in the spring-test module in order to perform
  assumptions using JUnit 4's Assume class

See gh-23451
This commit is contained in:
Sam Brannen
2019-08-15 11:52:19 +02:00
parent 3f3e41923f
commit 979508a7f3
43 changed files with 159 additions and 111 deletions

View File

@@ -34,7 +34,7 @@ import org.springframework.web.servlet.View;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* @author Rod Johnson

View File

@@ -16,9 +16,9 @@
package org.springframework.web.servlet.function
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.fail
import org.junit.jupiter.api.Test
import org.springframework.core.io.ClassPathResource
import org.springframework.http.HttpHeaders.*

View File

@@ -19,8 +19,8 @@ package org.springframework.web.servlet.function
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Test
import org.springframework.core.ParameterizedTypeReference
import org.springframework.http.MediaType

View File

@@ -19,10 +19,10 @@ package org.springframework.web.servlet.function
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import org.junit.Assert
import org.junit.jupiter.api.Test
import org.springframework.core.ParameterizedTypeReference
import java.util.*
import org.junit.jupiter.api.Assertions.assertEquals
/**
* Tests for WebMvc.fn [ServerResponse] extensions.
@@ -38,7 +38,7 @@ class ServerResponseExtensionsTests {
val body = Arrays.asList("foo", "bar")
val typeReference = object: ParameterizedTypeReference<List<String>>() {}
every { builder.body(body, typeReference) } returns response
Assert.assertEquals(response, builder.bodyWithType<List<String>>(body))
assertEquals(response, builder.bodyWithType<List<String>>(body))
verify { builder.body(body, typeReference) }
}
}

View File

@@ -16,7 +16,7 @@
package org.springframework.web.servlet.mvc.method.annotation
import org.junit.Assert.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.mock.web.test.MockHttpServletRequest
import org.springframework.mock.web.test.MockHttpServletResponse