BDF2 集成 JUNIT

BDF2 集成 JUNIT启动配置怎么设置
已邀请:

icecoffer

赞同来自:

参照官网例子可以实现dorado7的单元测试
但是BDF2无法实现,提示类型转换错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.urlMaintain': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bstek.bdf2.core.view.frame.main.MainFrame com.bstek.bdf2.core.view.url.UrlMaintain.mainFrame; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.mainFrame' defined in class path resource [com/bstek/bdf2/core/config/bdf2-core-configs.xml]: Cannot resolve reference to bean 'bdf2.applicationCache' while setting bean property 'applicationCache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.contextHolder' defined in class path resource [com/bstek/bdf2/core/orm/config/bdf2-orm-configs.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.context.support.GenericXmlApplicationContext cannot be cast to org.springframework.web.context.WebApplicationContext
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at com.bstek.dorado.core.SpringApplicationContext.getApplicationContext(SpringApplicationContext.java:126)
at com.bstek.dorado.core.SpringApplicationContext.initApplicationContext(SpringApplicationContext.java:93)
at com.wb.test.core.MockContext.init(MockContext.java:13)
at com.wb.test.SampleTest.setUp(SampleTest.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bstek.bdf2.core.view.frame.main.MainFrame com.bstek.bdf2.core.view.url.UrlMaintain.mainFrame; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.mainFrame' defined in class path resource [com/bstek/bdf2/core/config/bdf2-core-configs.xml]: Cannot resolve reference to bean 'bdf2.applicationCache' while setting bean property 'applicationCache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.contextHolder' defined in class path resource [com/bstek/bdf2/core/orm/config/bdf2-orm-configs.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.context.support.GenericXmlApplicationContext cannot be cast to org.springframework.web.context.WebApplicationContext
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.mainFrame' defined in class path resource [com/bstek/bdf2/core/config/bdf2-core-configs.xml]: Cannot resolve reference to bean 'bdf2.applicationCache' while setting bean property 'applicationCache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.contextHolder' defined in class path resource [com/bstek/bdf2/core/orm/config/bdf2-orm-configs.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.context.support.GenericXmlApplicationContext cannot be cast to org.springframework.web.context.WebApplicationContext
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 40 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bdf2.contextHolder' defined in class path resource [com/bstek/bdf2/core/orm/config/bdf2-orm-configs.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.context.support.GenericXmlApplicationContext cannot be cast to org.springframework.web.context.WebApplicationContext
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
... 53 more
Caused by: java.lang.ClassCastException: org.springframework.context.support.GenericXmlApplicationContext cannot be cast to org.springframework.web.context.WebApplicationContext
at com.bstek.bdf2.core.context.ContextHolder.setApplicationContext(ContextHolder.java:63)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 61 more


要回复问题请先登录注册