You may do something like this:

ServerRuntime.builder()
   .module(b -> b.bind(SchemaUpdateStrategyFactory.class).toInstance(descriptor 
-> new CreateIfNoSchemaStrategy()))
   ...

This is what "bootique-cayenne" does to generate the schema.

Andrus

> On Jan 9, 2019, at 6:46 PM, Tony Giaccone <t...@giaccone.org> wrote:
> 
> I'm trying to spin up an in memory instance of H2 so that I can run some
> unit tests. The model, has just the model and no datanode. I spin it up
> with this line:
> 
> This code is in a project that is just cayenne and represents our data
> model. It does have some base level of service implementation and all  of
> the other tests in this project are unit tests with mockito.  This jar file
> is included in other projects that are using bootique. I'd like to test the
> base level of some services that are common across both apps that use the
> model.
> 
> The problem is that the tables aren't created as part of the spin up. Any
> suggestions on how to make that happen?
> 
> serverRuntime =  ServerRuntime.builder()
>        .addConfig("cayenne-MyModel.xml")
>        .url("jdbc:h2:mem:MyDB;MVCC=TRUE")
>        .jdbcDriver("org.h2.Driver")
>        .user("user")
>        .password("password")
>        .build();

Reply via email to