This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
While looking at big picture of EJB 3.1 support in NB6.8 I found that lack of generation of unit tests for EJBs is visible drawback. EJB 3.1 introduces concept of embeddable container which is supported by NetBeans Web Project and which primary purpose is to simplify unit testing of EJBs. What does not work right now is that a unit test generated for a class creates testable class via constructor instead of via lookup in case of EJB, that is SinBean instance = new SinBean(); instead of expected SinBean instance = (SinBean)javax.ejb.embeddable.EJBContainer.createEJBContainer().getContext().lookup("java:global/classes/SinBean"); When we tried to resolve this for NB6.8 we discovered that it is quite a lot of work to make unit tests generation pluggable. I tried an alternative to just hardcode the change in JUnit module and attached is patch doing that. I think the patch is quite reasonable to be included in JUnit module and in future it could be refactored when JUnit module is more pluggable. What's your opinion Andrey?
*** Issue 172633 has been marked as a duplicate of this issue. ***
Created attachment 87980 [details] patch
In general I don't like such a solutions because usually the temporary solutions like this lives for years (or forever) and code becomes harder to support. But probably for this particular case it make sense to do it the way you suggested because it's important feature of EE6 and it would be very nice to support it. Just note that "embeddable container" and "global lookup" are supported only by EE6 servers.
I pushed the patch - d649ec71f25f. I changed it to test for presence of "javax.ejb.embeddable.EJBContainer" on classpath and generate EJB lookup code only if EJBContainer is reachable. That should avoid generation of lookup code in non-EJB3.1 projects. While testing this I filed issue 172723 - unit test should not be generated for an interface. In an EJB has local/remote interface then issue 172723 occurs.
Integrated into 'main-golden', will be available in build *200909221401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/d649ec71f25f User: David Konecny <dkonecny@netbeans.org> Log: #172634 - no support for unit testing of EJBs