mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Automated SQL Server management via Docker
This commit is contained in:
39
integration-tests/jpa-mssql/README.md
Normal file
39
integration-tests/jpa-mssql/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# JPA example with Microsoft SQL Server
|
||||
|
||||
## Running the tests
|
||||
|
||||
By default, the tests of this module are disabled.
|
||||
|
||||
To run the tests in a standard JVM with SQL Server started as a Docker container, you can run the following command:
|
||||
|
||||
```
|
||||
mvn clean install -Ddocker -Dtest-mssql
|
||||
```
|
||||
|
||||
To also test as a native image, add `-Dnative`:
|
||||
|
||||
```
|
||||
mvn clean install -Ddocker -Dtest-mssql -Dnative
|
||||
```
|
||||
|
||||
Alternatively you can connect to your own SQL Server.
|
||||
Reconfigure the connection URL with `-Dmssqldb.url=jdbc:sqlserver://...`;
|
||||
you'll probably want to change the authentication password too: `-Dmssqldb.sa-password=NotS0Secret`.
|
||||
|
||||
## Limitations
|
||||
|
||||
### Active Directory
|
||||
|
||||
Authentication to the server via Active Directory is a feature of the official JDBC driver, but this was disabled in Quarkus so to minimize the dependencies.
|
||||
|
||||
If you really need this feature, please let us know.
|
||||
|
||||
### Localization, Encoding an Character sets
|
||||
|
||||
SQL Server by default uses collation `SQL_Latin1_General_CP1_CI_AS` ; attempting to use this in a native-image will result in an error:
|
||||
|
||||
java.io.UnsupportedEncodingException: "Codepage Cp1252 is not supported by the Java environment."
|
||||
|
||||
The solution is simple: you'll need to make sure your native images contains additional, non-default character sets.
|
||||
|
||||
Just set the flag `addAllCharsets` in the `native-image` configuration of your favourite build tool.
|
||||
@@ -29,6 +29,12 @@
|
||||
<artifactId>quarkus-integration-test-jpa-mssql</artifactId>
|
||||
<name>Quarkus - Integration Tests - JPA - MSSQL</name>
|
||||
<description>Module that contains JPA related tests running in strict mode with the MSSQL database</description>
|
||||
|
||||
<properties>
|
||||
<mssqldb.url>SomeJDBCUrl</mssqldb.url>
|
||||
<mssqldb.sa-password>SomeJDBCPassword</mssqldb.sa-password>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Enables the JPA capabilities -->
|
||||
<dependency>
|
||||
@@ -70,6 +76,18 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>quarkus-maven-plugin</artifactId>
|
||||
@@ -85,6 +103,31 @@
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>test-mssql</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>test-mssql</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>native-image</id>
|
||||
<activation>
|
||||
@@ -141,6 +184,78 @@
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>docker-mssql</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>docker</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<mssqldb.url>jdbc:sqlserver://localhost:1433;databaseName=tempdb</mssqldb.url>
|
||||
<!-- Careful: SQL Server refuses to work with trivial passwords. -->
|
||||
<mssqldb.sa-password>ActuallyRequired11Complexity</mssqldb.sa-password>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<images>
|
||||
<image>
|
||||
<name>microsoft/mssql-server-linux:2017-CU12</name>
|
||||
<alias>quarkus-test-mssqldb</alias>
|
||||
<run>
|
||||
<ports>
|
||||
<port>1433:1433</port>
|
||||
</ports>
|
||||
<env>
|
||||
<ACCEPT_EULA>Y</ACCEPT_EULA>
|
||||
<SA_PASSWORD>ActuallyRequired11Complexity</SA_PASSWORD>
|
||||
</env>
|
||||
<log>
|
||||
<prefix>MS SQL Server:</prefix>
|
||||
<date>default</date>
|
||||
<color>cyan</color>
|
||||
</log>
|
||||
<wait>
|
||||
<!-- good docs found at: http://dmp.fabric8.io/#build-healthcheck -->
|
||||
<tcp>
|
||||
<mode>direct</mode>
|
||||
<ports>
|
||||
<port>1433</port>
|
||||
</ports>
|
||||
</tcp>
|
||||
<!-- Unfortunately booting this is slow, needs to set a generous timeout: -->
|
||||
<time>40000</time>
|
||||
</wait>
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>docker-start</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>docker-stop</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
quarkus.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=tempdb
|
||||
quarkus.datasource.url=${mssqldb.url}
|
||||
quarkus.datasource.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
quarkus.datasource.username=sa
|
||||
quarkus.datasource.password=ActuallyRequired11Complexity
|
||||
quarkus.datasource.password=${mssqldb.sa-password}
|
||||
quarkus.datasource.max-size=8
|
||||
quarkus.datasource.min-size=2
|
||||
quarkus.hibernate-orm.dialect=org.hibernate.dialect.SQLServer2012Dialect
|
||||
|
||||
Reference in New Issue
Block a user