You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Dain Sundstrom <da...@iq80.com> on 2007/02/04 01:45:48 UTC

Inject this!

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?

-dain

Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi Jacek :)

Thanks for the advice :) and support :)

On 3/15/07, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
>
> On 3/15/07, Mohammad Nour El-Din <no...@gmail.com> wrote:
> > Hi David...
> >
> > AFAIU , Do u mean that we should not annotate any fields or methods in
> our
> > unit test cases ???
>
> I'd 's/but/and' the last sentence. I hope that's what Dave meant.
>
> > And for committing new code, how the review is going to be ???
>
> You're free to go. You're a committer now so don't expect that anybody
> will review your code unless you ask about it. If you still remember
> how it was before you became a committer, think about others who are
> still lurking in this list and wondering how to contribute (and
> eventually become a committer).
>
> I'm sure you know it that all committers are subscribed to
> openejb-commits mailing list so any change is reviewed anyway. Just
> keep your pace and don't panic when something breaks. We're all humans
> and to err is human.
>
> Jacek
>
> --
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>



-- 
Thanks
- Mohammad Nour

Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi David...

Thanks David for help and support, every time you all make me feel proud to
be a member in this team :)

On 3/15/07, David Blevins <da...@visi.com> wrote:
>
>
> On Mar 15, 2007, at 9:41 AM, Jacek Laskowski wrote:
>
> > On 3/15/07, Mohammad Nour El-Din <no...@gmail.com> wrote:
> >> Hi David...
> >>
> >> AFAIU , Do u mean that we should not annotate any fields or
> >> methods in our
> >> unit test cases ???
> >
> > I'd 's/but/and' the last sentence. I hope that's what Dave meant.
>
> The "but" negates the previous Independent Clause in this case
> turning it into a positive.  Isn't that a good thing? :)
>
> I think it's an exciting change!
>
> -David
>
> >
> >> And for committing new code, how the review is going to be ???
> >
> > You're free to go. You're a committer now so don't expect that anybody
> > will review your code unless you ask about it. If you still remember
> > how it was before you became a committer, think about others who are
> > still lurking in this list and wondering how to contribute (and
> > eventually become a committer).
> >
> > I'm sure you know it that all committers are subscribed to
> > openejb-commits mailing list so any change is reviewed anyway. Just
> > keep your pace and don't panic when something breaks. We're all humans
> > and to err is human.
> >
> > Jacek
> >
> > --
> > Jacek Laskowski
> > http://www.JacekLaskowski.pl
> >
>
>


-- 
Thanks
- Mohammad Nour

Re: Inject this!

Posted by David Blevins <da...@visi.com>.
On Mar 15, 2007, at 9:41 AM, Jacek Laskowski wrote:

> On 3/15/07, Mohammad Nour El-Din <no...@gmail.com> wrote:
>> Hi David...
>>
>> AFAIU , Do u mean that we should not annotate any fields or  
>> methods in our
>> unit test cases ???
>
> I'd 's/but/and' the last sentence. I hope that's what Dave meant.

The "but" negates the previous Independent Clause in this case  
turning it into a positive.  Isn't that a good thing? :)

I think it's an exciting change!

-David

>
>> And for committing new code, how the review is going to be ???
>
> You're free to go. You're a committer now so don't expect that anybody
> will review your code unless you ask about it. If you still remember
> how it was before you became a committer, think about others who are
> still lurking in this list and wondering how to contribute (and
> eventually become a committer).
>
> I'm sure you know it that all committers are subscribed to
> openejb-commits mailing list so any change is reviewed anyway. Just
> keep your pace and don't panic when something breaks. We're all humans
> and to err is human.
>
> Jacek
>
> -- 
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>


Re: Inject this!

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 3/15/07, Mohammad Nour El-Din <no...@gmail.com> wrote:
> Hi David...
>
> AFAIU , Do u mean that we should not annotate any fields or methods in our
> unit test cases ???

I'd 's/but/and' the last sentence. I hope that's what Dave meant.

> And for committing new code, how the review is going to be ???

You're free to go. You're a committer now so don't expect that anybody
will review your code unless you ask about it. If you still remember
how it was before you became a committer, think about others who are
still lurking in this list and wondering how to contribute (and
eventually become a committer).

