Solved

Stateless session bean

Posted on 2010-09-15
7
478 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

746 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

9 Experts available now in Live!

Get 1:1 Help Now