You can still use a constructor/constructor injection when registering your
service in your module, if you want. (In fact the auto binding looks for
the constructor with the most parameters, if none are marked with @Inject.)
 Or, you can use Field Injection.  Not sure if you can use both, probably
not.

If you have @Inject in your class X, and then register the class X in your
module, Tapestry should throw an error if it can't find the class Y to
inject into X.

HOWEVER, if you are instantiating the class outside of the registry, the
@Inject annotations are ignored.  I know this because I have an old-school
coworker who does not believe in Injection, and I have to make some
services construct-able by him.. *le sigh*






On Mon, Sep 23, 2013 at 4:07 PM, Martin Kersten <martin.kersten...@gmail.com
> wrote:

> Yeah thats what I was thinking about exactly. This way I can get rid of the
> pesti constructor injection.
>
> Does anyone knows if the autobuild / build process fails if a property
> annotated @inject could not be injected? Kind of should be but I am quite
> not sure... .
>
>
> 2013/9/23 Daniel Jue <teamp...@gmail.com>
>
> > You'll probably find better examples online, but in my Test classes I
> > usually have a method like this:
> >
> >
> > private MyDAO<MyPojo,MyQueryObject> dao;
> > @BeforeClass
> > public void beforeClass() {
> >
> > // TODO Auto-generated constructor stub
> > System.out.println("MyDAOTest");
> > Registry registry;
> > RegistryBuilder builder = new RegistryBuilder();
> > builder.add(MyDAOModule.class);
> > registry = builder.build();
> > registry.performRegistryStartup();
> > dao = registry.getService(MyDAO.class);
> >
> > }
> >
> > @Test
> > public void f() {
> > MyQueryObject q = new MyQueryObject();
> > q.setAttribute("Martin");
> > List<MyPojo> = dao.findByQuery(q);
> > //assert something here
> > }
> >
> >
> > In MyDAOModule.class, you can set up your services to build via
> > auto-binding, interface binding, or using a build method (public static
> > MyDAO buildMyDAO() { ... }  )
> > depending on your needs.
> >
> >
> > On Mon, Sep 23, 2013 at 2:58 PM, Martin Kersten <
> > martin.kersten...@gmail.com
> > > wrote:
> >
> > > Is there anything to aid me with the usual service test. Currently I
> use
> > > constructors to ease setup of the services. I will try out providing a
> > test
> > > module setting up the services and use tapestry IOC to create those.
> > Should
> > > have done so more early on, but wanted it simple first. But now when I
> > have
> > > three or four services to setup it becomes cumbersome.
> > >
> > >
> > > 2013/9/23 Martin Kersten <martin.kersten...@gmail.com>
> > >
> > > > Thanks daniel. I will check the testify stuff in a real example.
> > > >
> > > >
> > > > 2013/9/23 Daniel Jue <teamp...@gmail.com>
> > > >
> > > >> I don't have spare minutes at the moment, I just want to drop these
> > > links
> > > >> for you to look at (if you haven't seen them already).  Hope it
> helps.
> > > >>
> > > >>
> > >
> >
> http://blog.tapestry5.de/index.php/2010/11/16/improved-testing-facilities/
> > > >>
> > > >> and then this one
> > > >>
> > > >> http://blog.tapestry5.de/index.php/2010/11/18/find-your-elements/
> > > >>
> > > >>
> > > >> Dan
> > > >>
> > > >>
> > > >> On Mon, Sep 23, 2013 at 12:49 PM, Martin Kersten <
> > > >> martin.kersten...@gmail.com> wrote:
> > > >>
> > > >> > Problems nope. I just habe to overhowle the system and wonder what
> > > >> people
> > > >> > nicht use. I will check your base clase out. Thanks for sharing.
> > > >> > Am 23.09.2013 18:12 schrieb "Dmitry Gusev" <
> dmitry.gu...@gmail.com
> > >:
> > > >> >
> > > >> > > I use JUnit for unit testing with T5 services, and TestNG for
> > > (smoke)
> > > >> > > integration testing my apps with URLs.
> > > >> > >
> > > >> > > All my JUnit test classes inherited from BaseIntegrationTest (
> > > >> > > https://gist.github.com/dmitrygusev/6672859),
> > > >> > > all TestNG classes inherited from a copy of SeleniumTestCase
> with
> > > with
> > > >> > this
> > > >> > > patch applied:
> > > >> > > https://issues.apache.org/jira/browse/TAP5-2107
> > > >> > >
> > > >> > > Which is something you may already read while browsing the web.
> > > >> > >
> > > >> > > Do you have any problems with this?
> > > >> > >
> > > >> > >
> > > >> > > On Mon, Sep 23, 2013 at 7:02 PM, Martin Kersten <
> > > >> > > martin.kersten...@gmail.com
> > > >> > > > wrote:
> > > >> > >
> > > >> > > > I want some real hands on experiences. So please if you have
> any
> > > >> please
> > > >> > > > provide.
> > > >> > > >
> > > >> > > > I am currently reworking the testing settup since the maven
> > stuff
> > > >> is to
> > > >> > > > slow for my program test cycle.
> > > >> > > >
> > > >> > > > Since I wont use testng I need to rewrite some test code. I
> need
> > > to
> > > >> do
> > > >> > > unit
> > > >> > > > testing in java
> > > >> > > > since I program in java. Integration test and Acceptance test
> > may
> > > be
> > > >> > done
> > > >> > > > in groovy
> > > >> > > > but I am in doupt this would be such a gain.
> > > >> > > >
> > > >> > > > Well the unit testing I want to elaborate the IOC directly
> using
> > > >> only a
> > > >> > > > fraction of the
> > > >> > > > services the application is about. The IOC setup seams to be
> > > fairly
> > > >> > fast
> > > >> > > so
> > > >> > > > it is ok
> > > >> > > > (Hibernate takes way longer)
> > > >> > > >
> > > >> > > > I use a embedded jetty for the integration testing with a
> > presetup
> > > >> in
> > > >> > > > memory database (h2).
> > > >> > > >
> > > >> > > > I dont use mvn jetty:run since it is dead slow with all the
> > > >> dependency
> > > >> > > > setup and stuff.
> > > >> > > >
> > > >> > > > So in the end I want to hear what you use for testing, what
> > speed
> > > >> means
> > > >> > > and
> > > >> > > > if you
> > > >> > > > use IOC, jetty or something else.
> > > >> > > >
> > > >> > > >
> > > >> > > > And yes I searched the web high and low, I want just personal
> > > >> > experiences
> > > >> > > > with
> > > >> > > > the background of embedding either a web application server or
> > an
> > > >> IOC.
> > > >> > > >
> > > >> > > >
> > > >> > > > Cheers,
> > > >> > > >
> > > >> > > > Martin (Kersten)
> > > >> > > >
> > > >> > >
> > > >> > >
> > > >> > >
> > > >> > > --
> > > >> > > Dmitry Gusev
> > > >> > >
> > > >> > > AnjLab Team
> > > >> > > http://anjlab.com
> > > >> > >
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Reply via email to