Solved

Stateless session bean

Posted on 2010-09-15
7
485 Views
Last Modified: 2012-05-10
Stateless session bean using JPA for persistence  are most thoroughly testable outside a container without requiring the creation of mock objects

I don't understand this .

It seems to me , this is impossible.  Stateless session bean  can not live outside container ...how come then we test  ? Also Test without creating any objects of the bean !

This is impossible ...is not it ?  Can we really do it ?
0
Comment
Question by:cofactor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:Hegemon
ID: 33681140
It is just an annotated POJO so you don't need container to test.
0
 

Author Comment

by:cofactor
ID: 33681161
>>>It is just an annotated POJO
which one ?
Stateful session bean live in EJB container.
>>>so you don't need container to test.
How you are going to test that ?
jakarta Logger will not work unless you deploy .
System.out.println  will not work unless you deploy .
Not sure about Junit / EJB3 Interceptor though
 
0
 
LVL 10

Accepted Solution

by:
Hegemon earned 300 total points
ID: 33681415
-- which one ?

All EJB 3.0 are POJOs

>>>so you don't need container to test.

-- How you are going to test that ?

Write unit test as you would normally do for POJOs

-- jakarta Logger will not work unless you deploy .

It is not a unit test then since you are not testing your classes in isolation. You should be mocking the logger.

System.out.println  will not work unless you deploy .

-- Incorrect, it will work in any environment.

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:cofactor
ID: 33684494
yea...its better now.

Could you please explain this part in your comment

>>>Write unit test as you would normally do for POJOs

did you mean  to use Assert  ? if you mean something else please enlighten me....thanks
0
 
LVL 10

Expert Comment

by:Hegemon
ID: 33684530
Yes, normally you would use Asserts. Just usual unit test in which you instantiate your EJB classes as POJOs:

MyBean bean = new MyBeanImpl();
0
 

Author Comment

by:cofactor
ID: 33688595
ok..that looks pretty good.

but look   it says   "without requiring the creation of mock objects"  

umm....does it make any sense ?  what this could mean....is it meaningful ?


>>MyBean bean = new MyBeanImpl();

you are really creating instances here  to test.
0
 
LVL 10

Expert Comment

by:Hegemon
ID: 33691666
Can you post the question in full ?

Yes, when you write a unit test, you are supposed to create the object you are testing ?
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question