[英]How do I Unit Test an EJB Webservice (Glassfish v2)?
I am currently having issues because the WebServiceContext is not initialised, obviously because the unit test is not within the EJB container. 我目前遇到问题是因为未初始化WebServiceContext,显然是因为单元测试不在EJB容器内。 Is there anyway to manually create a WebServiceContext for testing purposed?
无论如何,是否有手动创建WebServiceContext进行测试的目的?
I found that actually testing the EJB within a container and making it run properly across platforms and tools (eg code coverage) is quite difficult at best and really slow in terms of execution performance. 我发现,实际上测试容器内的EJB并使其在各种平台和工具(例如代码覆盖率)之间正常运行,在最大程度上是非常困难的,并且在执行性能方面确实很慢。
Rather than executing the unit test in a container, you can focus more on the business logoc side and manually inject the needed components and run the @PostConstruct manually as part of your unit test harness then test your business logic. 与其在容器中执行单元测试,不如将其更多地放在业务徽标方面,并手动注入所需的组件,并在单元测试工具中手动运行@PostConstruct,然后测试您的业务逻辑。
您还可以在GlassFish Server 3中进行单元测试(它与Java EE 5向后兼容)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.