Complete the code to start a PostgreSQL test container.
PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:latest").[1]();
run() or launch() instead of start().The start() method is used to launch the test container.
Complete the code to get the JDBC URL from the running container.
String jdbcUrl = postgres.[1]();getUrl() which does not return the JDBC URL.The method getJdbcUrl() returns the JDBC connection string for the container.
Fix the error in the annotation to use the PostgreSQL container as a JUnit 5 extension.
@RegisterExtension static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:latest").[1]();
start() manually when using @RegisterExtension.The withReuse() method enables container reuse, which is often used with JUnit 5 extensions.
Fill both blanks to create a test container with a specific database name and username.
PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:latest") .[1]("testdb") .[2]("testuser");
withPassword() and withUsername().withDatabaseName() sets the database name, and withUsername() sets the username.
Fill all three blanks to create a test container with a database name, username, and password.
PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:latest") .[1]("mydb") .[2]("admin") .[3]("secret");
withInitScript() instead of withPassword().Use withDatabaseName() for the database, withUsername() for the user, and withPassword() for the password.