-
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.
Integration tests for quarkus.hibernate-orm.database.orm-compatibilit…
…y.version For reference, below are the failures when not setting the property (and ignoring schema validation). MariaDB: [ERROR] Failures: [ERROR] CompatibilityTest.instant:81 expected: 2018-01-01T10:58:30Z but was: 2018-01-01T11:58:30Z [ERROR] CompatibilityTest.offsetDateTime:91 expected: 2018-01-01T11:58:30+01:00 (java.time.OffsetDateTime) but was: 2018-01-01T11:58:30Z (java.time.OffsetDateTime) when comparing values using 'OffsetDateTime.timeLineOrder()' [ERROR] CompatibilityTest.persistUsingOldSchema:61 1 expectation failed. Expected status code is <200> but was <500>. [ERROR] CompatibilityTest.sequence:38 1 expectation failed. Expected status code is <200> but was <500>. [ERROR] CompatibilityTest.zonedDateTime:102 expected: 2018-01-01T11:58:30+01:00[Europe/Paris] (java.time.ZonedDateTime) but was: 2018-01-01T11:58:30Z[UTC] (java.time.ZonedDateTime) when comparing values using 'ChronoZonedDateTime.timeLineOrder()' PostgreSQL: Everything failing due to array support not liking binary columns, so I had to comment out the array/arrayList properties. See https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/Array.20support Then we get that: [ERROR] Failures: [ERROR] CompatibilityTest.instant:79 expected: 2018-01-01T10:58:30Z but was: 2018-01-01T11:58:30Z [ERROR] CompatibilityTest.offsetDateTime:89 expected: 2018-01-01T11:58:30+01:00 (java.time.OffsetDateTime) but was: 2018-01-01T11:58:30Z (java.time.OffsetDateTime) when comparing values using 'OffsetDateTime.timeLineOrder()' [ERROR] CompatibilityTest.persistUsingOldSchema:59 1 expectation failed. Expected status code is <200> but was <500>. [ERROR] CompatibilityTest.sequence:36 1 expectation failed. Expected status code is <200> but was <500>. [ERROR] CompatibilityTest.zonedDateTime:100 expected: 2018-01-01T11:58:30+01:00[Europe/Paris] (java.time.ZonedDateTime) but was: 2018-01-01T11:58:30Z[UTC] (java.time.ZonedDateTime) when comparing values using 'ChronoZonedDateTime.timeLineOrder()'
- Loading branch information
Showing
25 changed files
with
1,487 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
integration-tests/hibernate-orm-compatibility-5.6/README.md
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,34 @@ | ||
# Hibernate ORM 5.6 database compatibility tests | ||
|
||
## What is this? | ||
|
||
These module test that Quarkus can indeed work with a database created by Hibernate ORM 5.6 | ||
when the following property is set: | ||
|
||
```properties | ||
quarkus.hibernate-orm.database.orm-compatibility.version = 5.6 | ||
``` | ||
|
||
## How does it work? | ||
|
||
The tests need to execute on a database whose schema and data | ||
was initialized with Hibernate ORM 5.6. | ||
|
||
Everything is already set up to restore a dump on startup. | ||
|
||
## How to update the tests? | ||
|
||
If you add new tests and those changes require new entity mappings and/or data, | ||
make sure to update the project `database-generator` accordingly | ||
(same entity mapping as in your tests, in particular). | ||
This project depends on Quarkus 2 and is used to generate a database. | ||
|
||
Then, to update the dump, run `./update-dump.sh` from each DB directory (`mariadb`, `postgresql`, ...). | ||
This will start a container, generate the database, and update the dump in `src/test/resources`. | ||
|
||
## Why is `database-generator` not part of the build? | ||
|
||
Because: | ||
|
||
1. It doesn't need to. This project is only meant to be used to update dumps. | ||
2. It depends on Quarkus 2, so adding it to the build would pollute the local Maven repository unnecessarily. |
121 changes: 121 additions & 0 deletions
121
integration-tests/hibernate-orm-compatibility-5.6/database-generator/pom.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,121 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-integration-test-hibernate-orm-compatibility-5.6-database-generator</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<properties> | ||
<compiler-plugin.version>3.10.1</compiler-plugin.version> | ||
<maven.compiler.release>17</maven.compiler.release> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> | ||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> | ||
<quarkus.platform.version>2.16.3.Final</quarkus.platform.version> | ||
<skipITs>true</skipITs> | ||
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${quarkus.platform.group-id}</groupId> | ||
<artifactId>${quarkus.platform.artifact-id}</artifactId> | ||
<version>${quarkus.platform.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-hibernate-orm</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jdbc-mariadb</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jdbc-postgresql</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>${quarkus.platform.group-id}</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus.platform.version}</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
<goal>generate-code</goal> | ||
<goal>generate-code-tests</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${compiler-plugin.version}</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-parameters</arg> | ||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<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> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<properties> | ||
<skipITs>false</skipITs> | ||
<quarkus.package.type>native</quarkus.package.type> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
</project> |
53 changes: 53 additions & 0 deletions
53
...lity-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/Main.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,53 @@ | ||
package io.quarkus.it.hibernate.compatibility; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.time.ZoneOffset; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
|
||
import io.quarkus.narayana.jta.QuarkusTransaction; | ||
import io.quarkus.runtime.Quarkus; | ||
import io.quarkus.runtime.QuarkusApplication; | ||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
|
||
@QuarkusMain | ||
public class Main { | ||
public static void main(String... args) { | ||
System.out.println("Initializing schema..."); | ||
Quarkus.run(QuarkusMain.class, args); | ||
} | ||
|
||
static class QuarkusMain implements QuarkusApplication { | ||
@Inject | ||
EntityManager em; | ||
|
||
@Override | ||
public int run(String... args) { | ||
System.out.println("Initializing data..."); | ||
QuarkusTransaction.requiringNew().run(() -> { | ||
var entity = new MyEntity(); | ||
entity.duration = Duration.of(59, ChronoUnit.SECONDS); | ||
entity.uuid = UUID.fromString("f49c6ba8-8d7f-417a-a255-d594dddf729f"); | ||
entity.instant = Instant.parse("2018-01-01T10:58:30.00Z"); | ||
entity.intArray = new int[] { 0, 1, 42 }; | ||
entity.offsetDateTime = LocalDateTime.of(2018, 1, 1, 12, 58, 30, 0) | ||
.atOffset(ZoneOffset.ofHours(2)); | ||
entity.zonedDateTime = LocalDateTime.of(2018, 1, 1, 12, 58, 30, 0) | ||
.atZone(ZoneId.of("Africa/Cairo" /* UTC+2 */)); | ||
entity.stringList = new ArrayList<>(List.of("one", "two")); | ||
entity.myEnum = MyEnum.VALUE2; | ||
em.persist(entity); | ||
}); | ||
System.out.println("Done."); | ||
return 0; | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/MyEntity.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 @@ | ||
package io.quarkus.it.hibernate.compatibility; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.time.OffsetDateTime; | ||
import java.time.ZonedDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
public class MyEntity { | ||
@Id | ||
@GeneratedValue | ||
public Long id; | ||
|
||
public Duration duration; | ||
|
||
public UUID uuid; | ||
|
||
public Instant instant; | ||
|
||
public OffsetDateTime offsetDateTime; | ||
|
||
public ZonedDateTime zonedDateTime; | ||
|
||
public int[] intArray; | ||
|
||
public ArrayList<String> stringList; | ||
|
||
@Enumerated(EnumType.ORDINAL) | ||
public MyEnum myEnum; | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...ty-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/MyEnum.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,7 @@ | ||
package io.quarkus.it.hibernate.compatibility; | ||
|
||
public enum MyEnum { | ||
VALUE1, | ||
VALUE2, | ||
VALUE3 | ||
} |
3 changes: 3 additions & 0 deletions
3
...ernate-orm-compatibility-5.6/database-generator/src/main/resources/application.properties
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,3 @@ | ||
# This is set from the commandline when building | ||
quarkus.datasource.db-kind=${db-kind} | ||
quarkus.hibernate-orm.database.generation=create |
Oops, something went wrong.