Check out the TestUtils [1] class. It used to create services for tests.
Here is an example:

IOrganizationDAO da0 = newMock(IOrganizationDAO.class);
IPacoService  service = TestUtils.create(IPacoService.class, "orgDao",
dao);

[1]
https://builds.apache.org/job/tapestry-trunk-freestyle/javadoc/org/apache/tapestry5/ioc/test/TestUtils.html

On Mon, Sep 5, 2011 at 9:09 AM, Ernesto Arroyo <earroyo...@yahoo.es> wrote:

> Thanks,
>
> Yes it should be easy in "plain Java) but,... As far as I do not provide a
> constructor, Java will provide a default one for me.  Because the default
> constructor will not create the dependency because is a private variable of
> the class I suposse Tapestry is doing an enhancement in the class using
> annotations for that (the class is enhanced in the same way EJBs are
> enhanced I think) to create the needed constructors for injection.
>
> So, If I provide a constructor maybe I "break" the way tapestry is doing
> this enhancement (for example, in Hibernate you can have problems if you
> provide a constructor in some ways)
>
> Of course I am going to do a test and check this, but this are ideas I have
> in mind now.
>
> Thanks a lot.
>
> PD:
> My example code was wrong,
>
> psrv.setOrgDao(mockDao); // orgDao is private in the service, we need a
> setter
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/How-to-inject-a-mock-into-a-tapestry-service-tp4768327p4769454.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Reply via email to