java - JUnit Testing EJB layer with embedded glassfish and Maven -
i have existing jee maven , eclipse project:
mainproject.ear +--project1.war +--project2.war +--ejb-proj.jar
i have test profile unit testing ejb project, including read/write database jpa.
i have added dependency in pom.xml
this:
<!-- embedded glassfish --> <plugin> <groupid>org.glassfish</groupid> <artifactid>maven-embedded-glassfish-plugin</artifactid> <version>3.0-74b</version> <configuration> <goalprefix>embedded-glassfish</goalprefix> <port>8080</port> <autodelete>true</autodelete> </configuration> <dependencies> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.44</version> </dependency> </dependencies>
then have created test class:
@before public void setup() { // instantiate container , context ejbcontainer = ejbcontainer.createejbcontainer(); logger.info("opening container"); ctx = ejbcontainer.getcontext(); }
these maven goals, in eclipse "skip test" unflagged:
clean compile package
glassfish correctly started error missing jdbc driver.
class name wrong or classpath not set : com.mysql.jdbc.jdbc2.optional.mysqldatasource
so, these questions:
- why mysql dependency in embedded glassfish ignored ?
- is correct start embedded container test class ? maybe better have started during test phases.
- in end want container initialized ejb test, suppose have deploy ejb jar only. how can ?
for completeness, same maven goals skip test = true
work. , .ear deployed in running container works too.
Comments
Post a Comment