-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
50 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
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
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
29 changes: 29 additions & 0 deletions
29
core/src/test/kotlin/org/evomaster/core/sql/multidb/ConflictingSchemasTest.kt
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,29 @@ | ||
package org.evomaster.core.sql.multidb | ||
|
||
import org.evomaster.client.java.controller.api.dto.database.schema.DatabaseType | ||
import org.evomaster.client.java.sql.DbInfoExtractor | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import java.sql.Connection | ||
|
||
class ConflictingSchemasTest : MultiDbTestBase() { | ||
|
||
override fun verify(databaseType: DatabaseType, connection: Connection, name: String) { | ||
|
||
val info = DbInfoExtractor.extract(connection) | ||
assertEquals(name.lowercase(), info.name.lowercase()) | ||
assertEquals(2, info.tables.size) | ||
val first = info.tables.find { it.schema.equals("first",true) }!! | ||
val second = info.tables.find { it.schema.equals("other",true) }!! | ||
|
||
assertEquals(first.name, second.name) | ||
|
||
assertEquals(2, first.columns.size) | ||
assertEquals(2, second.columns.size) | ||
|
||
assertTrue(first.columns.any { it.name.equals("x", true) }) | ||
assertTrue(second.columns.any { it.name.equals("y",true) }) | ||
} | ||
|
||
override fun getSchemaLocation()= "/sql_schema/multidb/conflictingschemas.sql" | ||
} |
33 changes: 33 additions & 0 deletions
33
core/src/test/kotlin/org/evomaster/core/sql/multidb/MultiDbTestBase.kt
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,33 @@ | ||
package org.evomaster.core.sql.multidb | ||
|
||
import org.evomaster.client.java.controller.api.dto.database.schema.DatabaseType | ||
import org.evomaster.client.java.sql.SqlScriptRunner | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.EnumSource | ||
import java.sql.Connection | ||
|
||
abstract class MultiDbTestBase { | ||
|
||
@ParameterizedTest | ||
@EnumSource(names = ["MYSQL","POSTGRES","H2"]) | ||
fun test(databaseType: DatabaseType){ | ||
val name = "dbtest" | ||
val sqlSchemaCommand = this::class.java.getResource(getSchemaLocation()).readText() | ||
|
||
MultiDbUtils.startDatabase(databaseType) | ||
try { | ||
MultiDbUtils.resetDatabase(name, databaseType) | ||
val connection = MultiDbUtils.createConnection(name, databaseType) | ||
connection.use { | ||
SqlScriptRunner.execCommand(it, sqlSchemaCommand) | ||
verify(databaseType,it, name) | ||
} | ||
}finally { | ||
MultiDbUtils.stopDatabase(databaseType) | ||
} | ||
} | ||
|
||
protected abstract fun verify(databaseType: DatabaseType, connection: Connection, name: String) | ||
|
||
protected abstract fun getSchemaLocation(): String | ||
} |
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
16 changes: 16 additions & 0 deletions
16
core/src/test/resources/sql_schema/multidb/conflictingschemas.sql
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,16 @@ | ||
CREATE SCHEMA IF NOT EXISTS first; | ||
CREATE SCHEMA IF NOT EXISTS other; | ||
|
||
|
||
create table first.Foo ( | ||
id bigint not null, | ||
x bigint, | ||
primary key (id) | ||
); | ||
|
||
|
||
create table other.Foo( | ||
id bigint not null, | ||
y bigint, | ||
primary key (id) | ||
); |