you shold also call registry.performRegistryStartup(); after Registry registry = builder.build();
in the end just call : registry.shutdown(); Davor Hrg On Jun 14, 2007 4:01 PM, Dan Adams <[EMAIL PROTECTED]> wrote: > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >