Permalink
Browse files

added Task model, in-memory database config, and test

  • Loading branch information...
1 parent b184d2e commit 51377586abf96ed64d02f03a7042bb24d14055ed @jamesward committed Apr 1, 2015
Showing with 69 additions and 3 deletions.
  1. +16 −0 app/models/Task.java
  2. +3 −3 conf/application.conf
  3. +26 −0 conf/evolutions/default/1.sql
  4. +24 −0 test/TaskTest.java
View
@@ -0,0 +1,16 @@
+package models;
+
+import play.db.ebean.Model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Task extends Model {
+
+ @Id
+ public String id;
+
+ public String contents;
+
+}
@@ -36,8 +36,8 @@ application.langs="en"
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
-# db.default.driver=org.h2.Driver
-# db.default.url="jdbc:h2:mem:play"
+db.default.driver=org.h2.Driver
+db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=""
#
@@ -54,7 +54,7 @@ application.langs="en"
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
#
-# ebean.default="models.*"
+ebean.default="models.*"
# Logger
# ~~~~~
@@ -0,0 +1,26 @@
+# --- Created by Ebean DDL
+# To stop Ebean DDL generation, remove this comment and start using Evolutions
+
+# --- !Ups
+
+create table task (
+ id varchar(255) not null,
+ contents varchar(255),
+ constraint pk_task primary key (id))
+;
+
+create sequence task_seq;
+
+
+
+
+# --- !Downs
+
+SET REFERENTIAL_INTEGRITY FALSE;
+
+drop table if exists task;
+
+SET REFERENTIAL_INTEGRITY TRUE;
+
+drop sequence if exists task_seq;
+
View
@@ -0,0 +1,24 @@
+import org.junit.Test;
+
+import static play.test.Helpers.fakeApplication;
+import static play.test.Helpers.running;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+import models.Task;
+
+public class TaskTest {
+
+ @Test
+ public void create() {
+ running(fakeApplication(), new Runnable() {
+ public void run() {
+ Task task = new Task();
+ task.contents = "Write a test";
+ task.save();
+ assertThat(task.id).isNotNull();
+ }
+ });
+ }
+
+}

0 comments on commit 5137758

Please sign in to comment.