I'm sure you know it that all committers are subscribed to
openejb-commits mailing list so any change is reviewed anyway. Just
keep your pace and don't panic when something breaks. We're all humans
and to err is human.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Inject this!

Posted by David Blevins <da...@visi.com>.
On Mar 15, 2007, at 7:35 AM, Mohammad Nour El-Din wrote:

> Hi David...
>
> AFAIU , Do u mean that we should not annotate any fields or methods  
> in our
> unit test cases ???

No, I'd say go ahead and check it in annotations and all.  If there's  
anything that breaks compliance or binds the itests to OpenEJB we  
can  fix it later, no big deal.

> And for committing new code, how the review is going to
> be ???

You're a committer now, so feel free to commit! :)  Most of us will  
likely read the commit log.

-David

> On 3/14/07, David Blevins <da...@visi.com> wrote:
>>
>> You've got commit now, Mohammad, so I say you should just go ahead
>> and commit these goodies.
>>
>> Just a note about the itests since I haven't really looked too
>> closely at the patch, there's a hard rule against anything that would
>> break standards compliance or bind the itests to any OpenEJB-specific
>> internals.  We might be toeing the line using annotations in test
>> cases, but we should be fine.
>>
>> -David
>>
>> On Mar 11, 2007, at 1:28 PM, Mohammad Nour El-Din wrote:
>>
>> > Hi Jacek...
>> >
>> > Thanks for taking this burden :D. It is not committed yet. It  
>> will my
>> > pleasure to have your feedback.
>> >
>> >
>> >
>> > On 3/11/07, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
>> >
>> >> On 3/8/07, David Blevins <da...@visi.com> wrote:
>> >>
>> >> > Or really, Mohammad you're a committer now.  Maybe you just  
>> want to
>> >> > give an overview of what you added and how it works?
>> >>
>> >> I hope it's already got committed. If not, I could take a look  
>> at it.
>> >> Let me know, Mohammad, if it's still relevant.
>> >>
>> >> Jacek
>> >>
>> >> --
>> >> Jacek Laskowski
>> >> http://www.JacekLaskowski.pl
>> >>
>> >
>> >
>> >
>> > --
>> > Thanks
>> > - Mohammad Nour
>>
>>
>
>
> -- 
> Thanks
> - Mohammad Nour


Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi David...

AFAIU , Do u mean that we should not annotate any fields or methods in our
unit test cases ??? And for committing new code, how the review is going to
be ???

On 3/14/07, David Blevins <da...@visi.com> wrote:
>
> You've got commit now, Mohammad, so I say you should just go ahead
> and commit these goodies.
>
> Just a note about the itests since I haven't really looked too
> closely at the patch, there's a hard rule against anything that would
> break standards compliance or bind the itests to any OpenEJB-specific
> internals.  We might be toeing the line using annotations in test
> cases, but we should be fine.
>
> -David
>
> On Mar 11, 2007, at 1:28 PM, Mohammad Nour El-Din wrote:
>
> > Hi Jacek...
> >
> > Thanks for taking this burden :D. It is not committed yet. It will my
> > pleasure to have your feedback.
> >
> >
> >
> > On 3/11/07, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
> >
> >> On 3/8/07, David Blevins <da...@visi.com> wrote:
> >>
> >> > Or really, Mohammad you're a committer now.  Maybe you just want to
> >> > give an overview of what you added and how it works?
> >>
> >> I hope it's already got committed. If not, I could take a look at it.
> >> Let me know, Mohammad, if it's still relevant.
> >>
> >> Jacek
> >>
> >> --
> >> Jacek Laskowski
> >> http://www.JacekLaskowski.pl
> >>
> >
> >
> >
> > --
> > Thanks
> > - Mohammad Nour
>
>


-- 
Thanks
- Mohammad Nour

Re: Inject this!

Posted by David Blevins <da...@visi.com>.
You've got commit now, Mohammad, so I say you should just go ahead  
and commit these goodies.

Just a note about the itests since I haven't really looked too  
closely at the patch, there's a hard rule against anything that would  
break standards compliance or bind the itests to any OpenEJB-specific  
internals.  We might be toeing the line using annotations in test  
cases, but we should be fine.

-David

On Mar 11, 2007, at 1:28 PM, Mohammad Nour El-Din wrote:

