mirror of
https://github.com/corda/corda.git
synced 2025-06-20 16:10:26 +00:00
Fix integration tests in database mode (#1401)
Add SQL setup in new test classes which were missing it. Ignoring H2 tests when running against standalone database. Revert datasource Enterprise specific configuration for RaftTransactionCommitLogTests.kt test, and mark it as required for test in database mode.
This commit is contained in:
@ -27,6 +27,7 @@ import net.corda.testing.node.internal.addressMustNotBeBound
|
||||
import net.corda.testing.node.internal.internalDriver
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.json.simple.JSONObject
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
@ -156,6 +157,7 @@ class DriverTests : IntegrationTest() {
|
||||
|
||||
@Test
|
||||
fun `driver rejects multiple nodes with the same organisation name`() {
|
||||
assumeTrue(!IntegrationTest.isRemoteDatabaseMode()) // Enterprise only - disable test, Liquibase doesn't quote schema name with all uppercase or lowercase letters
|
||||
driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) {
|
||||
newNode(CordaX500Name(commonName = "Notary", organisation = "R3CEV", locality = "New York", country = "US"))().getOrThrow()
|
||||
assertThatIllegalArgumentException().isThrownBy {
|
||||
|
@ -65,7 +65,7 @@ object DbScriptRunner {
|
||||
if (schemas.isEmpty()) scripts else schemas.map { merge(scripts, it) }.flatten()
|
||||
}
|
||||
|
||||
//rewritten version of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
// Rewritten version of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
class ListPopulator(private val continueOnError: Boolean,
|
||||
private val ignoreFailedDrops: Boolean,
|
||||
private val statements: List<String>) : DatabasePopulator {
|
||||
@ -94,9 +94,11 @@ class ListPopulator(private val continueOnError: Boolean,
|
||||
}
|
||||
} catch (ex: SQLException) {
|
||||
val dropStatement = StringUtils.startsWithIgnoreCase(statement.trim { it <= ' ' }, "drop")
|
||||
if ((continueOnError || dropStatement && ignoreFailedDrops)) {
|
||||
// Ignore exception on Oracle db, as the user from the previous test maybe still logged in, and cannot be dropped
|
||||
val createUser = StringUtils.startsWithIgnoreCase(statement.trim { it <= ' ' },"CREATE USER")
|
||||
if ((continueOnError || dropStatement && ignoreFailedDrops) || createUser) {
|
||||
val dropUserStatement = StringUtils.startsWithIgnoreCase(statement.trim { it <= ' ' }, "drop user ")
|
||||
if (dropUserStatement) { // log to help spotting a node still logged on database after test has finished (happens on Oracle db)
|
||||
if (dropUserStatement || createUser) { // log to help spotting a node still logged on database after test has finished (happens on Oracle db)
|
||||
logger.warn("SQLException for $statement: SQL state '" + ex.sqlState +
|
||||
"', error code '" + ex.errorCode +
|
||||
"', message [" + ex.message + "]")
|
||||
|
Reference in New Issue
Block a user