diff --git a/README.md b/README.md
index f1768cd..864a377 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,14 @@ The branch named `jpa-query-definition` contains the source code illustrated in
The branch named `jpa-mysql` contains the source code illustrated in the episode [Using a MySQL Database with Spring Data JPA](https://youtu.be/wjpeKiTiuRE?list=PLGDwUiT1wr693flGbjtm0WoB_722X6lNc).
+#### flyway
+
+The branch named `flyway` contains the source code illustrated in the episode [Using Flyway with Spring Boot for Database Migrations](https://youtu.be/5JUJHHc4KZc?list=PLGDwUiT1wr693flGbjtm0WoB_722X6lNc).
+
+#### liquibase
+
+The branch named `liquibase` contains the source code illustrated in the episode [Using Liquibase with Spring Boot for Database Migrations](https://youtu.be/7VeODrRkHXg?list=PLGDwUiT1wr693flGbjtm0WoB_722X6lNc).
+
## Languages
diff --git a/pom.xml b/pom.xml
index f66ef8f..afe42ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
- 1.3.2.RELEASE
+ 1.5.1.RELEASE
@@ -39,7 +39,15 @@
org.jadira.usertype
usertype.extended
- 4.0.0.GA
+ 5.0.0.GA
+
+
+ org.flywaydb
+ flyway-core
+
+
+ org.liquibase
+ liquibase-core
org.hsqldb
@@ -52,15 +60,14 @@
runtime
-
+
org.springframework
spring-context-support
- com.google.guava
- guava
- 19.0
+ com.github.ben-manes.caffeine
+ caffeine
@@ -70,6 +77,11 @@
+
+ com.google.guava
+ guava
+ 19.0
+
joda-time
joda-time
diff --git a/src/main/java/org/example/ws/Application.java b/src/main/java/org/example/ws/Application.java
index e7fb4ed..be33f59 100644
--- a/src/main/java/org/example/ws/Application.java
+++ b/src/main/java/org/example/ws/Application.java
@@ -2,10 +2,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cache.guava.GuavaCacheManager;
-import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -34,18 +31,4 @@ public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
- /**
- * Create a CacheManager implementation class to be used by Spring where
- * @Cacheable
annotations are applied.
- *
- * @return A CacheManager instance.
- */
- @Bean
- public CacheManager cacheManager() {
-
- GuavaCacheManager cacheManager = new GuavaCacheManager("greetings");
-
- return cacheManager;
- }
-
}
diff --git a/src/main/resources/config/application-hsqldb.properties b/src/main/resources/config/application-hsqldb.properties
index a885f87..d3f1006 100644
--- a/src/main/resources/config/application-hsqldb.properties
+++ b/src/main/resources/config/application-hsqldb.properties
@@ -10,7 +10,6 @@
# Hibernate
spring.jpa.hibernate.ddl-auto=validate
-# Initialization
-spring.datasource.schema=classpath:/data/hsqldb/schema.sql
-spring.datasource.data=classpath:/data/hsqldb/data.sql
+# Flyway
+flyway.locations=classpath:/data/hsqldb/migrations
diff --git a/src/main/resources/config/application-mysql.properties b/src/main/resources/config/application-mysql.properties
index 287a086..edbdfa4 100644
--- a/src/main/resources/config/application-mysql.properties
+++ b/src/main/resources/config/application-mysql.properties
@@ -9,23 +9,21 @@
##
# Connection
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
-spring.datasource.url=jdbc:mysql://localhost/greeting
+spring.datasource.url=jdbc:mysql://localhost/greeting?autoReconnect=true&useSSL=false
spring.datasource.username=greetusr
spring.datasource.password=greetpwd
spring.datasource.name=greeting
-# Initialization
-spring.datasource.schema=classpath:/data/mysql/schema.sql
-spring.datasource.data=classpath:/data/mysql/data.sql
-
# Pool
-spring.datasource.initial-size=10
-spring.datasource.max-active=50
-spring.datasource.min-idle=5
-spring.datasource.max-idle=5
+spring.datasource.tomcat.max-active=50
+spring.datasource.tomcat.initial-size=10
+spring.datasource.tomcat.min-idle=5
+
+spring.datasource.tomcat.test-on-borrow=true
+spring.datasource.tomcat.validation-query=select 1;
-spring.datasource.test-on-borrow=true
-spring.datasource.validation-query=select 1;
+spring.datasource.tomcat.time-between-eviction-runs-millis=60000
+spring.datasource.tomcat.min-evictable-idle-time-millis=300000
-spring.datasource.time-between-eviction-runs-millis=60000
-spring.datasource.min-evictable-idle-time-millis=300000
+# Flyway
+flyway.locations=classpath:/data/mysql/migrations
\ No newline at end of file
diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties
index d70dc6b..4b07971 100644
--- a/src/main/resources/config/application.properties
+++ b/src/main/resources/config/application.properties
@@ -14,11 +14,25 @@ spring.profiles.active=hsqldb,batch
# Data Source Configuration
###
# Hibernate
-spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy
+spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
# Jadira
spring.jpa.properties.jadira.usertype.autoRegisterUserTypes=true
+# Flyway
+flyway.enabled=false
+
+# Liquibase
+liquibase.enabled=true
+liquibase.change-log=classpath:/data/changelog/db.changelog-master.xml
+
+
+###
+# Cache Configuration
+###
+spring.cache.cache-names=greetings
+spring.cache.caffeine.spec=maximumSize=250,expireAfterAccess=600s
+
###
# Actuator Configuration
@@ -31,7 +45,7 @@ endpoints.shutdown.sensitive=false
management.context-path=/actuators
-management.security.role=SYSADMIN
+management.security.roles=SYSADMIN
info.app.name=Web Services
info.app.description=A RESTful web services project using Spring Boot.
diff --git a/src/main/resources/data/changelog/db.changelog-0.0.1.xml b/src/main/resources/data/changelog/db.changelog-0.0.1.xml
new file mode 100644
index 0000000..9b65db4
--- /dev/null
+++ b/src/main/resources/data/changelog/db.changelog-0.0.1.xml
@@ -0,0 +1,188 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'user' and r.code = 'ROLE_USER'
+
+
+ INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'operations' and r.code = 'ROLE_SYSADMIN'
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/data/changelog/db.changelog-0.1.0.xml b/src/main/resources/data/changelog/db.changelog-0.1.0.xml
new file mode 100644
index 0000000..6b36cc2
--- /dev/null
+++ b/src/main/resources/data/changelog/db.changelog-0.1.0.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/data/changelog/db.changelog-master.xml b/src/main/resources/data/changelog/db.changelog-master.xml
new file mode 100644
index 0000000..8672ea2
--- /dev/null
+++ b/src/main/resources/data/changelog/db.changelog-master.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/data/hsqldb/data.sql b/src/main/resources/data/hsqldb/migrations/V0_0_1__initialize.sql
similarity index 50%
rename from src/main/resources/data/hsqldb/data.sql
rename to src/main/resources/data/hsqldb/migrations/V0_0_1__initialize.sql
index 3bfaaa5..a19ccae 100644
--- a/src/main/resources/data/hsqldb/data.sql
+++ b/src/main/resources/data/hsqldb/migrations/V0_0_1__initialize.sql
@@ -1,8 +1,68 @@
/*
- * HSQLDB script.
- * Load the database with reference data and unit test data.
+ * Engine: HSQLDB
+ * Version: 0.0.1
+ * Description: Initial database structure and data.
*/
+/*
+ * Structure
+ */
+
+CREATE TABLE Greeting (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
+ referenceId VARCHAR(255) NOT NULL,
+ text VARCHAR(100) NOT NULL,
+ version INT NOT NULL,
+ createdBy VARCHAR(100) NOT NULL,
+ createdAt DATETIME NOT NULL,
+ updatedBy VARCHAR(100) DEFAULT NULL,
+ updatedAt DATETIME DEFAULT NULL,
+ PRIMARY KEY(id),
+ CONSTRAINT UQ_Greeting_ReferenceId UNIQUE (referenceId)
+);
+
+CREATE TABLE Account (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
+ referenceId VARCHAR(255) NOT NULL,
+ username VARCHAR(100) NOT NULL,
+ password VARCHAR(200) NOT NULL,
+ enabled BOOLEAN DEFAULT true NOT NULL,
+ credentialsexpired BOOLEAN DEFAULT false NOT NULL,
+ expired BOOLEAN DEFAULT false NOT NULL,
+ locked BOOLEAN DEFAULT false NOT NULL,
+ version INT NOT NULL,
+ createdBy VARCHAR(100) NOT NULL,
+ createdAt DATETIME NOT NULL,
+ updatedBy VARCHAR(100) DEFAULT NULL,
+ updatedAt DATETIME DEFAULT NULL,
+ PRIMARY KEY (id),
+ CONSTRAINT UQ_Account_ReferenceId UNIQUE (referenceId),
+ CONSTRAINT UQ_Account_Username UNIQUE (username)
+);
+
+CREATE TABLE Role (
+ id BIGINT NOT NULL,
+ code VARCHAR(50) NOT NULL,
+ label VARCHAR(100) NOT NULL,
+ ordinal INT NOT NULL,
+ effectiveAt DATETIME NOT NULL,
+ expiresAt DATETIME DEFAULT NULL,
+ createdAt DATETIME NOT NULL,
+ PRIMARY KEY (id),
+ CONSTRAINT UQ_Role_Code UNIQUE (code)
+);
+
+CREATE TABLE AccountRole (
+ accountId BIGINT NOT NULL,
+ roleId BIGINT NOT NULL,
+ PRIMARY KEY (accountId, roleId),
+ CONSTRAINT FK_AccountRole_AccountId FOREIGN KEY (accountId) REFERENCES Account (id),
+ CONSTRAINT FK_AccountRole_RoleId FOREIGN KEY (roleId) REFERENCES Role (id)
+);
+
+/*
+ * Data
+ */
INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('1e0d5287-67fd-4043-9ac4-b8d358d6d7ce', 'Hello World!', 0, 'user', NOW(), NULL, NULL);
INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('37c3178d-3b49-47b6-99d1-277b1a3e8df8', 'Hola Mundo!', 0, 'user', NOW(), NULL, NULL);
@@ -18,3 +78,5 @@ INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) V
INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'user' and r.id = 1;
INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'operations' and r.id = 3;
+
+
diff --git a/src/main/resources/data/hsqldb/migrations/V0_1_0__migration.sql b/src/main/resources/data/hsqldb/migrations/V0_1_0__migration.sql
new file mode 100644
index 0000000..14de33d
--- /dev/null
+++ b/src/main/resources/data/hsqldb/migrations/V0_1_0__migration.sql
@@ -0,0 +1,17 @@
+/*
+ * Engine: HSQLDB
+ * Version: 0.1.0
+ * Description:
+ * Database changes for version 0.1.0.
+ */
+
+/*
+ * Structure
+ */
+
+/*
+ * Data
+ */
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('e1707cf6-2aa4-4745-b04f-c9e03dc0a660', 'Howdy', 0, 'user', NOW(), NULL, NULL);
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('09aafc85-39d3-40f3-a09d-246a48ee71d1', 'Hi', 0, 'user', NOW(), NULL, NULL);
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('40cfa2c0-dd9a-4e94-8768-daeb1a483069', 'Whats Up?', 0, 'user', NOW(), NULL, NULL);
diff --git a/src/main/resources/data/hsqldb/schema.sql b/src/main/resources/data/hsqldb/schema.sql
deleted file mode 100644
index 62db1c0..0000000
--- a/src/main/resources/data/hsqldb/schema.sql
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * HSQLDB script.
- * Create the database schema for the application.
- */
-
-DROP TABLE Greeting IF EXISTS;
-
-CREATE TABLE Greeting (
- id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
- referenceId VARCHAR(255) NOT NULL,
- text VARCHAR(100) NOT NULL,
- version INT NOT NULL,
- createdBy VARCHAR(100) NOT NULL,
- createdAt DATETIME NOT NULL,
- updatedBy VARCHAR(100) DEFAULT NULL,
- updatedAt DATETIME DEFAULT NULL,
- PRIMARY KEY(id),
- CONSTRAINT UQ_Greeting_ReferenceId UNIQUE (referenceId)
-);
-
-
-DROP TABLE AccountRole IF EXISTS;
-DROP TABLE Account IF EXISTS;
-DROP TABLE Role IF EXISTS;
-
-CREATE TABLE Account (
- id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
- referenceId VARCHAR(255) NOT NULL,
- username VARCHAR(100) NOT NULL,
- password VARCHAR(200) NOT NULL,
- enabled BOOLEAN DEFAULT true NOT NULL,
- credentialsexpired BOOLEAN DEFAULT false NOT NULL,
- expired BOOLEAN DEFAULT false NOT NULL,
- locked BOOLEAN DEFAULT false NOT NULL,
- version INT NOT NULL,
- createdBy VARCHAR(100) NOT NULL,
- createdAt DATETIME NOT NULL,
- updatedBy VARCHAR(100) DEFAULT NULL,
- updatedAt DATETIME DEFAULT NULL,
- PRIMARY KEY (id),
- CONSTRAINT UQ_Account_ReferenceId UNIQUE (referenceId),
- CONSTRAINT UQ_Account_Username UNIQUE (username)
-);
-
-CREATE TABLE Role (
- id BIGINT NOT NULL,
- code VARCHAR(50) NOT NULL,
- label VARCHAR(100) NOT NULL,
- ordinal INT NOT NULL,
- effectiveAt DATETIME NOT NULL,
- expiresAt DATETIME DEFAULT NULL,
- createdAt DATETIME NOT NULL,
- PRIMARY KEY (id),
- CONSTRAINT UQ_Role_Code UNIQUE (code)
-);
-
-CREATE TABLE AccountRole (
- accountId BIGINT NOT NULL,
- roleId BIGINT NOT NULL,
- PRIMARY KEY (accountId, roleId),
- CONSTRAINT FK_AccountRole_AccountId FOREIGN KEY (accountId) REFERENCES Account (id),
- CONSTRAINT FK_AccountRole_RoleId FOREIGN KEY (roleId) REFERENCES Role (id)
-);
diff --git a/src/main/resources/data/mysql/data.sql b/src/main/resources/data/mysql/data.sql
deleted file mode 100644
index 8791b23..0000000
--- a/src/main/resources/data/mysql/data.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * MySQL script.
- * Load the database with reference data and unit test data.
- */
-
-INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('1e0d5287-67fd-4043-9ac4-b8d358d6d7ce', 'Hello World!', 0, 'user', NOW(), NULL, NULL);
-INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('37c3178d-3b49-47b6-99d1-277b1a3e8df8', 'Hola Mundo!', 0, 'user', NOW(), NULL, NULL);
-
-
--- password is 'password'
-INSERT INTO Account (referenceId, username, password, enabled, credentialsexpired, expired, locked, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('a07bd221-3ecd-4893-a0f0-78d7c0fbf94e', 'user', '$2a$10$9/44Rne7kQqPXa0cY6NfG.3XzScMrCxFYjapoLq/wFmHz7EC9praK', true, false, false, false, 0, 'user', NOW(), NULL, NULL);
--- password is 'operations'
-INSERT INTO Account (referenceId, username, password, enabled, credentialsexpired, expired, locked, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('7bd137c8-ab64-4a45-bf2d-d9bae3574622', 'operations', '$2a$10$CoMVfutnv1qZ.fNlHY1Na.rteiJhsDF0jB1o.76qXcfdWN6As27Zm', true, false, false, false, 0, 'user', NOW(), NULL, NULL);
-
-INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) VALUES (1, 'ROLE_USER', 'User', 0, '2015-01-01 00:00:00', NULL, NOW());
-INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) VALUES (2, 'ROLE_ADMIN', 'Admin', 1, '2015-01-01 00:00:00', NULL, NOW());
-INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) VALUES (3, 'ROLE_SYSADMIN', 'System Admin', 2, '2015-01-01 00:00:00', NULL, NOW());
-
-INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'user' and r.id = 1;
-INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'operations' and r.id = 3;
diff --git a/src/main/resources/data/mysql/schema.sql b/src/main/resources/data/mysql/migrations/V0_0_1__initialize.sql
similarity index 50%
rename from src/main/resources/data/mysql/schema.sql
rename to src/main/resources/data/mysql/migrations/V0_0_1__initialize.sql
index 22b038e..74b26c5 100644
--- a/src/main/resources/data/mysql/schema.sql
+++ b/src/main/resources/data/mysql/migrations/V0_0_1__initialize.sql
@@ -1,9 +1,12 @@
/*
- * MySQL script.
- * Create the database schema for the application.
+ * Engine: MySQL
+ * Version: 0.0.1
+ * Description: Initial database structure and data.
*/
-DROP TABLE IF EXISTS `Greeting`;
+/*
+ * Structure
+ */
CREATE TABLE `Greeting` (
`id` bigint(20) unsigned NOT NULL auto_increment,
@@ -18,11 +21,6 @@ CREATE TABLE `Greeting` (
CONSTRAINT `UQ_Greeting_ReferenceId` UNIQUE (`referenceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-DROP TABLE IF EXISTS `AccountRole`;
-DROP TABLE IF EXISTS `Account`;
-DROP TABLE IF EXISTS `Role`;
-
CREATE TABLE `Account` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`referenceId` varchar(255) NOT NULL,
@@ -61,3 +59,22 @@ CREATE TABLE `AccountRole` (
CONSTRAINT `FK_AccountRole_AccountId` FOREIGN KEY (`accountId`) REFERENCES `Account` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK_AccountRole_RoleId` FOREIGN KEY (`roleId`) REFERENCES `Role` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+/*
+ * Data
+ */
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('1e0d5287-67fd-4043-9ac4-b8d358d6d7ce', 'Hello World!', 0, 'user', NOW(), NULL, NULL);
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('37c3178d-3b49-47b6-99d1-277b1a3e8df8', 'Hola Mundo!', 0, 'user', NOW(), NULL, NULL);
+
+
+-- password is 'password'
+INSERT INTO Account (referenceId, username, password, enabled, credentialsexpired, expired, locked, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('a07bd221-3ecd-4893-a0f0-78d7c0fbf94e', 'user', '$2a$10$9/44Rne7kQqPXa0cY6NfG.3XzScMrCxFYjapoLq/wFmHz7EC9praK', true, false, false, false, 0, 'user', NOW(), NULL, NULL);
+-- password is 'operations'
+INSERT INTO Account (referenceId, username, password, enabled, credentialsexpired, expired, locked, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('7bd137c8-ab64-4a45-bf2d-d9bae3574622', 'operations', '$2a$10$CoMVfutnv1qZ.fNlHY1Na.rteiJhsDF0jB1o.76qXcfdWN6As27Zm', true, false, false, false, 0, 'user', NOW(), NULL, NULL);
+
+INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) VALUES (1, 'ROLE_USER', 'User', 0, '2015-01-01 00:00:00', NULL, NOW());
+INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) VALUES (2, 'ROLE_ADMIN', 'Admin', 1, '2015-01-01 00:00:00', NULL, NOW());
+INSERT INTO Role (id, code, label, ordinal, effectiveAt, expiresAt, createdAt) VALUES (3, 'ROLE_SYSADMIN', 'System Admin', 2, '2015-01-01 00:00:00', NULL, NOW());
+
+INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'user' and r.id = 1;
+INSERT INTO AccountRole (accountId, roleId) SELECT a.id, r.id FROM Account a, Role r WHERE a.username = 'operations' and r.id = 3;
diff --git a/src/main/resources/data/mysql/migrations/V0_1_0__migration.sql b/src/main/resources/data/mysql/migrations/V0_1_0__migration.sql
new file mode 100644
index 0000000..6622b8f
--- /dev/null
+++ b/src/main/resources/data/mysql/migrations/V0_1_0__migration.sql
@@ -0,0 +1,17 @@
+/*
+ * Engine: MySQL
+ * Version: 0.1.0
+ * Description:
+ * Database changes for version 0.1.0.
+ */
+
+/*
+ * Structure
+ */
+
+/*
+ * Data
+ */
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('e1707cf6-2aa4-4745-b04f-c9e03dc0a660', 'Howdy', 0, 'user', NOW(), NULL, NULL);
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('09aafc85-39d3-40f3-a09d-246a48ee71d1', 'Hi', 0, 'user', NOW(), NULL, NULL);
+INSERT INTO Greeting (referenceId, text, version, createdBy, createdAt, updatedBy, updatedAt) VALUES ('40cfa2c0-dd9a-4e94-8768-daeb1a483069', 'Whats Up?', 0, 'user', NOW(), NULL, NULL);
diff --git a/src/test/java/org/example/ws/AbstractTest.java b/src/test/java/org/example/ws/AbstractTest.java
index abe0d04..82816fe 100644
--- a/src/test/java/org/example/ws/AbstractTest.java
+++ b/src/test/java/org/example/ws/AbstractTest.java
@@ -4,8 +4,8 @@
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.test.SpringApplicationConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
/**
* The AbstractTest class is the parent of all JUnit test classes. This class
@@ -13,8 +13,8 @@
*
* @author Matt Warman
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringApplicationConfiguration(
+@RunWith(SpringRunner.class)
+@SpringBootTest(
classes = Application.class)
public abstract class AbstractTest {
diff --git a/src/test/java/org/example/ws/service/GreetingServiceTest.java b/src/test/java/org/example/ws/service/GreetingServiceTest.java
index cadf28b..7743736 100644
--- a/src/test/java/org/example/ws/service/GreetingServiceTest.java
+++ b/src/test/java/org/example/ws/service/GreetingServiceTest.java
@@ -42,7 +42,7 @@ public void testFindAll() {
Collection list = service.findAll();
Assert.assertNotNull("failure - expected not null", list);
- Assert.assertEquals("failure - expected list size", 2, list.size());
+ Assert.assertEquals("failure - expected list size", 5, list.size());
}
@@ -86,7 +86,7 @@ public void testCreate() {
Collection list = service.findAll();
- Assert.assertEquals("failure - expected size", 3, list.size());
+ Assert.assertEquals("failure - expected size", 6, list.size());
}
@@ -166,7 +166,7 @@ public void testDelete() {
Collection list = service.findAll();
- Assert.assertEquals("failure - expected size", 1, list.size());
+ Assert.assertEquals("failure - expected size", 4, list.size());
Greeting deletedEntity = service.findOne(id);