Andrus,

You need a tech writer, to get all this stuff documented.


Tony


On 5/3/18 3:19 AM, Andrus Adamchik wrote:
I use Derby. From my experience it is the most "serious" choice out of all 
in-memory Java databases. HSQL/H2 left a bad aftertaste from the days when we used it for 
the Modeler preferences. Though this may not be relevant in the context of unit tests.

Beyond that, I use bootique-jdbc-test / bootique-cayenne-test to manage DB 
lifecycle, datasets and assertions. There may be a lot of overlap with DBUnit, 
but if you are on Bootique, it integrates very nicely with the existing app 
configs, Cayenne models, etc. It supports loading data from CSVs, comparing DB 
state with CSV, referencing tables by mapped Cayenne classes, etc. There not 
much documentation as of yet, but here is a small random example:

@ClassRule
public static BQTestFactory TEST_FACTORY = new BQTestFactory();
private static CayenneTestDataManager DATA_MANAGER;

@BeforeClass
public static void beforeClass() {
     BQRuntime app = TEST_FACTORY
             .app("-s", "-c", "classpath:config.yml")
             .autoLoadModules()
             .createRuntime();

     app.run();

     DATA_MANAGER = CayenneTestDataManager.builder(app)
             .doNotDeleteData()
             .entitiesAndDependencies(E1.class, E2.class, E3.class)
             .build();

     
DATA_MANAGER.getTable(E1.class).csvDataSet().load("classpath:e1.csv").persist();
}

@Test
public void testXyz() {
     // send some requests; check the data in DB...

     Table e1 = DATA_MANAGER.getTable(E1.class);
     e1.matcher().assertMatches(4);
}

Andrus

On May 2, 2018, at 10:59 PM, Ken Anderson <[email protected]> wrote:

All,

We’re thinking about setting up an in-memory database in place of SQL Server 
for doing unit tests.  Does anyone have any experience doing this with Cayenne? 
 Any recommendations or warnings?

Thanks,
Ken

Reply via email to