Java 如何为集成测试伪造vaadin会话?
假设我有一个自定义注释Java 如何为集成测试伪造vaadin会话?,java,spring,kotlin,vaadin,vaadin8,Java,Spring,Kotlin,Vaadin,Vaadin8,假设我有一个自定义注释 @ViewScope/试一试Karibu测试 它有模拟Vaadin会话的方法,支持V8和V10+,甚至支持Kotlin 玩了一会儿。看起来不错,但尚未成功将其集成到我们的应用程序中。(认为Spring Security在某种程度上进行干扰,但不确定。)将在时机更合适时仔细观察。不过谢谢你。 @RunWith(SpringJUnit4ClassRunner::class) @SpringBootTest @WebAppConfiguration class FooAnno
@ViewScope/试一试Karibu测试
它有模拟Vaadin会话的方法,支持V8和V10+,甚至支持Kotlin 玩了一会儿。看起来不错,但尚未成功将其集成到我们的应用程序中。(认为Spring Security在某种程度上进行干扰,但不确定。)将在时机更合适时仔细观察。不过谢谢你。
@RunWith(SpringJUnit4ClassRunner::class)
@SpringBootTest
@WebAppConfiguration
class FooAnnotationIT{
@Autowired(required = false) //required=false --> empty list instead of exception when none are found
@Foo
val foos:List<Any> = mutableListOf()
@Test
fun `all beans are present`(){
assertThat(foos.size).isEqualTo(5)
}
}
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'blah.blah.blah.FooAnnotationIT': Unsatisfied dependency expressed through field 'foos'
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewCache': Scope 'vaadin-ui' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton
Caused by: java.lang.IllegalStateException: No VaadinSession bound to current thread