-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update r2dbc-spi version to 0.9.0.RELEASE * Add `OracleR2DBCDatabaseContainer` * Testcontainers R2DBC URL support Fixes #4475
- Loading branch information
1 parent
2d57f61
commit 5522641
Showing
12 changed files
with
147 additions
and
9 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
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 |
---|---|---|
@@ -1,10 +1,32 @@ | ||
description = "Testcontainers :: JDBC :: Oracle XE" | ||
|
||
dependencies { | ||
annotationProcessor 'com.google.auto.service:auto-service:1.0.1' | ||
compileOnly 'com.google.auto.service:auto-service:1.0' | ||
|
||
api project(':jdbc') | ||
|
||
compileOnly project(':r2dbc') | ||
compileOnly 'com.oracle.database.r2dbc:oracle-r2dbc:1.0.0' | ||
|
||
testImplementation project(':jdbc-test') | ||
testImplementation 'com.oracle.ojdbc:ojdbc8:19.3.0.0' | ||
testImplementation 'com.oracle.database.jdbc:ojdbc11:21.5.0.0' | ||
|
||
compileOnly 'org.jetbrains:annotations:24.0.0' | ||
|
||
testImplementation testFixtures(project(':r2dbc')) | ||
testImplementation 'com.oracle.database.r2dbc:oracle-r2dbc:1.0.0' | ||
} | ||
|
||
test { | ||
javaLauncher = javaToolchains.launcherFor { | ||
languageVersion = JavaLanguageVersion.of(11) | ||
} | ||
} | ||
|
||
compileTestJava { | ||
javaCompiler = javaToolchains.compilerFor { | ||
languageVersion = JavaLanguageVersion.of(11) | ||
} | ||
options.release.set(11) | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...s/oracle-xe/src/main/java/org/testcontainers/containers/OracleR2DBCDatabaseContainer.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 org.testcontainers.containers; | ||
|
||
import io.r2dbc.spi.ConnectionFactoryOptions; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Delegate; | ||
import org.testcontainers.lifecycle.Startable; | ||
import org.testcontainers.r2dbc.R2DBCDatabaseContainer; | ||
|
||
@RequiredArgsConstructor | ||
public class OracleR2DBCDatabaseContainer implements R2DBCDatabaseContainer { | ||
|
||
@Delegate(types = Startable.class) | ||
private final OracleContainer container; | ||
|
||
public static ConnectionFactoryOptions getOptions(OracleContainer container) { | ||
ConnectionFactoryOptions options = ConnectionFactoryOptions | ||
.builder() | ||
.option(ConnectionFactoryOptions.DRIVER, OracleR2DBCDatabaseContainerProvider.DRIVER) | ||
.build(); | ||
|
||
return new OracleR2DBCDatabaseContainer(container).configure(options); | ||
} | ||
|
||
@Override | ||
public ConnectionFactoryOptions configure(ConnectionFactoryOptions options) { | ||
return options | ||
.mutate() | ||
.option(ConnectionFactoryOptions.HOST, container.getHost()) | ||
.option(ConnectionFactoryOptions.PORT, container.getMappedPort(OracleContainer.ORACLE_PORT)) | ||
.option(ConnectionFactoryOptions.DATABASE, container.getDatabaseName()) | ||
.option(ConnectionFactoryOptions.USER, container.getUsername()) | ||
.option(ConnectionFactoryOptions.PASSWORD, container.getPassword()) | ||
.build(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...-xe/src/main/java/org/testcontainers/containers/OracleR2DBCDatabaseContainerProvider.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,43 @@ | ||
package org.testcontainers.containers; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.r2dbc.spi.ConnectionFactoryMetadata; | ||
import io.r2dbc.spi.ConnectionFactoryOptions; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.testcontainers.r2dbc.R2DBCDatabaseContainer; | ||
import org.testcontainers.r2dbc.R2DBCDatabaseContainerProvider; | ||
|
||
@AutoService(R2DBCDatabaseContainerProvider.class) | ||
public class OracleR2DBCDatabaseContainerProvider implements R2DBCDatabaseContainerProvider { | ||
|
||
static final String DRIVER = "oracle"; | ||
|
||
@Override | ||
public boolean supports(ConnectionFactoryOptions options) { | ||
return DRIVER.equals(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)); | ||
} | ||
|
||
@Override | ||
public R2DBCDatabaseContainer createContainer(ConnectionFactoryOptions options) { | ||
String image = OracleContainer.IMAGE + ":" + options.getRequiredValue(IMAGE_TAG_OPTION); | ||
OracleContainer container = new OracleContainer(image) | ||
.withDatabaseName((String) options.getRequiredValue(ConnectionFactoryOptions.DATABASE)); | ||
if (Boolean.TRUE.equals(options.getValue(REUSABLE_OPTION))) { | ||
container.withReuse(true); | ||
} | ||
return new OracleR2DBCDatabaseContainer(container); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public ConnectionFactoryMetadata getMetadata(ConnectionFactoryOptions options) { | ||
ConnectionFactoryOptions.Builder builder = options.mutate(); | ||
if (!options.hasOption(ConnectionFactoryOptions.USER)) { | ||
builder.option(ConnectionFactoryOptions.USER, OracleContainer.APP_USER); | ||
} | ||
if (!options.hasOption(ConnectionFactoryOptions.PASSWORD)) { | ||
builder.option(ConnectionFactoryOptions.PASSWORD, OracleContainer.APP_USER_PASSWORD); | ||
} | ||
return R2DBCDatabaseContainerProvider.super.getMetadata(builder.build()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...e/src/test/java/org/testcontainers/containers/r2dbc/OracleR2DBCDatabaseContainerTest.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,30 @@ | ||
package org.testcontainers.containers.r2dbc; | ||
|
||
import io.r2dbc.spi.ConnectionFactoryOptions; | ||
import org.testcontainers.containers.OracleContainer; | ||
import org.testcontainers.containers.OracleR2DBCDatabaseContainer; | ||
import org.testcontainers.r2dbc.AbstractR2DBCDatabaseContainerTest; | ||
|
||
public class OracleR2DBCDatabaseContainerTest extends AbstractR2DBCDatabaseContainerTest<OracleContainer> { | ||
|
||
@Override | ||
protected OracleContainer createContainer() { | ||
return new OracleContainer("gvenzl/oracle-xe:21-slim-faststart"); | ||
} | ||
|
||
@Override | ||
protected ConnectionFactoryOptions getOptions(OracleContainer container) { | ||
ConnectionFactoryOptions options = OracleR2DBCDatabaseContainer.getOptions(container); | ||
|
||
return options; | ||
} | ||
|
||
protected String createR2DBCUrl() { | ||
return "r2dbc:tc:oracle:///db?TC_IMAGE_TAG=21-slim-faststart"; | ||
} | ||
|
||
@Override | ||
protected String query() { | ||
return "SELECT %s from dual"; | ||
} | ||
} |
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