Hi All...
I started to work on a rough implementation related to how to
inject EJB
refs into test clients. I was suggesting to do the injection
within test
suites, but I found that it is a bad idea as the test suites are
initialized
before the container, so we will not be able to initialize the EJB
refs. I
am working on another idea in my mind, and will keep you updated
with info
when I get to a proper solution.
On 2/6/07, Mohammad Nour El-Din <[EMAIL PROTECTED] > wrote:
>
>
> On 2/6/07, David Blevins < [EMAIL PROTECTED] > wrote:
> >
> >
> > On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:
> >
> > > Hi All...
> > >
> > > On 2/4/07, David Blevins < [EMAIL PROTECTED]> wrote:
> > >>
> > >> On Feb 3, 2007, at 5:50 PM, Dain Sundstrom wrote:
> > >>
> > >> > On Feb 3, 2007, at 5:00 PM, Jacek Laskowski wrote:
> > >> >
> > >> >> On 2/4/07, Dain Sundstrom < [EMAIL PROTECTED]> wrote:
> > >> >>> I was thinking it would be nice if client code could
call use
> > the
> > >> >>> OpenEJB injection facilities. Say you have some unit
> > tests. You
> > >> >>> could in the setUp method, lookup a bunch of stuff in
JNDI and
> > >> write
> > >> >>> it into fields, but it would be much nicer to simple
annotate
> > >> your
> > >> >>> fields and have OpenEJB inject directly. I'm thinking of
> > >> something
> > >> >>> like this:
> > >> >>>
> > >> >>> public class SomeTest extends TestCase {
> > >> >>> @Resource
> > >> >>> private SomeEjb someEjb;
> > >> >>>
> > >> >>> public void setUp() {
> > >> >>> OpenEJB.inject(this);
> > >> >>> }
> > >> >>> }
> > >> >>>
> > >> >>> I can think of a bunch of ways we could implement this,
but
> > >> what do
> > >> >>> you think of the idea generally?
> > >
> > >
> > > I think it would be nice to let other *ENTITY* initialize
the test
> > > case, I
> > > think of the test suite itself. For example the the local test
> > > suite could
> > > be initialized with the properties needed to get the local
initial
> > > context,
> > > and the same for the remote test suite to get the remote
initial
> > > context and
> > > we can override the addTest method of the test suite so it
> > > initializes the
> > > added tests and then preforms the normal test case addition
to the
> > > suite, by
> > > this way we will have minor code changes, thoughts ???
> >
> > I wouldn't want to mess with our own tests suite too much as
we try
> > to keep it strictly ejb-spec compliant.
> >
> > But definitely for test code in user-land the approach you
describe
> > could be a pretty slick test framework. I say go for it.
> >
> > I think the InitialContext approach I mention would be a good
> > alternate for those who don't want to have any compile-time
deps in
> > their test code on OpenEJB classes. It'd also work for any
client
> > (doesn't have to be a test case).
> >
> > -David
>
>
> AFAIU you, you mean that we should initialize the test suite
with the
> initial context, or at least the info it needs to create one, if
this what
> you mean I totally agree with, if not it would be nice to
explain more for a
> not talented man like me :).
>
> >
> > >>>
> > >> >> Yeah, that would be of help.
> > >> >>
> > >> >> There's one caveat with it. When I first read the email
of yours
> > I
> > >> >> couldn't see the point because of the name which would
perform
> > the
> > >> >> injection. That's what the method would do, wouldn't it?
So why
> > it
> > >> >> isn't called performInjection or doInjection or alike?
Other
> > than
> > >> >> that
> > >> >> the idea's excellent.
> > >> >
> > >> > I don't really care what it is called. I just found the
phrase
> > >> > "inject this" funny in english.
> > >>
> > >> Check out this thread. http://www.nabble.com/%40EJB-
injection-for-
> > >> TestCases-%28would-be-cool%29-tf2889639s2756.html#a8072860
> > >>
> > >> One of the ideas we came up with there was people could pass a
> > >> reference to their TestCase instance along with the other
> > >> InitialContext params.
> > >>
> > >> -David
> > >>
> > >>
> > >
> > >
> > > --
> > > Thanks
> > > - Mohammad Nour
> >
> >
>
>
> --
> Thanks
> - Mohammad Nour
--
Thanks
- Mohammad Nour