Polishing
This commit is contained in:
@@ -4,8 +4,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
/**
|
||||
@@ -16,43 +15,43 @@ import org.mockito.junit.MockitoJUnitRunner
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class BeanFactoryExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var bf: BeanFactory
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var bf: BeanFactory
|
||||
|
||||
@Test
|
||||
fun `getBean with KClass`() {
|
||||
bf.getBean(Foo::class)
|
||||
verify(bf, Mockito.times(1)).getBean(Foo::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBean with KClass`() {
|
||||
bf.getBean(Foo::class)
|
||||
verify(bf, times(1)).getBean(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBean with reified type parameters`() {
|
||||
bf.getBean<Foo>()
|
||||
verify(bf, Mockito.times(1)).getBean(Foo::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBean with reified type parameters`() {
|
||||
bf.getBean<Foo>()
|
||||
verify(bf, times(1)).getBean(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBean with String and reified type parameters`() {
|
||||
val name = "foo"
|
||||
bf.getBean<Foo>(name)
|
||||
verify(bf, Mockito.times(1)).getBean(name, Foo::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBean with String and reified type parameters`() {
|
||||
val name = "foo"
|
||||
bf.getBean<Foo>(name)
|
||||
verify(bf, times(1)).getBean(name, Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBean with KClass and varargs`() {
|
||||
val arg1 = "arg1"
|
||||
val arg2 = "arg2"
|
||||
bf.getBean(Foo::class, arg1, arg2)
|
||||
verify(bf, Mockito.times(1)).getBean(Foo::class.java, arg1, arg2)
|
||||
}
|
||||
@Test
|
||||
fun `getBean with KClass and varargs`() {
|
||||
val arg1 = "arg1"
|
||||
val arg2 = "arg2"
|
||||
bf.getBean(Foo::class, arg1, arg2)
|
||||
verify(bf, times(1)).getBean(Foo::class.java, arg1, arg2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBean with reified type parameters and varargs`() {
|
||||
val arg1 = "arg1"
|
||||
val arg2 = "arg2"
|
||||
bf.getBean<Foo>(arg1, arg2)
|
||||
verify(bf, Mockito.times(1)).getBean(Foo::class.java, arg1, arg2)
|
||||
}
|
||||
@Test
|
||||
fun `getBean with reified type parameters and varargs`() {
|
||||
val arg1 = "arg1"
|
||||
val arg2 = "arg2"
|
||||
bf.getBean<Foo>(arg1, arg2)
|
||||
verify(bf, times(1)).getBean(Foo::class.java, arg1, arg2)
|
||||
}
|
||||
|
||||
class Foo
|
||||
class Foo
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
/**
|
||||
@@ -13,122 +13,122 @@ import org.mockito.junit.MockitoJUnitRunner
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class ListenableBeanFactoryExtensionsTests {
|
||||
class ListableBeanFactoryExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var lbf: ListableBeanFactory
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var lbf: ListableBeanFactory
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with KClass`() {
|
||||
lbf.getBeanNamesForType(Foo::class)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, true , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForType with KClass`() {
|
||||
lbf.getBeanNamesForType(Foo::class)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, true , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with KClass and Boolean`() {
|
||||
lbf.getBeanNamesForType(Foo::class, false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForType with KClass and Boolean`() {
|
||||
lbf.getBeanNamesForType(Foo::class, false)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with KClass, Boolean and Boolean`() {
|
||||
lbf.getBeanNamesForType(Foo::class, false, false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , false)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForType with KClass, Boolean and Boolean`() {
|
||||
lbf.getBeanNamesForType(Foo::class, false, false)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters`() {
|
||||
lbf.getBeanNamesForType<Foo>()
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, true , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters`() {
|
||||
lbf.getBeanNamesForType<Foo>()
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, true , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters and Boolean`() {
|
||||
lbf.getBeanNamesForType<Foo>(false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters and Boolean`() {
|
||||
lbf.getBeanNamesForType<Foo>(false)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters, Boolean and Boolean`() {
|
||||
lbf.getBeanNamesForType<Foo>(false, false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForType(Foo::class.java, false , false)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters, Boolean and Boolean`() {
|
||||
lbf.getBeanNamesForType<Foo>(false, false)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with KClass`() {
|
||||
lbf.getBeansOfType(Foo::class)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, true , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansOfType with KClass`() {
|
||||
lbf.getBeansOfType(Foo::class)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, true , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with KClass and Boolean`() {
|
||||
lbf.getBeansOfType(Foo::class, false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansOfType with KClass and Boolean`() {
|
||||
lbf.getBeansOfType(Foo::class, false)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with KClass, Boolean and Boolean`() {
|
||||
lbf.getBeansOfType(Foo::class, false, false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , false)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansOfType with KClass, Boolean and Boolean`() {
|
||||
lbf.getBeansOfType(Foo::class, false, false)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters`() {
|
||||
lbf.getBeansOfType<Foo>()
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, true , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters`() {
|
||||
lbf.getBeansOfType<Foo>()
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, true , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters and Boolean`() {
|
||||
lbf.getBeansOfType<Foo>(false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , true)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters and Boolean`() {
|
||||
lbf.getBeansOfType<Foo>(false)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters, Boolean and Boolean`() {
|
||||
lbf.getBeansOfType<Foo>(false, false)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansOfType(Foo::class.java, false , false)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters, Boolean and Boolean`() {
|
||||
lbf.getBeansOfType<Foo>(false, false)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForAnnotation with KClass`() {
|
||||
lbf.getBeanNamesForAnnotation(Bar::class)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForAnnotation(Bar::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForAnnotation with KClass`() {
|
||||
lbf.getBeanNamesForAnnotation(Bar::class)
|
||||
verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForAnnotation with reified type parameters`() {
|
||||
lbf.getBeanNamesForAnnotation<Bar>()
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeanNamesForAnnotation(Bar::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBeanNamesForAnnotation with reified type parameters`() {
|
||||
lbf.getBeanNamesForAnnotation<Bar>()
|
||||
verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansWithAnnotation with KClass`() {
|
||||
lbf.getBeansWithAnnotation(Bar::class)
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansWithAnnotation(Bar::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansWithAnnotation with KClass`() {
|
||||
lbf.getBeansWithAnnotation(Bar::class)
|
||||
verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansWithAnnotation with reified type parameters`() {
|
||||
lbf.getBeansWithAnnotation<Bar>()
|
||||
Mockito.verify(lbf, Mockito.times(1)).getBeansWithAnnotation(Bar::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `getBeansWithAnnotation with reified type parameters`() {
|
||||
lbf.getBeansWithAnnotation<Bar>()
|
||||
verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `findAnnotationOnBean with String and KClass`() {
|
||||
val name = "bar"
|
||||
lbf.findAnnotationOnBean(name, Bar::class)
|
||||
Mockito.verify(lbf, Mockito.times(1)).findAnnotationOnBean(name, Bar::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `findAnnotationOnBean with String and KClass`() {
|
||||
val name = "bar"
|
||||
lbf.findAnnotationOnBean(name, Bar::class)
|
||||
verify(lbf, times(1)).findAnnotationOnBean(name, Bar::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `findAnnotationOnBean with String and reified type parameters`() {
|
||||
val name = "bar"
|
||||
lbf.findAnnotationOnBean<Bar>(name)
|
||||
Mockito.verify(lbf, Mockito.times(1)).findAnnotationOnBean(name, Bar::class.java)
|
||||
}
|
||||
@Test
|
||||
fun `findAnnotationOnBean with String and reified type parameters`() {
|
||||
val name = "bar"
|
||||
lbf.findAnnotationOnBean<Bar>(name)
|
||||
verify(lbf, times(1)).findAnnotationOnBean(name, Bar::class.java)
|
||||
}
|
||||
|
||||
class Foo
|
||||
class Foo
|
||||
|
||||
annotation class Bar
|
||||
annotation class Bar
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class KotlinAutowiredTests {
|
||||
bpp.setBeanFactory(bf)
|
||||
bf.addBeanPostProcessor(bpp)
|
||||
var bd = RootBeanDefinition(KotlinBean::class.java)
|
||||
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE)
|
||||
bd.scope = RootBeanDefinition.SCOPE_PROTOTYPE
|
||||
bf.registerBeanDefinition("annotatedBean", bd)
|
||||
var tb = TestBean()
|
||||
bf.registerSingleton("testBean", tb)
|
||||
@@ -56,7 +56,7 @@ class KotlinAutowiredTests {
|
||||
bpp.setBeanFactory(bf)
|
||||
bf.addBeanPostProcessor(bpp)
|
||||
var bd = RootBeanDefinition(KotlinBean::class.java)
|
||||
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE)
|
||||
bd.scope = RootBeanDefinition.SCOPE_PROTOTYPE
|
||||
bf.registerBeanDefinition("annotatedBean", bd)
|
||||
|
||||
var kb = bf.getBean("annotatedBean", KotlinBean::class.java)
|
||||
|
||||
Reference in New Issue
Block a user