cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Giaccone, Tony" <anthony.giacc...@nytimes.com>
Subject Re: Spinning up Cayenne for unit test
Date Wed, 09 Jan 2019 18:04:21 GMT
Andrus,

Perfect that worked like a charm, only one small change, addModule, not
module.


Tony

On Wed, Jan 9, 2019 at 10:58 AM Andrus Adamchik <andrus@objectstyle.org>
wrote:

> 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 <tony@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();
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message