Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Junit test EJB

 
Forest Huge
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using JUNIT to test EJB in WSAD(IE)5.0.1, in the beginning we always got naming exception. Later on, I added
props.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:900/");
This temporary solved problem.
I am not sure I am doing the right way. So any suggestion about JUNIT test EJB?
THanks
 
Vincent Massol
Author
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Forest Lin:
We are using JUNIT to test EJB in WSAD(IE)5.0.1, in the beginning we always got naming exception. Later on, I added
props.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:900/");
This temporary solved problem.
I am not sure I am doing the right way. So any suggestion about JUNIT test EJB?
THanks

That's normal. This is because you are running your tests outside the container.
 
Forest Huge
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So could you please give a brief description how to use Junit to test EJB? thanks
 
Vincent Massol
Author
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Forest Lin:
So could you please give a brief description how to use Junit to test EJB? thanks

This would be a bit long to describe here as there are several techniques. One is with JUnit/mock objects (this requires refactoring of your code if it's already written). Another is to use JUnit doing remote calls or Cactus. There are 45 pages about this in the book (chapter 12).
 
Benson Fung
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is only for remote interface EJB. However, if it is a local interface EJB, how I can test it from JUNIT?
Benson
 
Nguyen Phuc Hai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can test EJB using Local interface if you write a jsp/servlet item and test EJB from them (In order jsp/servlet can call local interface if it belong the same container with EJB). Or you test EJB by using Cactus (The way to write test are the same but it help you test EJB local interface although from a remote machine)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic