Play framework integration: wrong DB evolutions with JUnit tests

Hello,

I am using Intellij 15.0.2 (linux, 64 bit) and have noticed a strange problem with play 2.3.7 and 2.4.6 with respect to differences in database evolutions applied when running the app and when testing with JUnit. Specifically, things work fine while running (with a Play 2 App run configuration or from the activator console) with respect to my DB evolutions.  However when I run a JUnit test from inside IntelliJ, it seems like a different evolution takes place.

In my situation, I have a evolution script (1.sql) that creates a table and alters it so that certain columns have default values. This works fine (on an H2 database running in server mode).  However when I then run a JUnit script that hits this DB, some other SQL script is running that changes the order of the columns and does not run the ALTER statements.  I do not know where this DDL  is coming from. It almost seems like Intellij is  dropping the table, and then using the Java object I am testing to recreate the specific table.  Evidence of this behaviour comes from the order of the columns, which is similar to that of the object.

Things work fine if I remove the evolutions from the play project or if I skip Intellij and just run the JUnit test from the activator console.  It would be nice to be able to run  Junit tests in Intellij and have them work consistently with the rest fo the framework.

I am new to play (and Intellij 15) so maybe I have something configured wrong. Any insight appreciated.


- chooks

5 comments
Comment actions Permalink

Hello,

is your project open source?

0
Comment actions Permalink

To call what I am doing a project is probably being generous :) I  am just trying to learn Play with Intellij - I am using the computer-database-java play template and trying to add model classes and associated JUnit tests.

I can attach my model classes, evolution scripts, and JUnit test if that would be helpful.

Also - everything works fine from the activator console.  I can even attach IJ's remote debugger to the activator console so I can interactively debug the app/unit tests (all of which work fine).  It seems to only be when I try to run the JUnit test in  IJ that issues show up.

0
Comment actions Permalink

Yes, it would be very helpful as looks like I can't reproduce it

0
Comment actions Permalink

Part 2 of 2.


To get to where I am, create an activator project with computer-database-java template and import into Idea.

AuditableModel and Case go in the app/model package
build.sbt in the root
application.conf in conf
1.sql and 2.sql in conf/evolutions/default

you will probably need to change the H2 database from a server to an in-memory database (which is commented out)



Attachment(s):
2.sql.zip
1.sql.zip
0

Please sign in to leave a comment.