Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Stateless session bean

Posted on 2010-09-15
7
Medium Priority
?
489 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 1200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

618 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