You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 西村 俊夫 <ni...@gmail.com> on 2007/12/03 11:36:25 UTC
Re: [T5] Got the ioc working in a test with tapestry-hibernate
Hi, Dan.
I want to same thing which you did. Could you let me know the details?
> So I have some test cases in which I actually need a working hibernate
> session so I'm having my tests start up an ioc registry. This took
> a bit
> of digging to figure out but I got it working. Here's a minimal test
> case that I used to prove that it worked:
>
> public void testTest() throws Exception {
> RegistryBuilder builder = new RegistryBuilder();
>
> builder.add(TapestryModule.class);
> builder.add(HibernateModule.class);
> builder.add(InternalTestModule.class);
> builder.add(AppModule.class);
>
> Registry registry = builder.build();
> // mode can be anything here
> registry.getService(Alias.class).setMode("test");
>
> // ... loads one of my services to make sure it works
> }
>
> The biggest trick was contributing my own internal test module so
> that I
> could override ApplicationDefaults in order to provide the correct
> root
> application package which is needed by tapestry-hibernate during
> configuration. Whew.
>
> public final class InternalTestModule {
> public static void
> contributeAliasOverrides(Configuration<AliasContribution> config) {
>
> ApplicationGlobalsImpl globals = new ApplicationGlobalsImpl();
> globals.store("your.root.package");
> config.add(AliasContribution.create(ApplicationGlobals.class,
> globals));
> }
> }
>
> But it seems to be loading fine now and I can use the hibernate
> stuff in
> my tests without a problem. There is more that's need as far as thread
> cleanup and shutting down the registry but this is what's needed to
> get
> it at least running.
>
> --
> Dan Adams
> Senior Software Engineer
> Interactive Factory
> 617.235.5857
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org