You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/01/17 08:14:08 UTC

T5: using TapestryTestCase

Hi,

Is there any tutorial on using TapestryTestCase ? say, I'd like to test a
service which has Hibernate's Session injected thru constructor, any idea?

Thanks,
A.C.
-- 
View this message in context: http://www.nabble.com/T5%3A-using-TapestryTestCase-tp14913469p14913469.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: using TapestryTestCase

Posted by Howard Lewis Ship <hl...@gmail.com>.
Just invoke mailer.sendIt() while training your mocks, without an expect() call.

Copious examples of this in the Tapestry code base.

On Jan 17, 2008 6:06 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Thanks, that works. one related question:
>
> I have this:
>
> public interface Mailer {
>         public void send();
>     public String sendIt();
> }
>
> then somewhere in the test, i'd like to make sure send is called, but it can
> not passed to expect as the latter expects a object, any way to 'expect' a
> void method? thanks.
>
>         Mailer mailer = this.newMock(Mailer.class);
>         expect(mailer.sendIt()).andReturn("done");  // this works
>         expect(mailer.send()).andReturn(null); // this does not work
>
>
>
> Igor Drobiazko wrote:
> >
> > Mock the session and pass through to the constructor:
> >
> > Session session = newMock(Session.class);
> > Service service = new Service(session);
> >
> >
>
> --
> View this message in context: http://www.nabble.com/T5%3A-using-TapestryTestCase-tp14913469p14944102.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: using TapestryTestCase

Posted by Andreas Andreou <an...@gmail.com>.
Actually, take a look at some EasyMock tutorials (that's what's behind)
i think their site has a few...

Also, use:

       Mailer mailer = this.newMock(Mailer.class);
       expect(mailer.sendIt()).andReturn("done");
       mailer.send();



On Jan 18, 2008 4:06 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Thanks, that works. one related question:
>
> I have this:
>
> public interface Mailer {
>         public void send();
>     public String sendIt();
> }
>
> then somewhere in the test, i'd like to make sure send is called, but it can
> not passed to expect as the latter expects a object, any way to 'expect' a
> void method? thanks.
>
>         Mailer mailer = this.newMock(Mailer.class);
>         expect(mailer.sendIt()).andReturn("done");  // this works
>         expect(mailer.send()).andReturn(null); // this does not work
>
>
>
> Igor Drobiazko wrote:
> >
> > Mock the session and pass through to the constructor:
> >
> > Session session = newMock(Session.class);
> > Service service = new Service(session);
> >
> >
>
> --
> View this message in context: http://www.nabble.com/T5%3A-using-TapestryTestCase-tp14913469p14944102.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: using TapestryTestCase

Posted by Angelo Chen <an...@yahoo.com.hk>.
Thanks, that works. one related question:

I have this:

public interface Mailer {
  	public void send();
    public String sendIt();
}

then somewhere in the test, i'd like to make sure send is called, but it can
not passed to expect as the latter expects a object, any way to 'expect' a
void method? thanks.

	Mailer mailer = this.newMock(Mailer.class);
	expect(mailer.sendIt()).andReturn("done");  // this works
	expect(mailer.send()).andReturn(null); // this does not work



Igor Drobiazko wrote:
> 
> Mock the session and pass through to the constructor:
> 
> Session session = newMock(Session.class);
> Service service = new Service(session);
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-using-TapestryTestCase-tp14913469p14944102.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: using TapestryTestCase

Posted by Igor Drobiazko <ig...@gmail.com>.
Mock the session and pass through to the constructor:

Session session = newMock(Session.class);
Service service = new Service(session);

On Jan 17, 2008 8:14 AM, Angelo Chen <an...@yahoo.com.hk> wrote:

>
> Hi,
>
> Is there any tutorial on using TapestryTestCase ? say, I'd like to test a
> service which has Hibernate's Session injected thru constructor, any idea?
>
> Thanks,
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3A-using-TapestryTestCase-tp14913469p14913469.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Best regards,

Igor Drobiazko