> Hi Jacek...
>
> Thanks for taking this burden :D. It is not committed yet. It will my
> pleasure to have your feedback.
>
>
>
> On 3/11/07, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
>
>> On 3/8/07, David Blevins <da...@visi.com> wrote:
>>
>> > Or really, Mohammad you're a committer now.  Maybe you just want to
>> > give an overview of what you added and how it works?
>>
>> I hope it's already got committed. If not, I could take a look at it.
>> Let me know, Mohammad, if it's still relevant.
>>
>> Jacek
>>
>> --
>> Jacek Laskowski
>> http://www.JacekLaskowski.pl
>>
>
>
>
> -- 
> Thanks
> - Mohammad Nour


Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi Jacek...

Thanks for taking this burden :D. It is not committed yet. It will my
pleasure to have your feedback.



On 3/11/07, Jacek Laskowski <ja...@laskowski.net.pl> wrote:

> On 3/8/07, David Blevins <da...@visi.com> wrote:
>
> > Or really, Mohammad you're a committer now.  Maybe you just want to
> > give an overview of what you added and how it works?
>
> I hope it's already got committed. If not, I could take a look at it.
> Let me know, Mohammad, if it's still relevant.
>
> Jacek
>
> --
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>



-- 
Thanks
- Mohammad Nour

Re: Inject this!

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 3/8/07, David Blevins <da...@visi.com> wrote:

> Or really, Mohammad you're a committer now.  Maybe you just want to
> give an overview of what you added and how it works?

I hope it's already got committed. If not, I could take a look at it.
Let me know, Mohammad, if it's still relevant.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi All...

On 3/8/07, David Blevins <da...@visi.com> wrote:
>
>
> On Mar 6, 2007, at 2:29 PM, Mohammad Nour El-Din wrote:
>
> > Hi All...
> >
> > I've just finished adding the capability to create annotated test
> > clients,
> > some new classes are added, some others are modified, the target
> > was to give
> > the capability to developers to create annotated test clients using
> > the same
> > approach of the un-annotated test clients and without any extra
> > effort.
> > Please take a look at https://issues.apache.org/jira/browse/
> > OPENEJB-519 and
> > have a nice time creating annotated test clients :). The patch is
> > waiting
> > for review.
> >
>
> Excellent, Mohammad!
>
> Is there anyone(s) who'd want to want to take a look at this?  (i'm a
> bit overcommitted myself atm)
>
> Or really, Mohammad you're a committer now.  Maybe you just want to
> give an overview of what you added and how it works?


Thanks David for introducing me :D. Well, I want to start by what was my aim
while I was making these changes. My aim was to be able to program annotated
test clients, as much as possible, in the same way we currently develop unit
tests.
It all starts from the new TestClient from which
Stateless\StatefulTestClient are extended. This new TestClient contains all
the common features required by all test clients. And it contains the two
new methods processFieldInjections and processSetterInjections. which are
used by the new tests clients
AnnotatedSetter\FieldInjectionStateless\StatefulTestClient and
AnnotatedSetter\FieldInjectionStateless\StatefulLocalTestClient classes.
These two classes take the burden of the new test classes, so they don't
have to call neither of processSetter\FieldInjections. This idea I derived
from the first proposal of Dain regarding annotated test clients. Each of
these new clients extend from BasicStateless\StatefulTestClient or
BasicStateless\StatefulLocalTestClient. You can see that these later test
clients have annotated fields for the EJB homes. By this new hierarchy
structure these fields can work for both un\annotated test clients. So, what
to do to develop a new annotated unit test. All you have to do is to make a
new unit test which extends from either of
AnnotatedSetter\FieldInjectionStateless\StatefulTestClient or
AnnotatedSetter\FieldInjectionStateless\StatefulLocalTestClient according to
the unit test you develop. And if you use a member field\method from a super
class, you don't have to add an annotated version of it into the new unit
test. All you have to do is to annotate the field\method located in the
super class. Sure you don't have to do this if you want a completely new
annotated version of these fields\methods. By this way we have the minor
code changes and minor unit tests development paradigm changes. I hope I
could explain this well. Have a nice time with annotated unit tests :).

