简体   繁体   中英

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. Is there anyway to manually create a WebServiceContext for testing purposed?

You can use OpenEJB for that. Take a look at this stackoverflow thread:

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.

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.

您还可以在GlassFish Server 3中进行单元测试(它与Java EE 5向后兼容)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM