-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for JDBC DB2 extension
- Loading branch information
Showing
19 changed files
with
778 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# JPA example with DB2 | ||
|
||
## Running the tests | ||
|
||
By default, the tests of this module are disabled. | ||
|
||
To run the tests in a standard JVM with DB2 started as a Docker container, you can run the following command: | ||
|
||
``` | ||
mvn verify -Dtest-db2 -Ddocker | ||
``` | ||
|
||
Additionally, you can generate a native image and run the tests for this native image by adding `-Dnative`: | ||
|
||
``` | ||
mvn verify -Dtest-db2 -Ddocker -Dnative | ||
``` | ||
|
||
## To manually run an equivalent DB2 container instead of through Testcontainers, do the following: | ||
|
||
1. Start DB2 in a container | ||
|
||
``` | ||
docker run \ | ||
-e DBNAME=hreact \ | ||
-e DB2INSTANCE=hreact \ | ||
-e DB2INST1_PASSWORD=hreact \ | ||
-e AUTOCONFIG=false \ | ||
-e ARCHIVE_LOGS=false \ | ||
-e LICENSE=accept \ | ||
-p 50000:50000 \ | ||
--privileged \ | ||
ibmcom/db2:11.5.0.0a | ||
``` | ||
|
||
2. Run the test, specifying the JDBC URL for the container you started in the previous step | ||
|
||
``` | ||
mvn verify -Dtest-db2 -Djdbc-db2.url=jdbc:db2://localhost:50000/hreact | ||
``` |
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,247 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-integration-test-jpa-db2</artifactId> | ||
<name>Quarkus - Integration Tests - JPA - DB2</name> | ||
<description>Module that contains JPA related tests running with the DB2 database</description> | ||
|
||
<properties> | ||
<jdbc-db2.url>jdbc:db2://localhost:50000/hreact</jdbc-db2.url> | ||
<db2.image>ibmcom/db2:11.5.0.0a</db2.image> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-undertow</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-hibernate-orm</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jdbc-db2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</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>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>test-db2</id> | ||
<activation> | ||
<property> | ||
<name>test-db2</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> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<native.image.path> | ||
${project.build.directory}/${project.build.finalName}-runner | ||
</native.image.path> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>native-image</id> | ||
<goals> | ||
<goal>native-image</goal> | ||
</goals> | ||
<configuration> | ||
<cleanupServer>true</cleanupServer> | ||
<enableHttpUrlHandler>true</enableHttpUrlHandler> | ||
<graalvmHome>${graalvmHome}</graalvmHome> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>docker-db2</id> | ||
<activation> | ||
<property> | ||
<name>docker</name> | ||
</property> | ||
</activation> | ||
<properties> | ||
<jdbc-db2.url>jdbc:db2://localhost:50005/hreact</jdbc-db2.url> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<configuration> | ||
<images> | ||
<image> | ||
<name>${db2.image}</name> | ||
<alias>quarkus-test-db2</alias> | ||
<run> | ||
<network> | ||
<mode>bridge</mode> | ||
</network> | ||
<privileged>true</privileged> | ||
<ports> | ||
<port>50005:50000</port> | ||
</ports> | ||
<env> | ||
<DB2INSTANCE>hreact</DB2INSTANCE> | ||
<DB2INST1_PASSWORD>hreact</DB2INST1_PASSWORD> | ||
<DBNAME>hreact</DBNAME> | ||
<LICENSE>accept</LICENSE> | ||
<!-- These help the DB2 container start faster --> | ||
<AUTOCONFIG>false</AUTOCONFIG> | ||
<ARCHIVE_LOGS>false</ARCHIVE_LOGS> | ||
</env> | ||
<log> | ||
<prefix>DB2:</prefix> | ||
<date>default</date> | ||
<color>cyan</color> | ||
</log> | ||
<wait> | ||
<!-- good docs found at: http://dmp.fabric8.io/#build-healthcheck --> | ||
<log>.*Setup has completed\..*</log> | ||
<!-- Unfortunately booting DB2 is slow, needs to set a generous (10m) timeout: --> | ||
<time>600000</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> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>docker-prune</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
<configuration> | ||
<executable>${basedir}/../../.github/docker-prune.sh</executable> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
42 changes: 42 additions & 0 deletions
42
integration-tests/jpa-db2/src/main/java/io/quarkus/it/jpa/db2/Address.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,42 @@ | ||
package io.quarkus.it.jpa.db2; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
/** | ||
* This is an enmarked @Embeddable class. | ||
* Let's see if just being referenced by the main entity is enough to be detected. | ||
* | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
//FIXME : this used to be non-annotated explicitly for testing purposes | ||
// added the annotation as it's illegal according to the ORM metadata validation | ||
@Embeddable | ||
public class Address { | ||
private String street1; | ||
private String street2; | ||
private String zipCode; | ||
|
||
public String getStreet1() { | ||
return street1; | ||
} | ||
|
||
public void setStreet1(String street1) { | ||
this.street1 = street1; | ||
} | ||
|
||
public String getStreet2() { | ||
return street2; | ||
} | ||
|
||
public void setStreet2(String street2) { | ||
this.street2 = street2; | ||
} | ||
|
||
public String getZipCode() { | ||
return zipCode; | ||
} | ||
|
||
public void setZipCode(String zipCode) { | ||
this.zipCode = zipCode; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
integration-tests/jpa-db2/src/main/java/io/quarkus/it/jpa/db2/Animal.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,16 @@ | ||
package io.quarkus.it.jpa.db2; | ||
|
||
/** | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
public class Animal { | ||
private double weight; | ||
|
||
public double getWeight() { | ||
return weight; | ||
} | ||
|
||
public void setWeight(double weight) { | ||
this.weight = weight; | ||
} | ||
} |
Oops, something went wrong.