-David
>
> >
> >
> > On 2/13/07, Mohammad Nour El-Din <nour.mohammad@gmail.com > wrote:
> >
> >> 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 <nour.mohammad@gmail.com > wrote:
> >>
> >> >
> >> >
> >> >  On 2/6/07, David Blevins < david.blevins@visi.com > wrote:
> >> > >
> >> > >
> >> > > On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:
> >> > >
> >> > > > Hi All...
> >> > > >
> >> > > > On 2/4/07, David Blevins < david.blevins@visi.com> 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 < dain@iq80.com> 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
> >
> >
> >
> >
> > --
> > Thanks
> > - Mohammad Nour
>
>


-- 
Thanks
- Mohammad Nour

Re: Inject this!

Posted by David Blevins <da...@visi.com>.
On Mar 6, 2007, at 2:29 PM, Mohammad Nour El-Din wrote:

> Hi All...
>
> I've just finished adding the capability to create annotated test  
> clients,
> some new classes are added, some others are modified, the target  
> was to give
> the capability to developers to create annotated test clients using  
> the same
> approach of the un-annotated test clients and without any extra  
> effort.
> Please take a look at https://issues.apache.org/jira/browse/ 
> OPENEJB-519 and
> have a nice time creating annotated test clients :). The patch is  
> waiting
> for review.
>

Excellent, Mohammad!

Is there anyone(s) who'd want to want to take a look at this?  (i'm a  
bit overcommitted myself atm)

Or really, Mohammad you're a committer now.  Maybe you just want to  
give an overview of what you added and how it works?

-David

>
>
> On 2/13/07, Mohammad Nour El-Din <nour.mohammad@gmail.com > wrote:
>
>> 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 <nour.mohammad@gmail.com > wrote:
>>
>> >
>> >
>> >  On 2/6/07, David Blevins < david.blevins@visi.com > wrote:
>> > >
>> > >
>> > > On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:
>> > >
>> > > > Hi All...
>> > > >
>> > > > On 2/4/07, David Blevins < david.blevins@visi.com> 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 < dain@iq80.com> 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
>
>
>
>
> -- 
> Thanks
> - Mohammad Nour


Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi All...

I've just finished adding the capability to create annotated test clients,
some new classes are added, some others are modified, the target was to give
the capability to developers to create annotated test clients using the same
approach of the un-annotated test clients and without any extra effort.
Please take a look at https://issues.apache.org/jira/browse/OPENEJB-519 and
have a nice time creating annotated test clients :). The patch is waiting
for review.



On 2/13/07, Mohammad Nour El-Din <nour.mohammad@gmail.com > wrote:

> 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 <nour.mohammad@gmail.com > wrote:
>
> >
> >
> >  On 2/6/07, David Blevins < david.blevins@visi.com > wrote:
> > >
> > >
> > > On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:
> > >
> > > > Hi All...
> > > >
> > > > On 2/4/07, David Blevins < david.blevins@visi.com> 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 < dain@iq80.com> 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




-- 
Thanks
- Mohammad Nour

Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
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 <no...@gmail.com> wrote:

>
>
>  On 2/6/07, David Blevins <da...@visi.com> wrote:
> >
> >
> > On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:
> >
> > > Hi All...
> > >
> > > On 2/4/07, David Blevins < david.blevins@visi.com> 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 <da...@iq80.com> 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

Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
On 2/6/07, David Blevins <da...@visi.com> wrote:
>
>
> On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:
>
> > Hi All...
> >
> > On 2/4/07, David Blevins <da...@visi.com> 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 <da...@iq80.com> 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

Re: Inject this!

Posted by David Blevins <da...@visi.com>.
On Feb 4, 2007, at 2:59 AM, Mohammad Nour El-Din wrote:

> Hi All...
>
> On 2/4/07, David Blevins <da...@visi.com> 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 <da...@iq80.com> 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

>
>>>
>> >> 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


Re: Inject this!

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi All...

On 2/4/07, David Blevins <da...@visi.com> 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 <da...@iq80.com> 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 ???

>>
> >> 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

Re: Inject this!

Posted by David Blevins <da...@visi.com>.
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 <da...@iq80.com> 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?
>>
>> 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


Re: Inject this!

Posted by Dain Sundstrom <da...@iq80.com>.
On Feb 3, 2007, at 5:00 PM, Jacek Laskowski wrote:

> On 2/4/07, Dain Sundstrom <da...@iq80.com> 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?
>
> 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.

-dain

Re: Inject this!

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 2/4/07, Dain Sundstrom <da...@iq80.com> 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?

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.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl