-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SqlTemplate depends on flyway/liquibase execution
- Loading branch information
Showing
13 changed files
with
1,188 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...org/mybatis/spring/boot/autoconfigure/MybatisDependsOnDatabaseInitializationDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2015-2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.spring.boot.autoconfigure; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import org.mybatis.spring.SqlSessionTemplate; | ||
import org.springframework.boot.sql.init.dependency.AbstractBeansOfTypeDependsOnDatabaseInitializationDetector; | ||
import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector; | ||
|
||
/** | ||
* {@link DependsOnDatabaseInitializationDetector} for Mybatis. | ||
* | ||
* @author Eddú Meléndez | ||
* @since 2.3.0 | ||
*/ | ||
class MybatisDependsOnDatabaseInitializationDetector | ||
extends AbstractBeansOfTypeDependsOnDatabaseInitializationDetector { | ||
|
||
@Override | ||
protected Set<Class<?>> getDependsOnDatabaseInitializationBeanTypes() { | ||
return Collections.singleton(SqlSessionTemplate.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,160 changes: 623 additions & 537 deletions
1,160
...ure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfigurationTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
466 changes: 227 additions & 239 deletions
466
...ava/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfigurationTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...ure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2015-2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.spring.boot.autoconfigure; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages; | ||
import org.springframework.context.annotation.Import; | ||
|
||
/** | ||
* Test annotation to configure the {@link AutoConfigurationPackages} to an arbitrary value. | ||
* | ||
* @author Eddú Meléndez | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Import(TestAutoConfigurationPackageRegistrar.class) | ||
public @interface TestAutoConfigurationPackage { | ||
|
||
Class<?> value(); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...est/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackageRegistrar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2015-2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.spring.boot.autoconfigure; | ||
|
||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; | ||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages; | ||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; | ||
import org.springframework.core.annotation.AnnotationAttributes; | ||
import org.springframework.core.type.AnnotationMetadata; | ||
import org.springframework.util.ClassUtils; | ||
|
||
/** | ||
* {@link ImportBeanDefinitionRegistrar} to store the base package for tests. | ||
* | ||
* @author Eddú Meléndez | ||
*/ | ||
public class TestAutoConfigurationPackageRegistrar implements ImportBeanDefinitionRegistrar { | ||
|
||
@Override | ||
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { | ||
AnnotationAttributes attributes = AnnotationAttributes | ||
.fromMap(metadata.getAnnotationAttributes(TestAutoConfigurationPackage.class.getName(), true)); | ||
AutoConfigurationPackages.register(registry, ClassUtils.getPackageName(attributes.getString("value"))); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | ||
# Copyright 2015-2022 the original author or authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
databaseChangeLog: | ||
- changeSet: | ||
id: 1 | ||
author: dsyer | ||
changes: | ||
- createSequence: | ||
sequenceName: hibernate_sequence | ||
- createTable: | ||
tableName: city | ||
columns: | ||
- column: | ||
name: id | ||
type: bigint | ||
autoIncrement: true | ||
constraints: | ||
primaryKey: true | ||
nullable: false | ||
- column: | ||
name: name | ||
type: varchar(50) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: state | ||
type: varchar(50) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: country | ||
type: varchar(50) | ||
constraints: | ||
nullable: false | ||
- column: | ||
name: map | ||
type: varchar(50) | ||
constraints: | ||
nullable: true |
36 changes: 36 additions & 0 deletions
36
mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Copyright 2015-2022 the original author or authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
databaseChangeLog: | ||
- changeSet: | ||
id: 1 | ||
author: marceloverdijk | ||
changes: | ||
- createTable: | ||
tableName: customer | ||
columns: | ||
- column: | ||
name: id | ||
type: int | ||
autoIncrement: true | ||
constraints: | ||
primaryKey: true | ||
nullable: false | ||
- column: | ||
name: name | ||
type: varchar(50) | ||
constraints: | ||
nullable: false |
39 changes: 39 additions & 0 deletions
39
mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"databaseChangeLog": [ | ||
{ | ||
"changeSet": { | ||
"author": "awilkinson", | ||
"id": "1", | ||
"changes": [ | ||
{ | ||
"createTable": { | ||
"tableName": "customer", | ||
"columns": [ | ||
{ | ||
"column": { | ||
"name": "id", | ||
"type": "int", | ||
"autoIncrement": true, | ||
"constraints": { | ||
"nullable": false, | ||
"primaryKey": true | ||
} | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "name", | ||
"type": "varchar(50)", | ||
"constraints": { | ||
"nullable": false | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- | ||
-- Copyright 2015-2022 the original author or authors. | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
|
||
--liquibase formatted sql | ||
|
||
--changeset author:awilkinson | ||
|
||
CREATE TABLE customer ( | ||
id int AUTO_INCREMENT NOT NULL PRIMARY KEY, | ||
name varchar(50) NOT NULL | ||
); |
37 changes: 37 additions & 0 deletions
37
mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2015-2022 the original author or authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd | ||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> | ||
|
||
<changeSet id="1" author="marceloverdijk"> | ||
<createTable tableName="customer"> | ||
<column name="id" type="int" autoIncrement="true"> | ||
<constraints primaryKey="true" nullable="false"/> | ||
</column> | ||
<column name="name" type="varchar(50)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</createTable> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
17 changes: 17 additions & 0 deletions
17
mybatis-spring-boot-autoconfigure/src/test/resources/db/migration/V1__init.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- | ||
-- Copyright 2015-2022 the original author or authors. | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
|
||
DROP TABLE IF EXISTS TEST; |