parent
3fcf4233a2
commit
ca02cc1194
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.beans
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
|
@ -31,47 +31,47 @@ class KotlinBeanUtilsTests {
|
|||
fun `Instantiate immutable class`() {
|
||||
val constructor = BeanUtils.findPrimaryConstructor(Foo::class.java)!!
|
||||
val foo = BeanUtils.instantiateClass(constructor, "a", 3)
|
||||
assertEquals("a", foo.param1)
|
||||
assertEquals(3, foo.param2)
|
||||
assertThat(foo.param1).isEqualTo("a")
|
||||
assertThat(foo.param2).isEqualTo(3)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Instantiate immutable class with optional parameter and all parameters specified`() {
|
||||
val constructor = BeanUtils.findPrimaryConstructor(Bar::class.java)!!
|
||||
val bar = BeanUtils.instantiateClass(constructor, "a", 8)
|
||||
assertEquals("a", bar.param1)
|
||||
assertEquals(8, bar.param2)
|
||||
assertThat(bar.param1).isEqualTo("a")
|
||||
assertThat(bar.param2).isEqualTo(8)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Instantiate immutable class with optional parameter and only mandatory parameters specified by position`() {
|
||||
val constructor = BeanUtils.findPrimaryConstructor(Bar::class.java)!!
|
||||
val bar = BeanUtils.instantiateClass(constructor, "a")
|
||||
assertEquals("a", bar.param1)
|
||||
assertEquals(12, bar.param2)
|
||||
assertThat(bar.param1).isEqualTo("a")
|
||||
assertThat(bar.param2).isEqualTo(12)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Instantiate immutable class with optional parameter specified with null value`() {
|
||||
val constructor = BeanUtils.findPrimaryConstructor(Bar::class.java)!!
|
||||
val bar = BeanUtils.instantiateClass(constructor, "a", null)
|
||||
assertEquals("a", bar.param1)
|
||||
assertEquals(12, bar.param2)
|
||||
assertThat(bar.param1).isEqualTo("a")
|
||||
assertThat(bar.param2).isEqualTo(12)
|
||||
}
|
||||
|
||||
@Test // gh-22531
|
||||
fun `Instantiate immutable class with nullable parameter`() {
|
||||
val constructor = BeanUtils.findPrimaryConstructor(Qux::class.java)!!
|
||||
val bar = BeanUtils.instantiateClass(constructor, "a", null)
|
||||
assertEquals("a", bar.param1)
|
||||
assertNull(bar.param2)
|
||||
assertThat(bar.param1).isEqualTo("a")
|
||||
assertThat(bar.param2).isNull()
|
||||
}
|
||||
|
||||
@Test // SPR-15851
|
||||
fun `Instantiate mutable class with declared constructor and default values for all parameters`() {
|
||||
val baz = BeanUtils.instantiateClass(Baz::class.java.getDeclaredConstructor())
|
||||
assertEquals("a", baz.param1)
|
||||
assertEquals(12, baz.param2)
|
||||
assertThat(baz.param1).isEqualTo("a")
|
||||
assertThat(baz.param2).isEqualTo(12)
|
||||
}
|
||||
|
||||
class Foo(val param1: String, val param2: Int)
|
||||
|
|
|
@ -16,16 +16,14 @@
|
|||
|
||||
package org.springframework.beans.factory.annotation
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition
|
||||
import org.springframework.tests.sample.beans.TestBean
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.springframework.beans.factory.BeanCreationException
|
||||
import org.springframework.tests.sample.beans.Colour
|
||||
import org.springframework.tests.sample.beans.TestBean
|
||||
|
||||
/**
|
||||
* Tests for Kotlin support with [Autowired].
|
||||
|
@ -48,9 +46,9 @@ class KotlinAutowiredTests {
|
|||
bf.registerSingleton("testBean", tb)
|
||||
|
||||
val kb = bf.getBean("annotatedBean", KotlinBean::class.java)
|
||||
assertSame(tb, kb.injectedFromConstructor)
|
||||
assertSame(tb, kb.injectedFromMethod)
|
||||
assertSame(tb, kb.injectedField)
|
||||
assertThat(kb.injectedFromConstructor).isSameAs(tb)
|
||||
assertThat(kb.injectedFromMethod).isSameAs(tb)
|
||||
assertThat(kb.injectedField).isSameAs(tb)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -64,9 +62,9 @@ class KotlinAutowiredTests {
|
|||
bf.registerBeanDefinition("annotatedBean", bd)
|
||||
|
||||
val kb = bf.getBean("annotatedBean", KotlinBean::class.java)
|
||||
assertNull(kb.injectedFromConstructor)
|
||||
assertNull(kb.injectedFromMethod)
|
||||
assertNull(kb.injectedField)
|
||||
assertThat(kb.injectedFromConstructor).isNull()
|
||||
assertThat(kb.injectedFromMethod).isNull()
|
||||
assertThat(kb.injectedField).isNull()
|
||||
}
|
||||
|
||||
@Test // SPR-15847
|
||||
|
@ -82,9 +80,9 @@ class KotlinAutowiredTests {
|
|||
bf.registerSingleton("testBean", tb)
|
||||
|
||||
val kb = bf.getBean("bean", KotlinBeanWithMandatoryAndOptionalParameters::class.java)
|
||||
assertSame(tb, kb.injectedFromConstructor)
|
||||
assertEquals("foo", kb.optional)
|
||||
assertEquals("bar", kb.initializedField)
|
||||
assertThat(kb.injectedFromConstructor).isSameAs(tb)
|
||||
assertThat(kb.optional).isEqualTo("foo")
|
||||
assertThat(kb.initializedField).isEqualTo("bar")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -98,9 +96,9 @@ class KotlinAutowiredTests {
|
|||
bf.registerBeanDefinition("bean", bd)
|
||||
|
||||
val kb = bf.getBean("bean", KotlinBeanWithOptionalParameters::class.java)
|
||||
assertNotNull(kb.optional1)
|
||||
assertEquals("foo", kb.optional2)
|
||||
assertEquals("bar", kb.initializedField)
|
||||
assertThat(kb.optional1).isNotNull()
|
||||
assertThat(kb.optional2).isEqualTo("foo")
|
||||
assertThat(kb.initializedField).isEqualTo("bar")
|
||||
}
|
||||
|
||||
@Test // SPR-15847
|
||||
|
@ -116,8 +114,8 @@ class KotlinAutowiredTests {
|
|||
bf.registerSingleton("testBean", tb)
|
||||
|
||||
val kb = bf.getBean("bean", KotlinBeanWithOptionalParameterAndExplicitConstructor::class.java)
|
||||
assertSame(tb, kb.injectedFromConstructor)
|
||||
assertEquals("foo", kb.optional)
|
||||
assertThat(kb.injectedFromConstructor).isSameAs(tb)
|
||||
assertThat(kb.optional).isEqualTo("foo")
|
||||
}
|
||||
|
||||
@Test // SPR-15847
|
||||
|
@ -135,9 +133,9 @@ class KotlinAutowiredTests {
|
|||
bf.registerSingleton("colour", colour)
|
||||
|
||||
val kb = bf.getBean("bean", KotlinBeanWithAutowiredSecondaryConstructor::class.java)
|
||||
assertSame(tb, kb.injectedFromConstructor)
|
||||
assertEquals("bar", kb.optional)
|
||||
assertSame(colour, kb.injectedFromSecondaryConstructor)
|
||||
assertThat(kb.injectedFromConstructor).isSameAs(tb)
|
||||
assertThat(kb.optional).isEqualTo("bar")
|
||||
assertThat(kb.injectedFromSecondaryConstructor).isSameAs(colour)
|
||||
}
|
||||
|
||||
@Test // SPR-16012
|
||||
|
@ -151,7 +149,7 @@ class KotlinAutowiredTests {
|
|||
bf.registerBeanDefinition("bean", bd)
|
||||
|
||||
val kb = bf.getBean("bean", KotlinBeanWithPrimaryAndDefaultConstructors::class.java)
|
||||
assertNotNull(kb.testBean)
|
||||
assertThat(kb.testBean).isNotNull()
|
||||
}
|
||||
|
||||
@Test // SPR-16012
|
||||
|
@ -167,7 +165,7 @@ class KotlinAutowiredTests {
|
|||
bf.registerSingleton("testBean", tb)
|
||||
|
||||
val kb = bf.getBean("bean", KotlinBeanWithPrimaryAndDefaultConstructors::class.java)
|
||||
assertEquals(tb, kb.testBean)
|
||||
assertThat(kb.testBean).isEqualTo(tb)
|
||||
}
|
||||
|
||||
@Test // SPR-16289
|
||||
|
@ -197,13 +195,9 @@ class KotlinAutowiredTests {
|
|||
bf.registerSingleton("testBean", tb)
|
||||
val colour = Colour.BLUE
|
||||
bf.registerSingleton("colour", colour)
|
||||
|
||||
try {
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException::class.java).isThrownBy {
|
||||
bf.getBean("bean", KotlinBeanWithSecondaryConstructor::class.java)
|
||||
fail("should have thrown a BeanCreationException")
|
||||
}
|
||||
catch (e: BeanCreationException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.context.annotation
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertNotNull
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.getBean
|
||||
import org.springframework.context.support.registerBean
|
||||
|
@ -34,9 +34,9 @@ class AnnotationConfigApplicationContextExtensionsTests {
|
|||
val applicationContext = AnnotationConfigApplicationContext {
|
||||
registerBean<Foo>()
|
||||
}
|
||||
assertThat(applicationContext).isNotNull()
|
||||
applicationContext.refresh()
|
||||
assertNotNull(applicationContext)
|
||||
assertNotNull(applicationContext.getBean<Foo>())
|
||||
applicationContext.getBean<Foo>()
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
|
||||
package org.springframework.context.annotation
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.fail
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.getBean
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException
|
||||
|
@ -26,12 +27,8 @@ class KotlinConfigurationClassTests {
|
|||
|
||||
@Test
|
||||
fun `Final configuration with default proxyBeanMethods value`() {
|
||||
try {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException::class.java).isThrownBy {
|
||||
AnnotationConfigApplicationContext(FinalConfigurationWithProxy::class.java)
|
||||
fail("should have thrown a BeanDefinitionParsingException")
|
||||
}
|
||||
catch (e: BeanDefinitionParsingException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +36,7 @@ class KotlinConfigurationClassTests {
|
|||
fun `Final configuration with proxyBeanMethods set to false`() {
|
||||
val context = AnnotationConfigApplicationContext(FinalConfigurationWithoutProxy::class.java)
|
||||
val foo = context.getBean<Foo>()
|
||||
assertEquals(foo, context.getBean<Bar>().foo)
|
||||
assertThat(context.getBean<Bar>().foo).isEqualTo(foo)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.context.annotation
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.BeanFactory
|
||||
import org.springframework.beans.factory.getBean
|
||||
|
@ -39,11 +39,11 @@ class Spr16022Tests {
|
|||
|
||||
private fun assert(context: BeanFactory) {
|
||||
val bean1 = context.getBean<MultipleConstructorsTestBean>("bean1")
|
||||
assertEquals(0, bean1.foo)
|
||||
assertThat(bean1.foo).isEqualTo(0)
|
||||
val bean2 = context.getBean<MultipleConstructorsTestBean>("bean2")
|
||||
assertEquals(1, bean2.foo)
|
||||
assertThat(bean2.foo).isEqualTo(1)
|
||||
val bean3 = context.getBean<MultipleConstructorsTestBean>("bean3")
|
||||
assertEquals(3, bean3.foo)
|
||||
assertThat(bean3.foo).isEqualTo(3)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
|
||||
package org.springframework.context.support
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNotNull
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException
|
||||
|
@ -45,10 +44,10 @@ class BeanDefinitionDslTests {
|
|||
refresh()
|
||||
}
|
||||
|
||||
assertNotNull(context.getBean<Foo>())
|
||||
assertNotNull(context.getBean<Bar>("bar"))
|
||||
assertTrue(context.isPrototype("bar"))
|
||||
assertNotNull(context.getBean<Baz>())
|
||||
context.getBean<Foo>()
|
||||
context.getBean<Bar>("bar")
|
||||
assertThat(context.isPrototype("bar")).isTrue()
|
||||
context.getBean<Baz>()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,13 +71,9 @@ class BeanDefinitionDslTests {
|
|||
refresh()
|
||||
}
|
||||
|
||||
assertNotNull(context.getBean<Foo>())
|
||||
assertNotNull(context.getBean<Bar>("bar"))
|
||||
try {
|
||||
context.getBean<Baz>()
|
||||
fail("Expect NoSuchBeanDefinitionException to be thrown")
|
||||
}
|
||||
catch(ex: NoSuchBeanDefinitionException) { null }
|
||||
context.getBean<Foo>()
|
||||
context.getBean<Bar>("bar")
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException::class.java).isThrownBy { context.getBean<Baz>() }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -100,14 +95,10 @@ class BeanDefinitionDslTests {
|
|||
refresh()
|
||||
}
|
||||
|
||||
assertNotNull(context.getBean<Foo>())
|
||||
assertNotNull(context.getBean<Bar>("bar"))
|
||||
assertEquals("foofoo", context.getBean<FooFoo>().name)
|
||||
try {
|
||||
context.getBean<Baz>()
|
||||
fail("Expect NoSuchBeanDefinitionException to be thrown")
|
||||
}
|
||||
catch(ex: NoSuchBeanDefinitionException) { null }
|
||||
context.getBean<Foo>()
|
||||
context.getBean<Bar>("bar")
|
||||
assertThat(context.getBean<FooFoo>().name).isEqualTo("foofoo")
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException::class.java).isThrownBy { context.getBean<Baz>() }
|
||||
}
|
||||
|
||||
@Test // SPR-16412
|
||||
|
@ -126,7 +117,7 @@ class BeanDefinitionDslTests {
|
|||
}
|
||||
|
||||
for (i in 1..5) {
|
||||
assertNotNull(context.getBean("string$i"))
|
||||
context.getBean("string$i")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +135,7 @@ class BeanDefinitionDslTests {
|
|||
}
|
||||
|
||||
val barbar = context.getBean<BarBar>()
|
||||
assertEquals(2, barbar.foos.size)
|
||||
assertThat(barbar.foos.size).isEqualTo(2)
|
||||
}
|
||||
|
||||
@Test // SPR-17292
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.context.support
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertNotNull
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.getBean
|
||||
|
||||
|
@ -32,7 +31,7 @@ class GenericApplicationContextExtensionsTests {
|
|||
val context = GenericApplicationContext()
|
||||
context.registerBean<BeanA>()
|
||||
context.refresh()
|
||||
assertNotNull(context.getBean<BeanA>())
|
||||
context.getBean<BeanA>()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -40,7 +39,7 @@ class GenericApplicationContextExtensionsTests {
|
|||
val context = GenericApplicationContext()
|
||||
context.registerBean<BeanA>("a")
|
||||
context.refresh()
|
||||
assertNotNull(context.getBean("a"))
|
||||
context.getBean("a")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,7 +47,7 @@ class GenericApplicationContextExtensionsTests {
|
|||
val context = GenericApplicationContext()
|
||||
context.registerBean { BeanA() }
|
||||
context.refresh()
|
||||
assertNotNull(context.getBean<BeanA>())
|
||||
context.getBean<BeanA>()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,7 +55,7 @@ class GenericApplicationContextExtensionsTests {
|
|||
val context = GenericApplicationContext()
|
||||
context.registerBean("a") { BeanA() }
|
||||
context.refresh()
|
||||
assertNotNull(context.getBean("a"))
|
||||
context.getBean("a")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -65,8 +64,8 @@ class GenericApplicationContextExtensionsTests {
|
|||
context.registerBean<BeanA>()
|
||||
context.registerBean { BeanB(it.getBean<BeanA>()) }
|
||||
context.refresh()
|
||||
assertNotNull(context.getBean<BeanA>())
|
||||
assertNotNull(context.getBean<BeanB>())
|
||||
context.getBean<BeanA>()
|
||||
context.getBean<BeanB>()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -75,8 +74,8 @@ class GenericApplicationContextExtensionsTests {
|
|||
context.registerBean<BeanA>("a")
|
||||
context.registerBean("b") { BeanB(it.getBean<BeanA>()) }
|
||||
context.refresh()
|
||||
assertNotNull(context.getBean("a"))
|
||||
assertNotNull(context.getBean("b"))
|
||||
context.getBean("a")
|
||||
context.getBean("b")
|
||||
}
|
||||
|
||||
class BeanA
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.ui
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@ class ModelExtensionsTests {
|
|||
fun setAttribute() {
|
||||
val model:Model = ConcurrentModel()
|
||||
model["foo"] = "bing"
|
||||
assertTrue(model.containsAttribute("foo"))
|
||||
assertEquals("bing", model.asMap()["foo"])
|
||||
assertThat(model.containsAttribute("foo")).isTrue()
|
||||
assertThat(model.asMap()["foo"]).isEqualTo("bing")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.ui
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
|
@ -31,8 +30,8 @@ class ModelMapExtensionsTests {
|
|||
fun setAttribute() {
|
||||
val model = ModelMap()
|
||||
model["foo"] = "bing"
|
||||
assertTrue(model.containsAttribute("foo"))
|
||||
assertEquals("bing", model["foo"])
|
||||
assertThat(model.containsAttribute("foo"))
|
||||
assertThat(model["foo"]).isEqualTo("bing")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.core
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class KotlinDefaultParameterNameDiscovererTests {
|
||||
|
@ -31,6 +31,6 @@ class KotlinDefaultParameterNameDiscovererTests {
|
|||
fun getParameterNamesOnEnum() {
|
||||
val constructor = MyEnum::class.java.declaredConstructors[0]
|
||||
val actualParams = parameterNameDiscoverer.getParameterNames(constructor)
|
||||
assertEquals(2, actualParams!!.size)
|
||||
assertThat(actualParams!!.size).isEqualTo(2)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.core
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.GenericTypeResolver.resolveReturnTypeArgument
|
||||
import java.lang.reflect.Method
|
||||
|
@ -31,14 +31,14 @@ class KotlinGenericTypeResolverTests {
|
|||
|
||||
@Test
|
||||
fun methodReturnTypes() {
|
||||
assertEquals(Integer::class.java, resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "integer")!!,
|
||||
MyInterfaceType::class.java))
|
||||
assertEquals(String::class.java, resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "string")!!,
|
||||
MyInterfaceType::class.java))
|
||||
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "raw")!!,
|
||||
MyInterfaceType::class.java))
|
||||
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "object")!!,
|
||||
MyInterfaceType::class.java))
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "integer")!!,
|
||||
MyInterfaceType::class.java)).isEqualTo(Integer::class.java)
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "string")!!,
|
||||
MyInterfaceType::class.java)).isEqualTo(String::class.java)
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "raw")!!,
|
||||
MyInterfaceType::class.java)).isNull()
|
||||
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods::class.java, "object")!!,
|
||||
MyInterfaceType::class.java)).isNull()
|
||||
}
|
||||
|
||||
private fun findMethod(clazz: Class<*>, name: String): Method? =
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
package org.springframework.core
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.TypeVariable
|
||||
|
@ -49,59 +47,58 @@ class KotlinMethodParameterTests {
|
|||
|
||||
@Test
|
||||
fun `Method parameter nullability`() {
|
||||
assertTrue(MethodParameter(nullableMethod, 0).isOptional)
|
||||
assertFalse(MethodParameter(nonNullableMethod, 0).isOptional)
|
||||
assertThat(MethodParameter(nullableMethod, 0).isOptional).isTrue()
|
||||
assertThat(MethodParameter(nonNullableMethod, 0).isOptional).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Method return type nullability`() {
|
||||
assertTrue(MethodParameter(nullableMethod, -1).isOptional)
|
||||
assertFalse(MethodParameter(nonNullableMethod, -1).isOptional)
|
||||
assertThat(MethodParameter(nullableMethod, -1).isOptional).isTrue()
|
||||
assertThat(MethodParameter(nonNullableMethod, -1).isOptional).isFalse()
|
||||
}
|
||||
|
||||
@Test // SPR-17222
|
||||
fun `Inner class constructor`() {
|
||||
assertFalse(MethodParameter(innerClassConstructor, 0).isOptional)
|
||||
|
||||
assertFalse(MethodParameter(innerClassWithParametersConstructor, 0).isOptional)
|
||||
assertFalse(MethodParameter(innerClassWithParametersConstructor, 1).isOptional)
|
||||
assertTrue(MethodParameter(innerClassWithParametersConstructor, 2).isOptional)
|
||||
assertThat(MethodParameter(innerClassConstructor, 0).isOptional).isFalse()
|
||||
assertThat(MethodParameter(innerClassWithParametersConstructor, 0).isOptional).isFalse()
|
||||
assertThat(MethodParameter(innerClassWithParametersConstructor, 1).isOptional).isFalse()
|
||||
assertThat(MethodParameter(innerClassWithParametersConstructor, 2).isOptional).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Regular class constructor`() {
|
||||
assertFalse(MethodParameter(regularClassConstructor, 0).isOptional)
|
||||
assertTrue(MethodParameter(regularClassConstructor, 1).isOptional)
|
||||
assertThat(MethodParameter(regularClassConstructor, 0).isOptional).isFalse()
|
||||
assertThat(MethodParameter(regularClassConstructor, 1).isOptional).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Suspending function return type`() {
|
||||
assertEquals(Number::class.java, returnParameterType("suspendFun"))
|
||||
assertEquals(Number::class.java, returnGenericParameterType("suspendFun"))
|
||||
assertThat(returnParameterType("suspendFun")).isEqualTo(Number::class.java)
|
||||
assertThat(returnGenericParameterType("suspendFun")).isEqualTo(Number::class.java)
|
||||
|
||||
assertEquals(Producer::class.java, returnParameterType("suspendFun2"))
|
||||
assertEquals("org.springframework.core.Producer<? extends java.lang.Number>", returnGenericParameterTypeName("suspendFun2"))
|
||||
assertThat(returnParameterType("suspendFun2")).isEqualTo(Producer::class.java)
|
||||
assertThat(returnGenericParameterTypeName("suspendFun2")).isEqualTo("org.springframework.core.Producer<? extends java.lang.Number>")
|
||||
|
||||
assertEquals(Wrapper::class.java, returnParameterType("suspendFun3"))
|
||||
assertEquals("org.springframework.core.Wrapper<java.lang.Number>", returnGenericParameterTypeName("suspendFun3"))
|
||||
assertThat(returnParameterType("suspendFun3")).isEqualTo(Wrapper::class.java)
|
||||
assertThat(returnGenericParameterTypeName("suspendFun3")).isEqualTo("org.springframework.core.Wrapper<java.lang.Number>")
|
||||
|
||||
assertEquals(Consumer::class.java, returnParameterType("suspendFun4"))
|
||||
assertEquals("org.springframework.core.Consumer<? super java.lang.Number>", returnGenericParameterTypeName("suspendFun4"))
|
||||
assertThat(returnParameterType("suspendFun4")).isEqualTo(Consumer::class.java)
|
||||
assertThat(returnGenericParameterTypeName("suspendFun4")).isEqualTo("org.springframework.core.Consumer<? super java.lang.Number>")
|
||||
|
||||
assertEquals(Producer::class.java, returnParameterType("suspendFun5"))
|
||||
assertTrue(returnGenericParameterType("suspendFun5") is TypeVariable<*>)
|
||||
assertEquals("org.springframework.core.Producer<? extends java.lang.Number>", returnGenericParameterTypeBoundName("suspendFun5"))
|
||||
assertThat(returnParameterType("suspendFun5")).isEqualTo(Producer::class.java)
|
||||
assertThat(returnGenericParameterType("suspendFun5")).isInstanceOf(TypeVariable::class.java)
|
||||
assertThat(returnGenericParameterTypeBoundName("suspendFun5")).isEqualTo("org.springframework.core.Producer<? extends java.lang.Number>")
|
||||
|
||||
assertEquals(Wrapper::class.java, returnParameterType("suspendFun6"))
|
||||
assertTrue(returnGenericParameterType("suspendFun6") is TypeVariable<*>)
|
||||
assertEquals("org.springframework.core.Wrapper<java.lang.Number>", returnGenericParameterTypeBoundName("suspendFun6"))
|
||||
assertThat(returnParameterType("suspendFun6")).isEqualTo(Wrapper::class.java)
|
||||
assertThat(returnGenericParameterType("suspendFun6")).isInstanceOf(TypeVariable::class.java)
|
||||
assertThat(returnGenericParameterTypeBoundName("suspendFun6")).isEqualTo("org.springframework.core.Wrapper<java.lang.Number>")
|
||||
|
||||
assertEquals(Consumer::class.java, returnParameterType("suspendFun7"))
|
||||
assertTrue(returnGenericParameterType("suspendFun7") is TypeVariable<*>)
|
||||
assertEquals("org.springframework.core.Consumer<? super java.lang.Number>", returnGenericParameterTypeBoundName("suspendFun7"))
|
||||
assertThat(returnParameterType("suspendFun7")).isEqualTo(Consumer::class.java)
|
||||
assertThat(returnGenericParameterType("suspendFun7")).isInstanceOf(TypeVariable::class.java)
|
||||
assertThat(returnGenericParameterTypeBoundName("suspendFun7")).isEqualTo("org.springframework.core.Consumer<? super java.lang.Number>")
|
||||
|
||||
assertEquals(Object::class.java, returnParameterType("suspendFun8"))
|
||||
assertEquals(Object::class.java, returnGenericParameterType("suspendFun8"))
|
||||
assertThat(returnParameterType("suspendFun8")).isEqualTo(Object::class.java)
|
||||
assertThat(returnGenericParameterType("suspendFun8")).isEqualTo(Object::class.java)
|
||||
}
|
||||
|
||||
private fun returnParameterType(funName: String) = returnMethodParameter(funName).parameterType
|
||||
|
|
|
@ -17,16 +17,13 @@
|
|||
package org.springframework.core
|
||||
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Assertions.fail
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.reactivestreams.Publisher
|
||||
import reactor.core.publisher.Flux
|
||||
|
@ -35,7 +32,6 @@ import reactor.test.StepVerifier
|
|||
import java.time.Duration
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
class KotlinReactiveAdapterRegistryTests {
|
||||
|
||||
private val registry = ReactiveAdapterRegistry.getSharedInstance()
|
||||
|
@ -44,16 +40,16 @@ class KotlinReactiveAdapterRegistryTests {
|
|||
fun deferredToPublisher() {
|
||||
val source = GlobalScope.async { 1 }
|
||||
val target: Publisher<Int> = getAdapter(Deferred::class).toPublisher(source)
|
||||
assertTrue(target is Mono<*>, "Expected Mono Publisher: " + target.javaClass.name)
|
||||
assertEquals(1, (target as Mono<Int>).block(Duration.ofMillis(1000)))
|
||||
assertThat(target).isInstanceOf(Mono::class.java)
|
||||
assertThat((target as Mono<Int>).block(Duration.ofMillis(1000))).isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun publisherToDeferred() {
|
||||
val source = Mono.just(1)
|
||||
val target = getAdapter(Deferred::class).fromPublisher(source)
|
||||
assertTrue(target is Deferred<*>)
|
||||
assertEquals(1, runBlocking { (target as Deferred<*>).await() })
|
||||
assertThat(target).isInstanceOf(Deferred::class.java)
|
||||
assertThat(runBlocking { (target as Deferred<*>).await() }).isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -64,7 +60,7 @@ class KotlinReactiveAdapterRegistryTests {
|
|||
emit(3)
|
||||
}
|
||||
val target: Publisher<Int> = getAdapter(Flow::class).toPublisher(source)
|
||||
assertTrue(target is Flux<*>, "Expected Flux Publisher: " + target.javaClass.name)
|
||||
assertThat(target).isInstanceOf(Flux::class.java)
|
||||
StepVerifier.create(target)
|
||||
.expectNext(1)
|
||||
.expectNext(2)
|
||||
|
@ -76,12 +72,8 @@ class KotlinReactiveAdapterRegistryTests {
|
|||
fun publisherToFlow() {
|
||||
val source = Flux.just(1, 2, 3)
|
||||
val target = getAdapter(Flow::class).fromPublisher(source)
|
||||
if (target is Flow<*>) {
|
||||
assertEquals(listOf(1, 2, 3), runBlocking { target.toList() })
|
||||
}
|
||||
else {
|
||||
fail()
|
||||
}
|
||||
assertThat(target).isInstanceOf(Flow::class.java)
|
||||
assertThat(runBlocking { (target as Flow<*>).toList() }).contains(1, 2, 3)
|
||||
}
|
||||
|
||||
private fun getAdapter(reactiveType: KClass<*>): ReactiveAdapter {
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
|
||||
package org.springframework.core
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
import org.hamcrest.CoreMatchers.`is`
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.springframework.util.ReflectionUtils
|
||||
|
||||
/**
|
||||
|
@ -33,21 +32,21 @@ class KotlinReflectionParameterNameDiscovererTests {
|
|||
fun getParameterNamesOnInterface() {
|
||||
val method = ReflectionUtils.findMethod(MessageService::class.java,"sendMessage", String::class.java)!!
|
||||
val actualParams = parameterNameDiscoverer.getParameterNames(method)
|
||||
assertThat(actualParams, `is`(arrayOf("message")))
|
||||
assertThat(actualParams).contains("message")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getParameterNamesOnClass() {
|
||||
val method = ReflectionUtils.findMethod(MessageServiceImpl::class.java,"sendMessage", String::class.java)!!
|
||||
val actualParams = parameterNameDiscoverer.getParameterNames(method)
|
||||
assertThat(actualParams, `is`(arrayOf("message")))
|
||||
assertThat(actualParams).contains("message")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getParameterNamesOnExtensionMethod() {
|
||||
val method = ReflectionUtils.findMethod(UtilityClass::class.java, "identity", String::class.java)!!
|
||||
val actualParams = parameterNameDiscoverer.getParameterNames(method)!!
|
||||
assertThat(actualParams, `is`(arrayOf("\$receiver")))
|
||||
assertThat(actualParams).contains("\$receiver")
|
||||
}
|
||||
|
||||
interface MessageService {
|
||||
|
|
|
@ -21,8 +21,7 @@ import java.sql.*
|
|||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
|
@ -40,21 +39,21 @@ class JdbcOperationsExtensionsTests {
|
|||
@Test
|
||||
fun `queryForObject with reified type parameters`() {
|
||||
every { template.queryForObject(sql, any<Class<Int>>()) } returns 2
|
||||
assertEquals(2, template.queryForObject<Int>(sql))
|
||||
assertThat(template.queryForObject<Int>(sql)).isEqualTo(2)
|
||||
verify { template.queryForObject(sql, any<Class<Int>>()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with RowMapper-like function`() {
|
||||
every { template.queryForObject(sql, any<RowMapper<Int>>(), any<Int>()) } returns 2
|
||||
assertEquals(2, template.queryForObject(sql, 3) { rs: ResultSet, _: Int -> rs.getInt(1) })
|
||||
assertThat(template.queryForObject(sql, 3) { rs: ResultSet, _: Int -> rs.getInt(1) }).isEqualTo(2)
|
||||
verify { template.queryForObject(eq(sql), any<RowMapper<Int>>(), eq(3)) }
|
||||
}
|
||||
|
||||
@Test // gh-22682
|
||||
fun `queryForObject with nullable RowMapper-like function`() {
|
||||
every { template.queryForObject(sql, any<RowMapper<Int>>(), 3) } returns null
|
||||
assertNull(template.queryForObject(sql, 3) { _, _ -> null as Int? })
|
||||
assertThat(template.queryForObject(sql, 3) { _, _ -> null as Int? }).isNull()
|
||||
verify { template.queryForObject(eq(sql), any<RowMapper<Int?>>(), eq(3)) }
|
||||
}
|
||||
|
||||
|
@ -63,7 +62,7 @@ class JdbcOperationsExtensionsTests {
|
|||
val args = arrayOf(3)
|
||||
val argTypes = intArrayOf(JDBCType.INTEGER.vendorTypeNumber)
|
||||
every { template.queryForObject(sql, args, argTypes, any<Class<Int>>()) } returns 2
|
||||
assertEquals(2, template.queryForObject<Int>(sql, args, argTypes))
|
||||
assertThat(template.queryForObject<Int>(sql, args, argTypes)).isEqualTo(2)
|
||||
verify { template.queryForObject(sql, args, argTypes, any<Class<Int>>()) }
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ class JdbcOperationsExtensionsTests {
|
|||
fun `queryForObject with reified type parameters and args`() {
|
||||
val args = arrayOf(3)
|
||||
every { template.queryForObject(sql, args, any<Class<Int>>()) } returns 2
|
||||
assertEquals(2, template.queryForObject<Int>(sql, args))
|
||||
assertThat(template.queryForObject<Int>(sql, args)).isEqualTo(2)
|
||||
verify { template.queryForObject(sql, args, any<Class<Int>>()) }
|
||||
}
|
||||
|
||||
|
@ -79,7 +78,7 @@ class JdbcOperationsExtensionsTests {
|
|||
fun `queryForList with reified type parameters`() {
|
||||
val list = listOf(1, 2, 3)
|
||||
every { template.queryForList(sql, any<Class<Int>>()) } returns list
|
||||
assertEquals(list, template.queryForList<Int>(sql))
|
||||
assertThat(template.queryForList<Int>(sql)).isEqualTo(list)
|
||||
verify { template.queryForList(sql, any<Class<Int>>()) }
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,7 @@ class JdbcOperationsExtensionsTests {
|
|||
val args = arrayOf(3)
|
||||
val argTypes = intArrayOf(JDBCType.INTEGER.vendorTypeNumber)
|
||||
every { template.queryForList(sql, args, argTypes, any<Class<Int>>()) } returns list
|
||||
assertEquals(list, template.queryForList<Int>(sql, args, argTypes))
|
||||
assertThat(template.queryForList<Int>(sql, args, argTypes)).isEqualTo(list)
|
||||
verify { template.queryForList(sql, args, argTypes, any<Class<Int>>()) }
|
||||
}
|
||||
|
||||
|
@ -105,17 +104,17 @@ class JdbcOperationsExtensionsTests {
|
|||
@Test
|
||||
fun `query with ResultSetExtractor-like function`() {
|
||||
every { template.query(eq(sql), any<ResultSetExtractor<Int>>(), eq(3)) } returns 2
|
||||
assertEquals(2, template.query<Int>(sql, 3) { rs ->
|
||||
assertThat(template.query<Int>(sql, 3) { rs ->
|
||||
rs.next()
|
||||
rs.getInt(1)
|
||||
})
|
||||
}).isEqualTo(2)
|
||||
verify { template.query(eq(sql), any<ResultSetExtractor<Int>>(), eq(3)) }
|
||||
}
|
||||
|
||||
@Test // gh-22682
|
||||
fun `query with nullable ResultSetExtractor-like function`() {
|
||||
every { template.query(eq(sql), any<ResultSetExtractor<Int?>>(), eq(3)) } returns null
|
||||
assertNull(template.query<Int?>(sql, 3) { _ -> null })
|
||||
assertThat(template.query<Int?>(sql, 3) { _ -> null }).isNull()
|
||||
verify { template.query(eq(sql), any<ResultSetExtractor<Int?>>(), eq(3)) }
|
||||
}
|
||||
|
||||
|
@ -124,7 +123,7 @@ class JdbcOperationsExtensionsTests {
|
|||
fun `query with RowCallbackHandler-like function`() {
|
||||
every { template.query(sql, ofType<RowCallbackHandler>(), 3) } returns Unit
|
||||
template.query(sql, 3) { rs ->
|
||||
assertEquals(22, rs.getInt(1))
|
||||
assertThat(rs.getInt(1)).isEqualTo(22)
|
||||
}
|
||||
verify { template.query(sql, ofType<RowCallbackHandler>(), 3) }
|
||||
}
|
||||
|
@ -133,9 +132,9 @@ class JdbcOperationsExtensionsTests {
|
|||
fun `query with RowMapper-like function`() {
|
||||
val list = listOf(1, 2, 3)
|
||||
every { template.query(sql, ofType<RowMapper<*>>(), 3) } returns list
|
||||
assertEquals(list, template.query(sql, 3) { rs, _ ->
|
||||
assertThat(template.query(sql, 3) { rs, _ ->
|
||||
rs.getInt(1)
|
||||
})
|
||||
}).isEqualTo(list)
|
||||
verify { template.query(sql, ofType<RowMapper<*>>(), 3) }
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.springframework.jdbc.core.namedparam
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import java.sql.JDBCType
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
|
@ -32,24 +32,24 @@ class MapSqlParameterSourceExtensionsTests {
|
|||
fun `setter with value`() {
|
||||
val source = MapSqlParameterSource()
|
||||
source["foo"] = 2
|
||||
assertEquals(2, source.getValue("foo"))
|
||||
assertThat(source.getValue("foo")).isEqualTo(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `setter with value and type`() {
|
||||
val source = MapSqlParameterSource()
|
||||
source["foo", JDBCType.INTEGER.vendorTypeNumber] = 2
|
||||
assertEquals(2, source.getValue("foo"))
|
||||
assertEquals(JDBCType.INTEGER.vendorTypeNumber, source.getSqlType("foo"))
|
||||
assertThat(source.getValue("foo")).isEqualTo(2)
|
||||
assertThat(source.getSqlType("foo")).isEqualTo(JDBCType.INTEGER.vendorTypeNumber)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `setter with value, type and type name`() {
|
||||
val source = MapSqlParameterSource()
|
||||
source["foo", JDBCType.INTEGER.vendorTypeNumber, "INT"] = 2
|
||||
assertEquals(2, source.getValue("foo"))
|
||||
assertEquals(JDBCType.INTEGER.vendorTypeNumber, source.getSqlType("foo"))
|
||||
assertEquals("INT", source.getTypeName("foo"))
|
||||
assertThat(source.getValue("foo")).isEqualTo(2)
|
||||
assertThat(source.getSqlType("foo")).isEqualTo(JDBCType.INTEGER.vendorTypeNumber)
|
||||
assertThat(source.getTypeName("foo")).isEqualTo("INT")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.messaging.rsocket
|
||||
|
||||
import io.rsocket.transport.ClientTransport
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
||||
import kotlinx.coroutines.reactive.awaitSingle
|
||||
|
@ -90,7 +89,6 @@ inline fun <reified T : Any> RSocketRequester.RequestSpec.dataWithType(publisher
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> RSocketRequester.RequestSpec.dataWithType(flow: Flow<T>): RSocketRequester.ResponseSpec =
|
||||
data(flow, object : ParameterizedTypeReference<T>() {})
|
||||
|
||||
|
@ -120,7 +118,6 @@ suspend inline fun <reified T : Any> RSocketRequester.ResponseSpec.retrieveAndAw
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> RSocketRequester.ResponseSpec.retrieveFlow(): Flow<T> =
|
||||
retrieveFlux(object : ParameterizedTypeReference<T>() {}).asFlow()
|
||||
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.rsocket
|
||||
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.reactivestreams.Publisher
|
||||
|
@ -20,7 +35,6 @@ import java.util.concurrent.CompletableFuture
|
|||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@ExperimentalCoroutinesApi
|
||||
class RSocketRequesterExtensionsTests {
|
||||
|
||||
private val stringTypeRefMatcher: (ParameterizedTypeReference<*>) -> Boolean = { it.type == String::class.java }
|
||||
|
@ -31,7 +45,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val builder = mockk<RSocketRequester.Builder>()
|
||||
every { builder.connect(any()) } returns Mono.just(requester)
|
||||
runBlocking {
|
||||
assertEquals(requester, builder.connectAndAwait(mockk()))
|
||||
assertThat(builder.connectAndAwait(mockk())).isEqualTo(requester)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +56,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val builder = mockk<RSocketRequester.Builder>()
|
||||
every { builder.connectTcp(host, anyInt()) } returns Mono.just(requester)
|
||||
runBlocking {
|
||||
assertEquals(requester, builder.connectTcpAndAwait(host, 0))
|
||||
assertThat(builder.connectTcpAndAwait(host, 0)).isEqualTo(requester)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +66,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val builder = mockk<RSocketRequester.Builder>()
|
||||
every { builder.connectWebSocket(any()) } returns Mono.just(requester)
|
||||
runBlocking {
|
||||
assertEquals(requester, builder.connectWebSocketAndAwait(mockk()))
|
||||
assertThat(builder.connectWebSocketAndAwait(mockk())).isEqualTo(requester)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +76,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
val data = mockk<Publisher<String>>()
|
||||
every { requestSpec.data(any<Publisher<String>>(), match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns responseSpec
|
||||
assertEquals(responseSpec, requestSpec.dataWithType(data))
|
||||
assertThat(requestSpec.dataWithType(data)).isEqualTo(responseSpec)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -71,7 +85,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
val data = mockk<Flow<String>>()
|
||||
every { requestSpec.data(any<Publisher<String>>(), match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns responseSpec
|
||||
assertEquals(responseSpec, requestSpec.dataWithType(data))
|
||||
assertThat(requestSpec.dataWithType(data)).isEqualTo(responseSpec)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -80,7 +94,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
val data = mockk<CompletableFuture<String>>()
|
||||
every { requestSpec.data(any<Publisher<String>>(), match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns responseSpec
|
||||
assertEquals(responseSpec, requestSpec.dataWithType<String>(data))
|
||||
assertThat(requestSpec.dataWithType<String>(data)).isEqualTo(responseSpec)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,7 +102,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val requestSpec = mockk<RSocketRequester.RequestSpec>()
|
||||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
every { requestSpec.data(any()) } returns responseSpec
|
||||
assertEquals(responseSpec, requestSpec.data(mockk()))
|
||||
assertThat(requestSpec.data(mockk())).isEqualTo(responseSpec)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -106,7 +120,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
every { responseSpec.retrieveMono(match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns Mono.just("foo")
|
||||
runBlocking {
|
||||
assertEquals(response, responseSpec.retrieveAndAwait<String>())
|
||||
assertThat(responseSpec.retrieveAndAwait<String>()).isEqualTo(response)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +129,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
every { responseSpec.retrieveFlux(match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns Flux.just("foo", "bar")
|
||||
runBlocking {
|
||||
assertEquals(listOf("foo", "bar"), responseSpec.retrieveFlow<String>().toList())
|
||||
assertThat(responseSpec.retrieveFlow<String>().toList()).contains("foo", "bar")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +138,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
every { responseSpec.retrieveMono(match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns Mono.just("foo")
|
||||
runBlocking {
|
||||
assertEquals("foo", responseSpec.retrieveMono<String>().block())
|
||||
assertThat(responseSpec.retrieveMono<String>().block()).isEqualTo("foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +147,7 @@ class RSocketRequesterExtensionsTests {
|
|||
val responseSpec = mockk<RSocketRequester.ResponseSpec>()
|
||||
every { responseSpec.retrieveFlux(match<ParameterizedTypeReference<*>>(stringTypeRefMatcher)) } returns Flux.just("foo", "bar")
|
||||
runBlocking {
|
||||
assertEquals(listOf("foo", "bar"), responseSpec.retrieveFlux<String>().collectList().block())
|
||||
assertThat(responseSpec.retrieveFlux<String>().collectList().block()).contains("foo", "bar")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.messaging.simp.annotation.support
|
||||
|
||||
import io.mockk.mockk
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import java.util.Collections
|
||||
import java.util.HashMap
|
||||
|
||||
|
@ -36,7 +37,6 @@ import org.springframework.messaging.simp.SimpMessagingTemplate
|
|||
import org.springframework.messaging.support.MessageBuilder
|
||||
import org.springframework.stereotype.Controller
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.springframework.messaging.MessageHandlingException
|
||||
import org.springframework.messaging.handler.annotation.MessageExceptionHandler
|
||||
|
||||
|
@ -70,8 +70,8 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nullableHeader", Collections.singletonMap("foo", "bar"))
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertNull(testController.exception)
|
||||
assertEquals("bar", testController.header)
|
||||
assertThat(testController.exception).isNull()
|
||||
assertThat(testController.header).isEqualTo("bar")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -79,8 +79,8 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nullableHeader", Collections.emptyMap())
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertNull(testController.exception)
|
||||
assertNull(testController.header)
|
||||
assertThat(testController.exception).isNull()
|
||||
assertThat(testController.header).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,7 +88,7 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nonNullableHeader", Collections.singletonMap("foo", "bar"))
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertEquals("bar", testController.header)
|
||||
assertThat(testController.header).isEqualTo("bar")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -96,8 +96,8 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nonNullableHeader", Collections.emptyMap())
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertNotNull(testController.exception)
|
||||
assertTrue(testController.exception is MessageHandlingException)
|
||||
assertThat(testController.exception).isNotNull()
|
||||
assertThat(testController.exception).isInstanceOf(MessageHandlingException::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -105,8 +105,8 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nullableHeaderNotRequired", Collections.singletonMap("foo", "bar"))
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertNull(testController.exception)
|
||||
assertEquals("bar", testController.header)
|
||||
assertThat(testController.exception).isNull()
|
||||
assertThat(testController.header).isEqualTo("bar")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -114,8 +114,8 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nullableHeaderNotRequired", Collections.emptyMap())
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertNull(testController.exception)
|
||||
assertNull(testController.header)
|
||||
assertThat(testController.exception).isNull()
|
||||
assertThat(testController.header).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -123,7 +123,7 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nonNullableHeaderNotRequired", Collections.singletonMap("foo", "bar"))
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertEquals("bar", testController.header)
|
||||
assertThat(testController.header).isEqualTo("bar")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -131,8 +131,8 @@ class SimpAnnotationMethodMessageHandlerKotlinTests {
|
|||
val message = createMessage("/nonNullableHeaderNotRequired", Collections.emptyMap())
|
||||
messageHandler.registerHandler(testController)
|
||||
messageHandler.handleMessage(message)
|
||||
assertNotNull(testController.exception)
|
||||
assertTrue(testController.exception is IllegalArgumentException)
|
||||
assertThat(testController.exception).isNotNull()
|
||||
assertThat(testController.exception).isInstanceOf(IllegalArgumentException::class.java)
|
||||
}
|
||||
|
||||
private fun createMessage(destination: String, headers: Map<String, String?>): Message<ByteArray> {
|
||||
|
|
|
@ -20,7 +20,7 @@ import io.mockk.mockk
|
|||
import io.mockk.verify
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
|
@ -80,7 +80,7 @@ class WebTestClientExtensionsTests {
|
|||
WebTestClient
|
||||
.bindToRouterFunction( router { GET("/") { ok().bodyValue("foo") } } )
|
||||
.build()
|
||||
.get().uri("/").exchange().expectBody<String>().consumeWith { assertEquals("foo", it.responseBody) }
|
||||
.get().uri("/").exchange().expectBody<String>().consumeWith { assertThat(it.responseBody).isEqualTo("foo") }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,7 +88,7 @@ class WebTestClientExtensionsTests {
|
|||
WebTestClient
|
||||
.bindToRouterFunction( router { GET("/") { ok().bodyValue("foo") } } )
|
||||
.build()
|
||||
.get().uri("/").exchange().expectBody<String>().returnResult().apply { assertEquals("foo", responseBody) }
|
||||
.get().uri("/").exchange().expectBody<String>().returnResult().apply { assertThat(responseBody).isEqualTo("foo") }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
|
||||
package org.springframework.test.web.servlet
|
||||
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.springframework.http.HttpMethod
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType.*
|
||||
|
@ -81,8 +80,8 @@ class MockMvcExtensionsTests {
|
|||
}.andDo {
|
||||
handle(handler)
|
||||
}
|
||||
assertTrue(matcherInvoked)
|
||||
assertTrue(handlerInvoked)
|
||||
assertThat(matcherInvoked).isTrue()
|
||||
assertThat(handlerInvoked).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -125,21 +124,20 @@ class MockMvcExtensionsTests {
|
|||
mockMvc.get("/person/$name") {
|
||||
accept = APPLICATION_JSON
|
||||
}.andExpect {
|
||||
assertThrows<AssertionError> { content { contentType(APPLICATION_ATOM_XML) } }
|
||||
assertThrows<AssertionError> { content { string("Wrong") } }
|
||||
assertThrows<AssertionError> { jsonPath("name", CoreMatchers.`is`("Wrong")) }
|
||||
assertThrows<AssertionError> { content { json("""{"name":"wrong"}""") } }
|
||||
assertThrows<AssertionError> { jsonPath("name") { value("wrong") } }
|
||||
assertThrows<AssertionError> { cookie { value("name", "wrong") } }
|
||||
assertThrows<AssertionError> { flash { attribute<String>("name", "wrong") } }
|
||||
assertThrows<AssertionError> { header { stringValues("name", "wrong") } }
|
||||
assertThrows<AssertionError> { model { attributeExists("name", "wrong") } }
|
||||
assertThrows<AssertionError> { redirectedUrl("wrong/Url") }
|
||||
assertThrows<AssertionError> { redirectedUrlPattern("wrong/Url") }
|
||||
assertThrows<AssertionError> { redirectedUrlPattern("wrong/Url") }
|
||||
assertThrows<AssertionError> { status { isAccepted } }
|
||||
assertThrows<AssertionError> { view { name("wrongName") } }
|
||||
assertThrows<AssertionError> { jsonPath("name") { value("wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { content { contentType(APPLICATION_ATOM_XML) } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { content { string("Wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { jsonPath("name", CoreMatchers.`is`("Wrong")) }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { content { json("""{"name":"wrong"}""") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { jsonPath("name") { value("wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { cookie { value("name", "wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { flash { attribute<String>("name", "wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { header { stringValues("name", "wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { model { attributeExists("name", "wrong") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { redirectedUrl("wrong/Url") }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { redirectedUrlPattern("wrong/Url") }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { status { isAccepted } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { view { name("wrongName") } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { jsonPath("name") { value("wrong") } }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +147,7 @@ class MockMvcExtensionsTests {
|
|||
accept = APPLICATION_XML
|
||||
}.andExpect {
|
||||
status { isOk }
|
||||
assertThrows<AssertionError> { xpath("//wrong") { nodeCount(1) } }
|
||||
assertThatExceptionOfType(AssertionError::class.java).isThrownBy { xpath("//wrong") { nodeCount(1) } }
|
||||
}.andDo {
|
||||
print()
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.springframework.web.client
|
|||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.*
|
||||
|
@ -47,7 +47,7 @@ class RestOperationsExtensionsTests {
|
|||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
every { template.getForObject(url, Foo::class.java, var1, var2) } returns foo
|
||||
assertEquals(foo, template.getForObject<Foo>(url, var1, var2))
|
||||
assertThat(template.getForObject<Foo>(url, var1, var2)).isEqualTo(foo)
|
||||
verify { template.getForObject(url, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class RestOperationsExtensionsTests {
|
|||
val url = "https://spring.io"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
every { template.getForObject(url, Foo::class.java, vars) } returns foo
|
||||
assertEquals(foo, template.getForObject<Foo>(url, vars))
|
||||
assertThat(template.getForObject<Foo>(url, vars)).isEqualTo(foo)
|
||||
verify { template.getForObject(url, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class RestOperationsExtensionsTests {
|
|||
fun `getForObject with reified type parameters and URI`() {
|
||||
val url = URI("https://spring.io")
|
||||
every { template.getForObject(url, Foo::class.java) } returns foo
|
||||
assertEquals(foo, template.getForObject<Foo>(url))
|
||||
assertThat(template.getForObject<Foo>(url)).isEqualTo(foo)
|
||||
verify { template.getForObject(url, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class RestOperationsExtensionsTests {
|
|||
fun `getForEntity with reified type parameters, String and URI`() {
|
||||
val url = URI("https://spring.io")
|
||||
every { template.getForEntity(url, Foo::class.java) } returns entity
|
||||
assertEquals(entity, template.getForEntity<Foo>(url))
|
||||
assertThat(template.getForEntity<Foo>(url)).isEqualTo(entity)
|
||||
verify { template.getForEntity(url, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class RestOperationsExtensionsTests {
|
|||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
every { template.getForEntity(url, Foo::class.java, var1, var2) } returns entity
|
||||
assertEquals(entity, template.getForEntity<Foo>(url, var1, var2))
|
||||
assertThat(template.getForEntity<Foo>(url, var1, var2)).isEqualTo(entity)
|
||||
verify { template.getForEntity(url, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ class RestOperationsExtensionsTests {
|
|||
val url = "https://spring.io"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
every { template.getForEntity(url, Foo::class.java, vars) } returns entity
|
||||
assertEquals(entity, template.getForEntity<Foo>(url, vars))
|
||||
assertThat(template.getForEntity<Foo>(url, vars)).isEqualTo(entity)
|
||||
verify { template.getForEntity(url, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class RestOperationsExtensionsTests {
|
|||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
every { template.patchForObject(url, body, Foo::class.java, var1, var2) } returns foo
|
||||
assertEquals(foo, template.patchForObject<Foo>(url, body, var1, var2))
|
||||
assertThat(template.patchForObject<Foo>(url, body, var1, var2)).isEqualTo(foo)
|
||||
verify { template.patchForObject(url, body, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class RestOperationsExtensionsTests {
|
|||
val body: Any = "body"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
every { template.patchForObject(url, body, Foo::class.java, vars) } returns foo
|
||||
assertEquals(foo, template.patchForObject<Foo>(url, body, vars))
|
||||
assertThat(template.patchForObject<Foo>(url, body, vars)).isEqualTo(foo)
|
||||
verify { template.patchForObject(url, body, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ class RestOperationsExtensionsTests {
|
|||
val url = "https://spring.io"
|
||||
val body: Any = "body"
|
||||
every { template.patchForObject(url, body, Foo::class.java) } returns foo
|
||||
assertEquals(foo, template.patchForObject<Foo>(url, body))
|
||||
assertThat(template.patchForObject<Foo>(url, body)).isEqualTo(foo)
|
||||
verify { template.patchForObject(url, body, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ class RestOperationsExtensionsTests {
|
|||
fun `patchForObject with reified type parameters`() {
|
||||
val url = "https://spring.io"
|
||||
every { template.patchForObject(url, null, Foo::class.java) } returns foo
|
||||
assertEquals(foo, template.patchForObject<Foo>(url))
|
||||
assertThat(template.patchForObject<Foo>(url)).isEqualTo(foo)
|
||||
verify { template.patchForObject(url, null, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class RestOperationsExtensionsTests {
|
|||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
every { template.postForObject(url, body, Foo::class.java, var1, var2) } returns foo
|
||||
assertEquals(foo, template.postForObject<Foo>(url, body, var1, var2))
|
||||
assertThat(template.postForObject<Foo>(url, body, var1, var2)).isEqualTo(foo)
|
||||
verify { template.postForObject(url, body, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ class RestOperationsExtensionsTests {
|
|||
val body: Any = "body"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
every { template.postForObject(url, body, Foo::class.java, vars) } returns foo
|
||||
assertEquals(foo, template.postForObject<Foo>(url, body, vars))
|
||||
assertThat(template.postForObject<Foo>(url, body, vars)).isEqualTo(foo)
|
||||
verify { template.postForObject(url, body, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class RestOperationsExtensionsTests {
|
|||
val url = "https://spring.io"
|
||||
val body: Any = "body"
|
||||
every { template.postForObject(url, body, Foo::class.java) } returns foo
|
||||
assertEquals(foo, template.postForObject<Foo>(url, body))
|
||||
assertThat(template.postForObject<Foo>(url, body)).isEqualTo(foo)
|
||||
verify { template.postForObject(url, body, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ class RestOperationsExtensionsTests {
|
|||
fun `postForObject with reified type parameters`() {
|
||||
val url = "https://spring.io"
|
||||
every { template.postForObject(url, null, Foo::class.java) } returns foo
|
||||
assertEquals(foo, template.postForObject<Foo>(url))
|
||||
assertThat(template.postForObject<Foo>(url)).isEqualTo(foo)
|
||||
verify { template.postForObject(url, null, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ class RestOperationsExtensionsTests {
|
|||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
every { template.postForEntity(url, body, Foo::class.java, var1, var2) } returns entity
|
||||
assertEquals(entity, template.postForEntity<Foo>(url, body, var1, var2))
|
||||
assertThat(template.postForEntity<Foo>(url, body, var1, var2)).isEqualTo(entity)
|
||||
verify { template.postForEntity(url, body, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ class RestOperationsExtensionsTests {
|
|||
val body: Any = "body"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
every { template.postForEntity(url, body, Foo::class.java, vars) } returns entity
|
||||
assertEquals(entity, template.postForEntity<Foo>(url, body, vars))
|
||||
assertThat(template.postForEntity<Foo>(url, body, vars)).isEqualTo(entity)
|
||||
verify { template.postForEntity(url, body, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ class RestOperationsExtensionsTests {
|
|||
val url = "https://spring.io"
|
||||
val body: Any = "body"
|
||||
every { template.postForEntity(url, body, Foo::class.java) } returns entity
|
||||
assertEquals(entity, template.postForEntity<Foo>(url, body))
|
||||
assertThat(template.postForEntity<Foo>(url, body)).isEqualTo(entity)
|
||||
verify { template.postForEntity(url, body, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ class RestOperationsExtensionsTests {
|
|||
fun `postForEntity with reified type parameters`() {
|
||||
val url = "https://spring.io"
|
||||
every { template.postForEntity(url, null, Foo::class.java) } returns entity
|
||||
assertEquals(entity, template.postForEntity<Foo>(url))
|
||||
assertThat(template.postForEntity<Foo>(url)).isEqualTo(entity)
|
||||
verify { template.postForEntity(url, null, Foo::class.java) }
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ class RestOperationsExtensionsTests {
|
|||
val entityList = mockk<ResponseEntity<List<Foo>>>()
|
||||
val responseType = object : ParameterizedTypeReference<List<Foo>>() {}
|
||||
every { template.exchange(url, method, entity, responseType, var1, var2) } returns entityList
|
||||
assertEquals(entityList, template.exchange<List<Foo>>(url, method, entity, var1, var2))
|
||||
assertThat(template.exchange<List<Foo>>(url, method, entity, var1, var2)).isEqualTo(entityList)
|
||||
verify { template.exchange(url, method, entity, responseType, var1, var2) }
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ class RestOperationsExtensionsTests {
|
|||
val entityList = mockk<ResponseEntity<List<Foo>>>()
|
||||
val responseType = object : ParameterizedTypeReference<List<Foo>>() {}
|
||||
every { template.exchange(url, method, entity, responseType, vars) } returns entityList
|
||||
assertEquals(entityList, template.exchange<List<Foo>>(url, method, entity, vars))
|
||||
assertThat(template.exchange<List<Foo>>(url, method, entity, vars)).isEqualTo(entityList)
|
||||
verify { template.exchange(url, method, entity, responseType, vars) }
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ class RestOperationsExtensionsTests {
|
|||
val entityList = mockk<ResponseEntity<List<Foo>>>()
|
||||
val responseType = object : ParameterizedTypeReference<List<Foo>>() {}
|
||||
every { template.exchange(url, method, entity, responseType) } returns entityList
|
||||
assertEquals(entityList, template.exchange<List<Foo>>(url, method, entity))
|
||||
assertThat(template.exchange<List<Foo>>(url, method, entity)).isEqualTo(entityList)
|
||||
verify { template.exchange(url, method, entity, responseType) }
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ class RestOperationsExtensionsTests {
|
|||
val entityList = mockk<ResponseEntity<List<Foo>>>()
|
||||
val responseType = object : ParameterizedTypeReference<List<Foo>>() {}
|
||||
every { template.exchange(url, method, null, responseType) } returns entityList
|
||||
assertEquals(entityList, template.exchange<List<Foo>>(url, method))
|
||||
assertThat(template.exchange<List<Foo>>(url, method)).isEqualTo(entityList)
|
||||
verify { template.exchange(url, method, null, responseType) }
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ class RestOperationsExtensionsTests {
|
|||
val entityList = mockk<ResponseEntity<List<Foo>>>()
|
||||
val responseType = object : ParameterizedTypeReference<List<Foo>>() {}
|
||||
every { template.exchange(entity, responseType) } returns entityList
|
||||
assertEquals(entityList, template.exchange<List<Foo>>(entity))
|
||||
assertThat(template.exchange<List<Foo>>(entity)).isEqualTo(entityList)
|
||||
verify { template.exchange(entity, responseType) }
|
||||
}
|
||||
|
||||
|
@ -276,9 +276,8 @@ class RestOperationsExtensionsTests {
|
|||
if (method.parameterTypes.contains(kClass.java)) {
|
||||
val parameters = mutableListOf<Class<*>>(RestOperations::class.java).apply { addAll(method.parameterTypes.filter { it != kClass.java }) }
|
||||
val f = extensions.getDeclaredMethod(method.name, *parameters.toTypedArray()).kotlinFunction!!
|
||||
assertEquals(1, f.typeParameters.size)
|
||||
System.out.println(method.name + f.typeParameters)
|
||||
assertEquals(listOf(Any::class.createType(nullable = true)), f.typeParameters[0].upperBounds, "Failed: " + method.name)
|
||||
assertThat(f.typeParameters.size).isEqualTo(1)
|
||||
assertThat(f.typeParameters[0].upperBounds).isEqualTo(listOf(Any::class.createType(nullable = true)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.springframework.web.method.annotation
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.MethodParameter
|
||||
|
@ -94,43 +94,39 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
fun resolveNullableRequiredWithParameter() {
|
||||
request.addParameter("name", "123")
|
||||
var result = resolver.resolveArgument(nullableParamRequired, null, webRequest, binderFactory)
|
||||
assertEquals("123", result)
|
||||
assertThat(result).isEqualTo("123")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveNullableRequiredWithoutParameter() {
|
||||
var result = resolver.resolveArgument(nullableParamRequired, null, webRequest, binderFactory)
|
||||
assertNull(result)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveNullableNotRequiredWithParameter() {
|
||||
request.addParameter("name", "123")
|
||||
var result = resolver.resolveArgument(nullableParamNotRequired, null, webRequest, binderFactory)
|
||||
assertEquals("123", result)
|
||||
assertThat(result).isEqualTo("123")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveNullableNotRequiredWithoutParameter() {
|
||||
var result = resolver.resolveArgument(nullableParamNotRequired, null, webRequest, binderFactory)
|
||||
assertNull(result)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveNonNullableRequiredWithParameter() {
|
||||
request.addParameter("name", "123")
|
||||
var result = resolver.resolveArgument(nonNullableParamRequired, null, webRequest, binderFactory)
|
||||
assertEquals("123", result)
|
||||
assertThat(result).isEqualTo("123")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveNonNullableRequiredWithoutParameter() {
|
||||
try {
|
||||
assertThatExceptionOfType(MissingServletRequestParameterException::class.java).isThrownBy {
|
||||
resolver.resolveArgument(nonNullableParamRequired, null, webRequest, binderFactory)
|
||||
fail("should have thrown a MissingServletRequestParameterException")
|
||||
}
|
||||
catch (e: MissingServletRequestParameterException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,17 +134,13 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
fun resolveNonNullableNotRequiredWithParameter() {
|
||||
request.addParameter("name", "123")
|
||||
var result = resolver.resolveArgument(nonNullableParamNotRequired, null, webRequest, binderFactory)
|
||||
assertEquals("123", result)
|
||||
assertThat(result).isEqualTo("123")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveNonNullableNotRequiredWithoutParameter() {
|
||||
try {
|
||||
assertThatExceptionOfType(TypeCastException::class.java).isThrownBy {
|
||||
resolver.resolveArgument(nonNullableParamNotRequired, null, webRequest, binderFactory) as String
|
||||
fail("should have thrown a TypeCastException")
|
||||
}
|
||||
catch (e: TypeCastException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +152,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
webRequest = ServletWebRequest(request)
|
||||
|
||||
var result = resolver.resolveArgument(nullableMultipartParamRequired, null, webRequest, binderFactory)
|
||||
assertEquals(expected, result)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -169,7 +161,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
var result = resolver.resolveArgument(nullableMultipartParamRequired, null, webRequest, binderFactory)
|
||||
assertNull(result)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -180,7 +172,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
webRequest = ServletWebRequest(request)
|
||||
|
||||
var result = resolver.resolveArgument(nullableMultipartParamNotRequired, null, webRequest, binderFactory)
|
||||
assertEquals(expected, result)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -189,7 +181,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
var result = resolver.resolveArgument(nullableMultipartParamNotRequired, null, webRequest, binderFactory)
|
||||
assertNull(result)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -200,7 +192,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
webRequest = ServletWebRequest(request)
|
||||
|
||||
var result = resolver.resolveArgument(nonNullableMultipartParamRequired, null, webRequest, binderFactory)
|
||||
assertEquals(expected, result)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -208,12 +200,8 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
request.method = HttpMethod.POST.name
|
||||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
try {
|
||||
assertThatExceptionOfType(MissingServletRequestPartException::class.java).isThrownBy {
|
||||
resolver.resolveArgument(nonNullableMultipartParamRequired, null, webRequest, binderFactory)
|
||||
fail("should have thrown a MissingServletRequestPartException")
|
||||
}
|
||||
catch (e: MissingServletRequestPartException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +213,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
webRequest = ServletWebRequest(request)
|
||||
|
||||
var result = resolver.resolveArgument(nonNullableMultipartParamNotRequired, null, webRequest, binderFactory)
|
||||
assertEquals(expected, result)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -233,12 +221,8 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
|||
request.method = HttpMethod.POST.name
|
||||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
try {
|
||||
assertThatExceptionOfType(TypeCastException::class.java).isThrownBy {
|
||||
resolver.resolveArgument(nonNullableMultipartParamNotRequired, null, webRequest, binderFactory) as MultipartFile
|
||||
fail("should have thrown a TypeCastException")
|
||||
}
|
||||
catch (e: TypeCastException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@ import io.mockk.mockk
|
|||
import io.mockk.verify
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.HttpStatus
|
||||
|
@ -74,7 +73,7 @@ class ClientResponseExtensionsTests {
|
|||
val response = mockk<ClientResponse>()
|
||||
every { response.bodyToMono<String>() } returns Mono.just("foo")
|
||||
runBlocking {
|
||||
assertEquals("foo", response.awaitBody<String>())
|
||||
assertThat(response.awaitBody<String>()).isEqualTo("foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +82,7 @@ class ClientResponseExtensionsTests {
|
|||
val response = mockk<ClientResponse>()
|
||||
every { response.bodyToMono<String>() } returns Mono.empty()
|
||||
runBlocking {
|
||||
assertNull(response.awaitBodyOrNull<String>())
|
||||
assertThat(response.awaitBodyOrNull<String>()).isNull()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +92,7 @@ class ClientResponseExtensionsTests {
|
|||
val entity = ResponseEntity("foo", HttpStatus.OK)
|
||||
every { response.toEntity<String>() } returns Mono.just(entity)
|
||||
runBlocking {
|
||||
assertEquals(entity, response.awaitEntity<String>())
|
||||
assertThat(response.awaitEntity<String>()).isEqualTo(entity)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,7 @@ class ClientResponseExtensionsTests {
|
|||
val entity = ResponseEntity(listOf("foo"), HttpStatus.OK)
|
||||
every { response.toEntityList<String>() } returns Mono.just(entity)
|
||||
runBlocking {
|
||||
assertEquals(entity, response.awaitEntityList<String>())
|
||||
assertThat(response.awaitEntityList<String>()).isEqualTo(entity)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import io.mockk.verify
|
|||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
|
@ -86,7 +86,7 @@ class WebClientExtensionsTests {
|
|||
val response = mockk<ClientResponse>()
|
||||
every { requestBodySpec.exchange() } returns Mono.just(response)
|
||||
runBlocking {
|
||||
assertEquals(response, requestBodySpec.awaitExchange())
|
||||
assertThat(requestBodySpec.awaitExchange()).isEqualTo(response)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ class WebClientExtensionsTests {
|
|||
val spec = mockk<WebClient.ResponseSpec>()
|
||||
every { spec.bodyToMono<String>() } returns Mono.just("foo")
|
||||
runBlocking {
|
||||
assertEquals("foo", spec.awaitBody<String>())
|
||||
assertThat(spec.awaitBody<String>()).isEqualTo("foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.springframework.web.reactive.function.server
|
||||
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.springframework.core.io.ClassPathResource
|
||||
import org.springframework.http.HttpHeaders.*
|
||||
import org.springframework.http.HttpMethod.*
|
||||
|
@ -122,12 +124,8 @@ class CoRouterFunctionDslTests {
|
|||
|
||||
@Test
|
||||
fun emptyRouter() {
|
||||
try {
|
||||
assertThatExceptionOfType(IllegalStateException::class.java).isThrownBy {
|
||||
router { }
|
||||
fail("should have thrown an IllegalStateException")
|
||||
}
|
||||
catch (e: IllegalStateException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.springframework.web.reactive.function.server
|
||||
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.springframework.core.io.ClassPathResource
|
||||
import org.springframework.http.HttpHeaders.*
|
||||
import org.springframework.http.HttpMethod.*
|
||||
|
@ -123,12 +125,8 @@ class RouterFunctionDslTests {
|
|||
|
||||
@Test
|
||||
fun emptyRouter() {
|
||||
try {
|
||||
assertThatExceptionOfType(IllegalStateException::class.java).isThrownBy {
|
||||
router { }
|
||||
fail("should have thrown an IllegalStateException")
|
||||
}
|
||||
catch (e: IllegalStateException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@ import io.mockk.mockk
|
|||
import io.mockk.verify
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.codec.multipart.Part
|
||||
|
@ -63,7 +62,7 @@ class ServerRequestExtensionsTests {
|
|||
fun awaitBody() {
|
||||
every { request.bodyToMono<String>() } returns Mono.just("foo")
|
||||
runBlocking {
|
||||
assertEquals("foo", request.awaitBody<String>())
|
||||
assertThat(request.awaitBody<String>()).isEqualTo("foo")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ class ServerRequestExtensionsTests {
|
|||
fun awaitBodyOrNull() {
|
||||
every { request.bodyToMono<String>() } returns Mono.empty()
|
||||
runBlocking {
|
||||
assertNull(request.awaitBodyOrNull<String>())
|
||||
assertThat(request.awaitBodyOrNull<String>()).isNull()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +79,7 @@ class ServerRequestExtensionsTests {
|
|||
val map = mockk<MultiValueMap<String, String>>()
|
||||
every { request.formData() } returns Mono.just(map)
|
||||
runBlocking {
|
||||
assertEquals(map, request.awaitFormData())
|
||||
assertThat(request.awaitFormData()).isEqualTo(map)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,7 @@ class ServerRequestExtensionsTests {
|
|||
val map = mockk<MultiValueMap<String, Part>>()
|
||||
every { request.multipartData() } returns Mono.just(map)
|
||||
runBlocking {
|
||||
assertEquals(map, request.awaitMultipartData())
|
||||
assertThat(request.awaitMultipartData()).isEqualTo(map)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +97,7 @@ class ServerRequestExtensionsTests {
|
|||
val principal = mockk<Principal>()
|
||||
every { request.principal() } returns Mono.just(principal)
|
||||
runBlocking {
|
||||
assertEquals(principal, request.awaitPrincipal())
|
||||
assertThat(request.awaitPrincipal()).isEqualTo(principal)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +106,7 @@ class ServerRequestExtensionsTests {
|
|||
val session = mockk<WebSession>()
|
||||
every { request.session() } returns Mono.just(session)
|
||||
runBlocking {
|
||||
assertEquals(session, request.awaitSession())
|
||||
assertThat(request.awaitSession()).isEqualTo(session)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import io.reactivex.Flowable
|
|||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
|
@ -145,7 +145,7 @@ class ServerResponseExtensionsTests {
|
|||
val builder = mockk<ServerResponse.HeadersBuilder<*>>()
|
||||
every { builder.build() } returns Mono.just(response)
|
||||
runBlocking {
|
||||
assertEquals(response, builder.buildAndAwait())
|
||||
assertThat(builder.buildAndAwait()).isEqualTo(response)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,7 @@ package org.springframework.web.reactive.result
|
|||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.delay
|
||||
import org.hamcrest.CoreMatchers.`is`
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse
|
||||
|
@ -83,7 +81,7 @@ class KotlinInvocableHandlerMethodTests {
|
|||
val result = invoke(CoroutinesController(), method)
|
||||
|
||||
assertHandlerResultValue(result, "created")
|
||||
assertThat<HttpStatus>(this.exchange.response.statusCode, `is`(HttpStatus.CREATED))
|
||||
assertThat(this.exchange.response.statusCode).isSameAs(HttpStatus.CREATED)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -96,7 +94,7 @@ class KotlinInvocableHandlerMethodTests {
|
|||
StepVerifier.create(result)
|
||||
.consumeNextWith { StepVerifier.create(it.returnValue as Mono<*>).verifyComplete() }
|
||||
.verifyComplete()
|
||||
assertEquals("bar", this.exchange.response.headers.getFirst("foo"))
|
||||
assertThat(this.exchange.response.headers.getFirst("foo")).isEqualTo("bar")
|
||||
}
|
||||
|
||||
private fun invoke(handler: Any, method: Method, vararg providedArgs: Any?): Mono<HandlerResult> {
|
||||
|
|
|
@ -17,14 +17,12 @@
|
|||
package org.springframework.web.reactive.result.method.annotation
|
||||
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.springframework.context.ApplicationContext
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
@ -37,7 +35,6 @@ import org.springframework.web.bind.annotation.RestController
|
|||
import org.springframework.web.client.HttpServerErrorException
|
||||
import org.springframework.web.reactive.config.EnableWebFlux
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
|
||||
|
||||
override fun initApplicationContext(): ApplicationContext {
|
||||
|
@ -53,8 +50,8 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
|
|||
startServer(httpServer)
|
||||
|
||||
val entity = performGet<String>("/suspend", HttpHeaders.EMPTY, String::class.java)
|
||||
assertEquals(HttpStatus.OK, entity.statusCode)
|
||||
assertEquals("foo", entity.body)
|
||||
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
|
||||
assertThat(entity.body).isEqualTo("foo")
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
|
@ -62,8 +59,8 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
|
|||
startServer(httpServer)
|
||||
|
||||
val entity = performGet<String>("/deferred", HttpHeaders.EMPTY, String::class.java)
|
||||
assertEquals(HttpStatus.OK, entity.statusCode)
|
||||
assertEquals("foo", entity.body)
|
||||
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
|
||||
assertThat(entity.body).isEqualTo("foo")
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
|
@ -71,8 +68,8 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
|
|||
startServer(httpServer)
|
||||
|
||||
val entity = performGet<String>("/flow", HttpHeaders.EMPTY, String::class.java)
|
||||
assertEquals(HttpStatus.OK, entity.statusCode)
|
||||
assertEquals("foobar", entity.body)
|
||||
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
|
||||
assertThat(entity.body).isEqualTo("foobar")
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
|
@ -80,19 +77,16 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
|
|||
startServer(httpServer)
|
||||
|
||||
val entity = performGet<String>("/suspending-flow", HttpHeaders.EMPTY, String::class.java)
|
||||
assertEquals(HttpStatus.OK, entity.statusCode)
|
||||
assertEquals("foobar", entity.body)
|
||||
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
|
||||
assertThat(entity.body).isEqualTo("foobar")
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
fun `Suspending handler method throwing exception`(httpServer: HttpServer) {
|
||||
startServer(httpServer)
|
||||
|
||||
try {
|
||||
assertThatExceptionOfType(HttpServerErrorException.InternalServerError::class.java).isThrownBy {
|
||||
performGet<String>("/error", HttpHeaders.EMPTY, String::class.java)
|
||||
fail("should have thrown an HttpServerErrorException.InternalServerError")
|
||||
} catch (e: HttpServerErrorException.InternalServerError) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,11 +94,8 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
|
|||
fun `Handler method returning Flow throwing exception`(httpServer: HttpServer) {
|
||||
startServer(httpServer)
|
||||
|
||||
try {
|
||||
assertThatExceptionOfType(HttpServerErrorException.InternalServerError::class.java).isThrownBy {
|
||||
performGet<String>("/flow-error", HttpHeaders.EMPTY, String::class.java)
|
||||
fail("should have thrown an HttpServerErrorException.InternalServerError")
|
||||
} catch (e: HttpServerErrorException.InternalServerError) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
package org.springframework.web.servlet.function
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.io.ClassPathResource
|
||||
import org.springframework.http.HttpHeaders.*
|
||||
|
@ -38,7 +36,7 @@ class RouterFunctionDslTests {
|
|||
val servletRequest = MockHttpServletRequest()
|
||||
servletRequest.addHeader("bar", "bar")
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -46,7 +44,7 @@ class RouterFunctionDslTests {
|
|||
val servletRequest = MockHttpServletRequest("GET", "/content")
|
||||
servletRequest.addHeader(ACCEPT, APPLICATION_ATOM_XML_VALUE)
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -54,7 +52,7 @@ class RouterFunctionDslTests {
|
|||
val servletRequest = MockHttpServletRequest("POST", "/api/foo/")
|
||||
servletRequest.addHeader(ACCEPT, APPLICATION_JSON_VALUE)
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -62,35 +60,35 @@ class RouterFunctionDslTests {
|
|||
val servletRequest = MockHttpServletRequest("GET", "/content")
|
||||
servletRequest.addHeader(CONTENT_TYPE, APPLICATION_OCTET_STREAM_VALUE)
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resourceByPath() {
|
||||
val servletRequest = MockHttpServletRequest("GET", "/org/springframework/web/servlet/function/response.txt")
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun method() {
|
||||
val servletRequest = MockHttpServletRequest("PATCH", "/")
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun path() {
|
||||
val servletRequest = MockHttpServletRequest("GET", "/baz")
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resource() {
|
||||
val servletRequest = MockHttpServletRequest("GET", "/response.txt")
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -100,24 +98,20 @@ class RouterFunctionDslTests {
|
|||
servletRequest.addHeader(ACCEPT, APPLICATION_PDF_VALUE)
|
||||
servletRequest.addHeader(CONTENT_TYPE, APPLICATION_PDF_VALUE)
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertFalse(sampleRouter().route(request).isPresent)
|
||||
assertThat(sampleRouter().route(request).isPresent).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rendering() {
|
||||
val servletRequest = MockHttpServletRequest("GET", "/rendering")
|
||||
val request = DefaultServerRequest(servletRequest, emptyList())
|
||||
assertTrue(sampleRouter().route(request).get().handle(request) is RenderingResponse)
|
||||
assertThat(sampleRouter().route(request).get().handle(request) is RenderingResponse).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun emptyRouter() {
|
||||
try {
|
||||
assertThatExceptionOfType(IllegalStateException::class.java).isThrownBy {
|
||||
router { }
|
||||
fail("should have thrown an IllegalStateException")
|
||||
}
|
||||
catch (e: IllegalStateException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ package org.springframework.web.servlet.function
|
|||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.MediaType
|
||||
|
@ -43,23 +42,23 @@ class ServerRequestExtensionsTests {
|
|||
fun `remoteAddressOrNull with value`() {
|
||||
val remoteAddress = mockk<InetSocketAddress>()
|
||||
every { request.remoteAddress() } returns Optional.of(remoteAddress)
|
||||
assertEquals(remoteAddress, request.remoteAddressOrNull())
|
||||
assertThat(remoteAddress).isEqualTo(request.remoteAddressOrNull())
|
||||
verify { request.remoteAddress() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `remoteAddressOrNull with null`() {
|
||||
every { request.remoteAddress() } returns Optional.empty()
|
||||
assertNull(request.remoteAddressOrNull())
|
||||
assertThat(request.remoteAddressOrNull()).isNull()
|
||||
verify { request.remoteAddress() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun body() {
|
||||
val body = Arrays.asList("foo", "bar")
|
||||
val body = listOf("foo", "bar")
|
||||
val typeReference = object: ParameterizedTypeReference<List<String>>() {}
|
||||
every { request.body(typeReference) } returns body
|
||||
assertEquals(body, request.body<List<String>>())
|
||||
assertThat(request.body<List<String>>()).isEqualTo(body)
|
||||
verify { request.body(typeReference) }
|
||||
}
|
||||
|
||||
|
@ -67,14 +66,14 @@ class ServerRequestExtensionsTests {
|
|||
fun `attributeOrNull with value`() {
|
||||
val attribute = mockk<Any>()
|
||||
every { request.attribute("foo") } returns Optional.of(attribute)
|
||||
assertEquals(attribute, request.attributeOrNull("foo"))
|
||||
assertThat(request.attributeOrNull("foo")).isEqualTo(attribute)
|
||||
verify { request.attribute("foo") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `attributeOrNull with null`() {
|
||||
every { request.attribute("foo") } returns Optional.empty()
|
||||
assertNull(request.attributeOrNull("foo"))
|
||||
assertThat(request.attributeOrNull("foo")).isNull()
|
||||
verify { request.attribute("foo") }
|
||||
}
|
||||
|
||||
|
@ -82,14 +81,14 @@ class ServerRequestExtensionsTests {
|
|||
fun `paramOrNull with value`() {
|
||||
val param = "bar"
|
||||
every { request.param("foo") } returns Optional.of(param)
|
||||
assertEquals(param, request.paramOrNull("foo"))
|
||||
assertThat(request.paramOrNull("foo")).isEqualTo(param)
|
||||
verify { request.param("foo") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `paramOrNull with null`() {
|
||||
every { request.param("foo") } returns Optional.empty()
|
||||
assertNull(request.paramOrNull("foo"))
|
||||
assertThat(request.paramOrNull("foo")).isNull()
|
||||
verify { request.param("foo") }
|
||||
}
|
||||
|
||||
|
@ -97,14 +96,14 @@ class ServerRequestExtensionsTests {
|
|||
fun `principalOrNull with value`() {
|
||||
val principal = mockk<Principal>()
|
||||
every { request.principal() } returns Optional.of(principal)
|
||||
assertEquals(principal, request.principalOrNull())
|
||||
assertThat(request.principalOrNull()).isEqualTo(principal)
|
||||
verify { request.principal() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `principalOrNull with null`() {
|
||||
every { request.principal() } returns Optional.empty()
|
||||
assertNull(request.principalOrNull())
|
||||
assertThat(request.principalOrNull()).isNull()
|
||||
verify { request.principal() }
|
||||
}
|
||||
|
||||
|
@ -112,14 +111,14 @@ class ServerRequestExtensionsTests {
|
|||
fun `contentLengthOrNull with value`() {
|
||||
val contentLength: Long = 123
|
||||
every { headers.contentLength() } returns OptionalLong.of(contentLength)
|
||||
assertEquals(contentLength, headers.contentLengthOrNull())
|
||||
assertThat(headers.contentLengthOrNull()).isEqualTo(contentLength)
|
||||
verify { headers.contentLength() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `contentLengthOrNull with null`() {
|
||||
every { headers.contentLength() } returns OptionalLong.empty()
|
||||
assertNull(headers.contentLengthOrNull())
|
||||
assertThat(headers.contentLengthOrNull()).isNull()
|
||||
verify { headers.contentLength() }
|
||||
}
|
||||
|
||||
|
@ -127,14 +126,14 @@ class ServerRequestExtensionsTests {
|
|||
fun `contentTypeOrNull with value`() {
|
||||
val contentType = mockk<MediaType>()
|
||||
every { headers.contentType() } returns Optional.of(contentType)
|
||||
assertEquals(contentType, headers.contentTypeOrNull())
|
||||
assertThat(headers.contentTypeOrNull()).isEqualTo(contentType)
|
||||
verify { headers.contentType() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `contentTypeOrNull with null`() {
|
||||
every { headers.contentType() } returns Optional.empty()
|
||||
assertNull(headers.contentTypeOrNull())
|
||||
assertThat(headers.contentTypeOrNull()).isNull()
|
||||
verify { headers.contentType() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@ package org.springframework.web.servlet.function
|
|||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
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.
|
||||
|
@ -35,10 +34,10 @@ class ServerResponseExtensionsTests {
|
|||
fun bodyWithType() {
|
||||
val builder = mockk<ServerResponse.BodyBuilder>()
|
||||
val response = mockk<ServerResponse>()
|
||||
val body = Arrays.asList("foo", "bar")
|
||||
val body = listOf("foo", "bar")
|
||||
val typeReference = object: ParameterizedTypeReference<List<String>>() {}
|
||||
every { builder.body(body, typeReference) } returns response
|
||||
assertEquals(response, builder.bodyWithType<List<String>>(body))
|
||||
assertThat(builder.bodyWithType<List<String>>(body)).isEqualTo(response)
|
||||
verify { builder.body(body, typeReference) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.web.servlet.mvc.method.annotation
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse
|
||||
|
@ -37,7 +37,7 @@ class ServletAnnotationControllerHandlerMethodKotlinTests : AbstractServletHandl
|
|||
request.addParameter("param2", "2")
|
||||
val response = MockHttpServletResponse()
|
||||
servlet.service(request, response)
|
||||
assertEquals("value1-2", response.contentAsString)
|
||||
assertThat(response.contentAsString).isEqualTo("value1-2")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -49,7 +49,7 @@ class ServletAnnotationControllerHandlerMethodKotlinTests : AbstractServletHandl
|
|||
request.addParameter("param2", "2")
|
||||
val response = MockHttpServletResponse()
|
||||
servlet.service(request, response)
|
||||
assertEquals("value1-2", response.contentAsString)
|
||||
assertThat(response.contentAsString).isEqualTo("value1-2")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,7 +60,7 @@ class ServletAnnotationControllerHandlerMethodKotlinTests : AbstractServletHandl
|
|||
request.addParameter("param1", "value1")
|
||||
val response = MockHttpServletResponse()
|
||||
servlet.service(request, response)
|
||||
assertEquals("value1-12", response.contentAsString)
|
||||
assertThat(response.contentAsString).isEqualTo("value1-12")
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue