It is surprisingly hard to get spring integration tests running on an oracle DB. So here I'll document how.
Note that I have limited knowledge about Oracle DBs; the only target of this guide is to get it working somehow. If you are looking for a stable / sensible setup, you unfortunately need to look somewhere else (and then tell me in the comments!).
First, choose the docker image of the version of interest. You can find those here: https://container-registry.oracle.com/ If you do not know which version to choose, go for express.
Download & start the container, as well as set the password with docker run -d --name oracle18 -p 1521:1521 -p 5500:5500 container-registry.oracle.com/database/express:18.4.0-xe
.
Then check with docker logs oracle18
whether the container starts successfully.
Note that this really might fail; there are a lot of open issues.
I'd suggest to simply try a different oracle version before attempting to debug.
You can then change the password with docker exec oracle18 ./setPassword.sh password
.
Note that there are open issues with this script, too; but it seems to work fine at least with the container in this example.
In our version of oracle DB, the pluggable database service name is XEPDB1
.
You can find the name in the logs of the container.
We can connect using a connection string such as jdbc:oracle:thin:@//localhost:1521/XEPDB1
.
If you are using a UI, make sure to set "Connection Type" to "Service Name" (and not "SID").
You can use the user "SYSTEM" or "PDBADMIN" with the password set above. All accounts have the same password.
To then actually modify the database you need the correct permissions. I've observed that "SYSTEM" can create tables. To insert rows, you additionally need to increase the quota:
ALTER USER PDBADMIN quota 100M on USERS;
ALTER USER SYSTEM quota 100M on USERS;
To have spring use the Oracle DB, change the config to:
spring.datasource.url=jdbc:oracle:thin:@localhost:1521/XEPDB1
spring.datasource.schema=PDBADMIN
spring.datasource.username=SYSTEM
spring.datasource.password=swisspost
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
Depending on your setup, you might additionally need some combination of
spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
spring.jpa.properties.hibernate.default_schema=PDBADMIN
spring.datasource.hikari.schema=PDBADMIN
Further, you need to add the oracle driver dependency:
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>test</scope>
</dependency>
And possibly some more, depending on your setup:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-oracle</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>