Skip to content

Commit

Permalink
chore: clean codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Dec 23, 2023
1 parent 4ea2df0 commit 9cc2d71
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
Expand All @@ -26,11 +28,20 @@ public class TodoRepositoryTest {

// see: https://java.testcontainers.org/modules/databases/oraclexe/
@Container
static OracleContainer oracle = new OracleContainer("gvenzl/oracle-xe:21-slim-faststart")
static OracleContainer oracleContainer = new OracleContainer("gvenzl/oracle-xe:21-slim-faststart")
.withDatabaseName("blogdb")
.withUsername("user")
.withPassword("password");

@DynamicPropertySource
static void registerDynamicProperties(DynamicPropertyRegistry registry) {
registry.add("spring.r2dbc.url", () -> "r2dbc:oracle://"
+ oracleContainer.getHost() + ":" + oracleContainer.getFirstMappedPort()
+ "/" + oracleContainer.getDatabaseName());
registry.add("spring.r2dbc.username", () -> oracleContainer.getUsername());
registry.add("spring.r2dbc.password", () -> oracleContainer.getPassword());
}

@Autowired
TodoRepository todos;

Expand Down

0 comments on commit 9cc2d71

Please sign in to comment.