-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b936bb9
commit 866d1ca
Showing
7 changed files
with
81 additions
and
52 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
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
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
29 changes: 29 additions & 0 deletions
29
...main/resources/generator/server/springboot/core/MssqlTestContainerExtension.java.mustache
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,29 @@ | ||
package {{packageName}}; | ||
|
||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.testcontainers.containers.MSSQLServerContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public class MssqlTestContainerExtension implements BeforeAllCallback { | ||
private static AtomicBoolean started = new AtomicBoolean(false); | ||
private static MSSQLServerContainer<?> container = new MSSQLServerContainer<>(DockerImageName.parse("mcr.microsoft.com/mssql/server:latest").asCompatibleSubstituteFor("mcr.microsoft.com/mssql/server")) | ||
.withUrlParam("trustServerCertificate","true") | ||
.acceptLicense(); | ||
@Override | ||
public void beforeAll(ExtensionContext extensionContext) throws Exception { | ||
if (!started.get()) { | ||
container.start(); | ||
System.setProperty("spring.datasource.url", container.getJdbcUrl()); | ||
System.setProperty("spring.datasource.password", container.getPassword()); | ||
System.setProperty("spring.datasource.username", container.getUsername()); | ||
System.setProperty("spring.datasource.driver-class-name","com.microsoft.sqlserver.jdbc.SQLServerDriver"); | ||
started.set(true); | ||
} | ||
} | ||
} |
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
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
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