-
-
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.
Fix: ContainerDatabaseDriver does not register Properties object (#5829)
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
- Loading branch information
1 parent
de1a77e
commit 9847d59
Showing
3 changed files
with
64 additions
and
6 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
44 changes: 44 additions & 0 deletions
44
...s/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLDatabaseContainerDriverTest.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,44 @@ | ||
package org.testcontainers.jdbc.mysql; | ||
|
||
import org.junit.Test; | ||
import org.testcontainers.jdbc.ContainerDatabaseDriver; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.Properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class MySQLDatabaseContainerDriverTest { | ||
|
||
@Test | ||
public void shouldRespectBothUrlPropertiesAndParameterProperties() throws SQLException { | ||
ContainerDatabaseDriver driver = new ContainerDatabaseDriver(); | ||
String url = "jdbc:tc:mysql:5.7.22://hostname/databasename?padCharsWithSpace=true"; | ||
Properties properties = new Properties(); | ||
properties.setProperty("maxRows", "1"); | ||
|
||
try (Connection connection = driver.connect(url, properties)) { | ||
try (Statement statement = connection.createStatement()) { | ||
statement.execute("CREATE TABLE arbitrary_table (length_5_string CHAR(5))"); | ||
statement.execute("INSERT INTO arbitrary_table VALUES ('abc')"); | ||
statement.execute("INSERT INTO arbitrary_table VALUES ('123')"); | ||
|
||
// Check that maxRows is set | ||
try (ResultSet resultSet = statement.executeQuery("SELECT * FROM arbitrary_table")) { | ||
resultSet.next(); | ||
assertThat(resultSet.isFirst()).isTrue(); | ||
assertThat(resultSet.isLast()).isTrue(); | ||
} | ||
|
||
// Check that pad with chars is set | ||
try (ResultSet resultSet = statement.executeQuery("SELECT * FROM arbitrary_table")) { | ||
assertThat(resultSet.next()).isTrue(); | ||
assertThat(resultSet.getString(1)).isEqualTo("abc "); | ||
} | ||
} | ||
} | ||
} | ||
} |