users@glassfish.java.net

Re: Question on testing JPA in GlassFish

From: <glassfish_at_javadesktop.org>
Date: Wed, 24 Dec 2008 12:26:55 PST

[b]Question: Do you think it is reasonable to put all my entities and business logic inside a jar file, and use this jar file inside the JSF web app?[/b]

Answer: Here is my ten cents:

A. One java project for your jpa (i.e., pojo, persistence.xml, orm.xml) stuff
B. One java project for business logic interface
C. One ejb project for implementation of the business logic (i.e., session beans, @webservice)
D. One web project for your web stuff
E. One ear

Also, I use separate package for data access stuff (reading, writing, updating, finding entities) using EntityManager in database and another package for business logic (aka use cases). Both will have interfaces and implementation using session beans but interface will go into B and implementation to C.

In D
add A and B as projects
add third-party web specific jars to D lib directory

Packaging EAR (E)
C.jar
D.war
third-party jars
lib/A.jar
lib/B.jar


Testing

1. Use Junit to test C classes i,e business logic, use cases (i.e., session beans, webservice) etc.

2. If you are using JSF try “jboss-jsfunit” and also facestrace. Both are very easy to configure and use in testing face-config, web.xml, jsf pages etc. You may also want to try cactus.

Some useful links:
JBoss-jsfUnit
http://ttlnews.blogspot.com/search/label/configuration
http://www.jboss.org/jsfunit

FacesTrace
http://www.prime.com.tr/facestrace
[Message sent by forum member 'nuffsaidx' (nuffsaidx)]

http://forums.java.net/jive/thread.jspa?messageID=323237