diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/com/juick/config/DataSourceAutoConfiguration.java | 50 | ||||
-rw-r--r-- | src/test/resources/application-mysql.yml | 12 | ||||
-rw-r--r-- | src/test/resources/application-postgres.yml | 12 | ||||
-rw-r--r-- | src/test/resources/db/specific/mariadb/V1.00__schema.sql (renamed from src/test/resources/schema-mysql.sql) | 0 | ||||
-rw-r--r-- | src/test/resources/db/specific/mariadb/V1.23__data.sql | 13 | ||||
-rw-r--r-- | src/test/resources/db/specific/postgresql/V1.00__schema.sql (renamed from src/test/resources/schema-postgres.sql) | 9 | ||||
-rw-r--r-- | src/test/resources/db/specific/postgresql/V1.23__data.sql | 13 |
7 files changed, 44 insertions, 65 deletions
diff --git a/src/test/java/com/juick/config/DataSourceAutoConfiguration.java b/src/test/java/com/juick/config/DataSourceAutoConfiguration.java deleted file mode 100644 index 1b88d577..00000000 --- a/src/test/java/com/juick/config/DataSourceAutoConfiguration.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008-2019, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package com.juick.config; - -import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; - -import javax.sql.DataSource; - -@Configuration -@ConfigurationProperties("spring.datasource") -@ConditionalOnProperty(value = "spring.datasource.platform", havingValue = "mysql") -public class DataSourceAutoConfiguration { - - @Bean - MariaDB4jSpringService mariaDB4j() { - return new MariaDB4jSpringService(); - } - - @Bean - @DependsOn("mariaDB4j") - DataSource dataSource(DataSourceProperties dataSourceProperties) { - return DataSourceBuilder.create() - .driverClassName(dataSourceProperties.getDriverClassName()) - .url(dataSourceProperties.getUrl()) - .username(dataSourceProperties.getUsername()) - .password(dataSourceProperties.getPassword()) - .build(); - } -} diff --git a/src/test/resources/application-mysql.yml b/src/test/resources/application-mysql.yml index 2203714f..e55a292f 100644 --- a/src/test/resources/application-mysql.yml +++ b/src/test/resources/application-mysql.yml @@ -1,13 +1,13 @@ spring: datasource: - platform: mysql - initialization-mode: always driver-class-name: org.mariadb.jdbc.Driver - url: jdbc:mariadb://localhost:${mariaDB4j.port}/test?zeroDateTimeBehavior=convertToNull&useMysqlMetadata=true + url: jdbc:mariadb://localhost:3306/juick?zeroDateTimeBehavior=convertToNull username: root - password: + password: secret flyway: baseline-on-migrate: true + sql: + init: + platform: mysql + mode: always -mariaDB4j: - port: 3307
\ No newline at end of file diff --git a/src/test/resources/application-postgres.yml b/src/test/resources/application-postgres.yml new file mode 100644 index 00000000..b75b1e50 --- /dev/null +++ b/src/test/resources/application-postgres.yml @@ -0,0 +1,12 @@ +spring: + datasource: + url: jdbc:postgresql://localhost:5432/juick?stringtype=unspecified + username: juick + password: secret + flyway: + baseline-on-migrate: true + sql: + init: + platform: postgresql + mode: always + diff --git a/src/test/resources/schema-mysql.sql b/src/test/resources/db/specific/mariadb/V1.00__schema.sql index d30cd9f7..d30cd9f7 100644 --- a/src/test/resources/schema-mysql.sql +++ b/src/test/resources/db/specific/mariadb/V1.00__schema.sql diff --git a/src/test/resources/db/specific/mariadb/V1.23__data.sql b/src/test/resources/db/specific/mariadb/V1.23__data.sql new file mode 100644 index 00000000..a5db173a --- /dev/null +++ b/src/test/resources/db/specific/mariadb/V1.23__data.sql @@ -0,0 +1,13 @@ +INSERT INTO users(id, nick, passw) VALUES(0, 'Anonymous', 'password'); +INSERT INTO users(id, nick, passw) VALUES(2, 'juick', 'password'); +INSERT INTO users(id, nick, passw) VALUES(5, 'archive', 'password'); +INSERT INTO tags(tag_id, name) VALUES(2, 'juick'); +ALTER TABLE tags AUTO_INCREMENT = 10; +ALTER TABLE users AUTO_INCREMENT = 10; +INSERT INTO reactions (like_id, description) VALUES (1, 'like'); +INSERT INTO reactions (like_id, description) VALUES (2, 'love'); +INSERT INTO reactions (like_id, description) VALUES (3, 'lol'); +INSERT INTO reactions (like_id, description) VALUES (4, 'hmm'); +INSERT INTO reactions (like_id, description) VALUES (5, 'angry'); +INSERT INTO reactions (like_id, description) VALUES (6, 'uhblya'); +INSERT INTO reactions (like_id, description) VALUES (7, 'ugh'); diff --git a/src/test/resources/schema-postgres.sql b/src/test/resources/db/specific/postgresql/V1.00__schema.sql index 7c4406f0..4909000a 100644 --- a/src/test/resources/schema-postgres.sql +++ b/src/test/resources/db/specific/postgresql/V1.00__schema.sql @@ -1500,15 +1500,6 @@ CREATE INDEX idx_29422_message_id ON favorites USING btree (message_id); CREATE INDEX idx_29422_user_id ON favorites USING btree (user_id); --- --- Name: public; Type: ACL; Schema: -; Owner: postgres --- - -REVOKE ALL ON SCHEMA public FROM PUBLIC; -REVOKE ALL ON SCHEMA public FROM postgres; -GRANT ALL ON SCHEMA public TO postgres; -GRANT ALL ON SCHEMA public TO PUBLIC; - -- -- PostgreSQL database dump complete diff --git a/src/test/resources/db/specific/postgresql/V1.23__data.sql b/src/test/resources/db/specific/postgresql/V1.23__data.sql new file mode 100644 index 00000000..673b24d2 --- /dev/null +++ b/src/test/resources/db/specific/postgresql/V1.23__data.sql @@ -0,0 +1,13 @@ +INSERT INTO users(id, nick, passw) VALUES(0, 'Anonymous', 'password'); +INSERT INTO users(id, nick, passw) VALUES(2, 'juick', 'password'); +INSERT INTO users(id, nick, passw) VALUES(5, 'archive', 'password'); +INSERT INTO tags(tag_id, name) VALUES(2, 'juick'); +alter sequence tags_tag_id_seq restart with 10; +alter sequence users_id_seq restart with 10; +INSERT INTO reactions (like_id, description) VALUES (1, 'like'); +INSERT INTO reactions (like_id, description) VALUES (2, 'love'); +INSERT INTO reactions (like_id, description) VALUES (3, 'lol'); +INSERT INTO reactions (like_id, description) VALUES (4, 'hmm'); +INSERT INTO reactions (like_id, description) VALUES (5, 'angry'); +INSERT INTO reactions (like_id, description) VALUES (6, 'uhblya'); +INSERT INTO reactions (like_id, description) VALUES (7, 'ugh'); |