-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23466 from famod/ora-devservice-test
Add `DevServicesOracleDatasourceTestCase`
- Loading branch information
Showing
2 changed files
with
107 additions
and
0 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
58 changes: 58 additions & 0 deletions
58
.../src/test/java/io/quarkus/jdbc/oracle/deployment/DevServicesOracleDatasourceTestCase.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,58 @@ | ||
package io.quarkus.jdbc.oracle.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.sql.Connection; | ||
import java.util.logging.Level; | ||
import java.util.logging.LogRecord; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.agroal.api.AgroalDataSource; | ||
import io.agroal.api.configuration.AgroalConnectionPoolConfiguration; | ||
import io.agroal.api.exceptionsorter.OracleExceptionSorter; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DevServicesOracleDatasourceTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withEmptyApplication() | ||
// Expect no warnings (in particular from Agroal) | ||
.setLogRecordPredicate(record -> record.getLevel().intValue() >= Level.WARNING.intValue() | ||
// There are other warnings: JDK8, TestContainers, drivers, ... | ||
// Ignore them: we're only interested in Agroal here. | ||
&& record.getMessage().contains("Agroal")) | ||
.assertLogRecords(records -> assertThat(records) | ||
// This is just to get meaningful error messages, as LogRecord doesn't have a toString() | ||
.extracting(LogRecord::getMessage) | ||
.isEmpty()); | ||
|
||
@Inject | ||
AgroalDataSource dataSource; | ||
|
||
@Test | ||
public void testDatasource() throws Exception { | ||
AgroalConnectionPoolConfiguration configuration = null; | ||
|
||
try { | ||
configuration = dataSource.getConfiguration().connectionPoolConfiguration(); | ||
} catch (NullPointerException e) { | ||
// we catch the NPE here as we have a proxycd and we can't test dataSource directly | ||
fail("Datasource should not be null"); | ||
} | ||
assertTrue(configuration.connectionFactoryConfiguration().jdbcUrl().contains("jdbc:oracle:")); | ||
assertEquals("quarkus", configuration.connectionFactoryConfiguration().principal().getName()); | ||
assertEquals(20, configuration.maxSize()); | ||
assertThat(configuration.exceptionSorter()).isInstanceOf(OracleExceptionSorter.class); | ||
|
||
try (Connection connection = dataSource.getConnection()) { | ||
} | ||
} | ||
} |