Oh, i forgot to tell u that for this test to work tapestry 5.1.0.1 is
required because it uses the CoreHibernateModule

On Thu, Mar 26, 2009 at 9:08 PM, Juan E. Maya <maya.j...@gmail.com> wrote:

> Hi Davor, Injection only work on tapestry pages or components. U can't
> inject tapestry services in JUnit classes (as far as i know)
> The way i run my test is as follow, i use testng but u could easily see how
> it would be in Junit
>
> It's important to notice that u have to manually load the Modules u need to
> run the tests.
>
>
>     @BeforeSuite
>     public void config() {
>         RegistryBuilder builder = new RegistryBuilder();
>         builder.add(TapestryIOCModule.class, HibernateCoreModule.class,
> YourModule.class);
>         _registry = builder.build();
>         _registry.performRegistryStartup();
>     }
>
> a test:
>
> @Test
>     public void testSomeDao() {
>        SomeDao someDao= _registry.getService(SomeDao.class);
>        ...
>        ...
>     }
>
> And after test run:
>
> @AfterSuite
>     public void finishTests() {
>         _registry.shutdown();
>     }
>
> Hope it helps
>
>
>
> On Thu, Mar 26, 2009 at 7:17 PM, Davor Miku <davorm...@gmail.com> wrote:
>
>> Hi!
>>
>> This is probably dumb question.
>>
>> I'm using tapestry-hibernate for DAO services.
>>
>> How can I test them with JUnit.?
>>
>> I tried with @Inject SomeDAO in test class, but I'm getting NPE.
>>
>
>

Reply via email to