Solved

Stateless session bean

Posted on 2010-09-15
7
480 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now