-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend
sql-db/hibernate-reactive
and sql-db/vertx-sql
with oracle
Extend with reactive Oracle client. Implementation of test plan for QUARKUS-1407: https://github.com/quarkus-qe/quarkus-test-plans/blob/main/QUARKUS-1407.md
- Loading branch information
Showing
15 changed files
with
230 additions
and
3 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
49 changes: 49 additions & 0 deletions
49
sql-db/hibernate-reactive/src/test/java/io/quarkus/ts/reactive/OracleDatabaseIT.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,49 @@ | ||
package io.quarkus.ts.reactive; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.bootstrap.OracleService; | ||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.quarkus.test.services.Container; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
|
||
@QuarkusScenario | ||
public class OracleDatabaseIT extends AbstractReactiveDatabaseIT { | ||
|
||
private static final String ORACLE_USER = "quarkus_test"; | ||
private static final String ORACLE_PASSWORD = "quarkus_test"; | ||
private static final String ORACLE_DATABASE = "quarkus_test"; | ||
static final int ORACLE_PORT = 1521; | ||
|
||
@Container(image = "${oracle.image}", port = ORACLE_PORT, expectedLog = "DATABASE IS READY TO USE!") | ||
static OracleService database = new ProvisionalOracleService() | ||
.with(ORACLE_USER, ORACLE_PASSWORD, ORACLE_DATABASE); | ||
|
||
@QuarkusApplication | ||
static RestService app = new RestService().withProperties("oracle.properties") | ||
.withProperty("quarkus.datasource.username", ORACLE_USER) | ||
.withProperty("quarkus.datasource.password", ORACLE_PASSWORD) | ||
.withProperty("quarkus.datasource.reactive.url", database::getReactiveUrl); | ||
|
||
@Override | ||
protected RestService getApp() { | ||
return app; | ||
} | ||
|
||
@Test | ||
@Override | ||
@Disabled | ||
public void ensureSessionIsPropagatedOnReactiveTransactions() { | ||
// TODO: investigate / file an issue? | ||
} | ||
|
||
// TODO: Remove after https://github.com/quarkus-qe/quarkus-test-framework/pull/428 is available in TF | ||
private static class ProvisionalOracleService extends OracleService { | ||
@Override | ||
public String getReactiveUrl() { | ||
return getHost().replace("http://", getJdbcName() + ":thin:@") + ":" + getPort() + ":" + getDatabase(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../hibernate-reactive/src/test/java/io/quarkus/ts/reactive/openshift/OpenShiftOracleIT.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,10 @@ | ||
package io.quarkus.ts.reactive.openshift; | ||
|
||
import io.quarkus.test.scenarios.OpenShiftScenario; | ||
import io.quarkus.ts.reactive.OracleDatabaseIT; | ||
import org.junit.jupiter.api.Disabled; | ||
|
||
@Disabled("https://issues.redhat.com/browse/QUARKUS-1164?focusedCommentId=18977100&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-18977100") | ||
@OpenShiftScenario | ||
public class OpenShiftOracleIT extends OracleDatabaseIT { | ||
} |
3 changes: 3 additions & 0 deletions
3
sql-db/hibernate-reactive/src/test/resources/oracle.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 @@ | ||
quarkus.datasource.db-kind=oracle | ||
quarkus.hibernate-orm.sql-load-script=oracle_import.sql | ||
quarkus.hibernate-orm.database.generation=create |
11 changes: 11 additions & 0 deletions
11
sql-db/hibernate-reactive/src/test/resources/oracle_import.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,11 @@ | ||
DROP TABLE authors; | ||
CREATE TABLE AUTHORS(ID NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, NAME VARCHAR(100) NOT NULL); | ||
INSERT INTO authors(id,name) VALUES (1, 'Homer'); | ||
INSERT INTO authors(id,name) VALUES (2, 'Vern'); | ||
INSERT INTO authors(id,name) VALUES (3, 'Dlugi'); | ||
INSERT INTO authors(id,name) VALUES (4, 'Kahneman'); | ||
DROP TABLE books; | ||
CREATE TABLE books(id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, author INT references authors(id) , title VARCHAR(500) NOT NULL, isbn VARCHAR(50)); | ||
INSERT INTO books(author, title) VALUES (3, 'Slovník'); | ||
INSERT INTO books(author, title, isbn) VALUES (4, 'Thinking fast and slow', '978-0374275631'); | ||
INSERT INTO books(author, title) VALUES (4, 'Attention and Effort'); |
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
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
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
62 changes: 62 additions & 0 deletions
62
sql-db/vertx-sql/src/main/resources/db/migration/oracle/V1.0.0__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,62 @@ | ||
|
||
CREATE TABLE airports ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
iata_code VARCHAR(100) NOT NULL UNIQUE, | ||
city VARCHAR(100) NOT NULL | ||
); | ||
|
||
CREATE TABLE airlines ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
iata_code VARCHAR(100) NOT NULL UNIQUE, | ||
name VARCHAR(100) NOT NULL, | ||
infant_price FLOAT(7) | ||
); | ||
|
||
CREATE TABLE flights ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
origin VARCHAR(100) NOT NULL, | ||
destination VARCHAR(100) NOT NULL, | ||
flight_code VARCHAR(100) NOT NULL, | ||
base_price SMALLINT NOT NULL | ||
); | ||
|
||
CREATE TABLE pricingRules ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
days_to_departure SMALLINT NOT NULL, | ||
until SMALLINT NOT NULL, | ||
percentage SMALLINT NOT NULL | ||
); | ||
|
||
CREATE TABLE address ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
street VARCHAR(300) NOT NULL, | ||
block_number VARCHAR(20) NOT NULL, | ||
zip_code VARCHAR(20) NOT NULL, | ||
city VARCHAR(150) NOT NULL, | ||
country VARCHAR(200) NOT NULL, | ||
created_at INT NOT NULL, | ||
updated_at INT | ||
); | ||
|
||
CREATE TABLE passenger ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
nif VARCHAR(15) NOT NULL, | ||
name VARCHAR(25) NOT NULL, | ||
last_name VARCHAR(55) NOT NULL, | ||
contact_number VARCHAR(20) NOT NULL, | ||
created_at INT NOT NULL, | ||
updated_at INT, | ||
address_id NUMBER, | ||
CONSTRAINT fk_address FOREIGN KEY(address_id) REFERENCES address(id) ON DELETE SET NULL | ||
); | ||
|
||
CREATE TABLE basket ( | ||
id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | ||
flight VARCHAR(10) NOT NULL, | ||
price NUMERIC NOT NULL, | ||
created_at INT NOT NULL, | ||
updated_at INT, | ||
passenger_id NUMBER, | ||
CONSTRAINT fk_passenger FOREIGN KEY(passenger_id) REFERENCES passenger(id) ON DELETE SET NULL | ||
); | ||
|
35 changes: 35 additions & 0 deletions
35
sql-db/vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/OracleHandlerIT.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,35 @@ | ||
package io.quarkus.qe.vertx.sql.handlers; | ||
|
||
import io.quarkus.test.bootstrap.OracleService; | ||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.quarkus.test.services.Container; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
|
||
@QuarkusScenario | ||
public class OracleHandlerIT extends CommonTestCases { | ||
private static final int ORACLE_PORT = 1521; | ||
private static final String DATABASE = "amadeus"; | ||
|
||
@Container(image = "${oracle.image}", port = ORACLE_PORT, expectedLog = "DATABASE IS READY TO USE!") | ||
static OracleService oracle = new ProvisionalOracleService() | ||
.with("test", "test", DATABASE); | ||
|
||
@QuarkusApplication | ||
static final RestService app = new RestService() | ||
.withProperty("quarkus.datasource.oracle.username", oracle::getUser) | ||
.withProperty("quarkus.datasource.oracle.password", oracle::getPassword) | ||
.withProperty("quarkus.datasource.oracle.jdbc.url", oracle::getJdbcUrl) | ||
.withProperty("quarkus.datasource.oracle.reactive.url", oracle::getReactiveUrl) | ||
.withProperty("app.selected.db", "oracle") | ||
// Enable Flyway for Oracle | ||
.withProperty("quarkus.flyway.oracle.migrate-at-start", "true"); | ||
|
||
// TODO: Remove after https://github.com/quarkus-qe/quarkus-test-framework/pull/428 is available in TF | ||
private static class ProvisionalOracleService extends OracleService { | ||
@Override | ||
public String getReactiveUrl() { | ||
return getHost().replace("http://", getJdbcName() + ":thin:@") + ":" + getPort() + ":" + getDatabase(); | ||
} | ||
} | ||
} |