unit testing EJBs with Maven 2 and Glassfish 3

瘦欲@ 提交于 2019-12-02 19:38:49
Pascal Thivent

(...) The standard recommended solution is to add the glassfish-embedded-all artifact as the first project dependency with test scope

Indeed, you need an implementation like glassfish-embedded-all or glassfish-embedded-web if you're only using the web profile, which seems to be your case (I didn't know that the web profile was providing EJBContainer by the way).

And to be precise, this artifact doesn't have to be the "first" dependency but it must be declared before the javaee-api artifact.

So, is there a Maven repository that Nexus will be able to index to give me the glassfish-embedded-all artifact?

I couldn't reproduce the issue with http://download.java.net/maven/glassfish/ but it appears that JBoss Nexus repository does have it (probably because they use it in Arquillian):

<repository>
  <id>jboss-public-repository-group</id>
  <name>JBoss Public Maven Repository Group</name>
  <url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>

is this even the correct way to go about unit testing EJBs?

Unit tests are typically done outside-container and in isolation (using a Mocking framework) so I wouldn't call that unit testing. But for integration/functional testing (in-container), the EJBContainer API is really great and perfectly fine.

See also

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!