Add comprehensive tests of Kotlin extensions
This commit also removes extensions hidden by Java API (varargs).
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package org.springframework.context.annotation
|
||||
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Test
|
||||
import org.springframework.beans.factory.getBean
|
||||
import org.springframework.context.support.registerBean
|
||||
|
||||
/**
|
||||
* Tests for [AnnotationConfigApplicationContext] Kotlin extensions
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class AnnotationConfigApplicationContextExtensionsTests {
|
||||
|
||||
@Test
|
||||
fun `Instantiate AnnotationConfigApplicationContext`() {
|
||||
val applicationContext = AnnotationConfigApplicationContext {
|
||||
registerBean<Foo>()
|
||||
}
|
||||
applicationContext.refresh()
|
||||
assertNotNull(applicationContext)
|
||||
assertNotNull(applicationContext.getBean<Foo>())
|
||||
}
|
||||
|
||||
class Foo
|
||||
}
|
||||
@@ -4,6 +4,11 @@ import org.junit.Assert.assertNotNull
|
||||
import org.junit.Test
|
||||
import org.springframework.beans.factory.getBean
|
||||
|
||||
/**
|
||||
* Tests for [GenericApplicationContext] Kotlin extensions
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class GenericApplicationContextExtensionsTests {
|
||||
|
||||
@Test
|
||||
@@ -69,8 +74,8 @@ class GenericApplicationContextExtensionsTests {
|
||||
assertNotNull(context.getBean<BeanB>())
|
||||
}
|
||||
|
||||
internal class BeanA
|
||||
class BeanA
|
||||
|
||||
internal class BeanB(val a: BeanA)
|
||||
class BeanB(val a: BeanA)
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,11 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
/**
|
||||
* Tests for [Model] Kotlin extensions
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class ModelExtensionsTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,6 +21,11 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
/**
|
||||
* Tests for [ModelMap] Kotlin extensions
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class ModelMapExtensionsTests {
|
||||
|
||||
@Test
|
||||
@@ -30,4 +35,5 @@ class ModelMapExtensionsTests {
|
||||
assertTrue(model.containsAttribute("foo"))
|
||||
assertEquals("bing", model["foo"])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user