Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing jpa part

 
Olivier Scalbert
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am currently developing a JSF web app that uses services provided by a stateless session bean, that acts as a facade.
This session bean delegates to different pojos.
One of these pojos encapsulates all the JPA stuff. It uses an injected Persistent Context
@PersistenceContext(unitName = "myPU")
Everything work fine.

Now I would like to do some testing around this JPA pojo.
I woulld to use junit as all my other pojos are tested with junit.
But how can I do that ?
From my tests (out of container), how can I create a persistent manager based on the persistent unit name ?
I am using netbeans + glassfish.

Thanks for your help,
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Olivier,

Have you looked into embedded GlassFish? It can be used inside JUnit.

Regards,
Reza
 
Olivier Scalbert
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info, Reza
I will have a look to embedded glassfish.

By the way I have your book opened on my desk !!!
;-)

Olivier
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Olivier,

Good to hear :-). I hope that it is helping. Do let me know if you have questions or comments. I can be reached here: reza_rahman@lycos.com. I can put it on the plan for the second edition.

Cheers,
Reza

P.S.: If you get a chance, please do consider writing a review on Amazon or elsewhere. It really helps us out :-).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic