change jasync to jdbc

This commit is contained in:
2019-08-04 18:05:31 +02:00
parent cbb86dacc5
commit aeabe3f8c1
16 changed files with 107 additions and 79 deletions

View File

@@ -72,7 +72,7 @@ class ConnectionTest(): TestAbstract() {
fun callExec() {
val o = ObjTest("myName")
val result = connection.exec("select json_build_object('id', 1, 'name', ?::json->>'name')", listOf(o))
Assertions.assertEquals(1, result.rowsAffected)
Assertions.assertNotNull(result.getString(1))
}
@Test
@@ -166,7 +166,7 @@ class ConnectionTest(): TestAbstract() {
params
) {
assertEquals("ff", it!!.first)
assertEquals("plop", rows[0].getString("other"))
assertEquals("plop", getString("other"))
}
assertNotNull(result)
assertEquals("ff", result!!.first)

View File

@@ -4,6 +4,7 @@ import fr.postgresjson.connexion.Paginated
import fr.postgresjson.connexion.Requester
import fr.postgresjson.entity.IdEntity
import org.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.io.File
@@ -43,7 +44,7 @@ class RequesterTest: TestAbstract() {
.getQuery("Test/selectOne")
.exec()
assertEquals(1, result.rowsAffected)
Assertions.assertNotNull(result.getString(1))
}
@Test
@@ -54,7 +55,7 @@ class RequesterTest: TestAbstract() {
.getFunction("test_function")
.exec(listOf("test", "plip"))
assertEquals(1, result.rowsAffected)
Assertions.assertNotNull(result.getString(1))
}
@Test
@@ -139,7 +140,7 @@ class RequesterTest: TestAbstract() {
.getQuery("Test/selectOneWithParameters")
.selectOne(mapOf("name" to "myName")) {
assertEquals("myName", it!!.name)
Assert.assertEquals("plop", rows[0].getString("other"))
Assert.assertEquals("plop", getString("other"))
}!!
assertEquals("myName", obj.name)

View File

@@ -9,20 +9,22 @@ import java.io.File
@TestInstance(PER_CLASS)
abstract class TestAbstract {
private var connection = Connection(database = "test", username = "test", password = "test")
protected fun getConnextion(): Connection {
return Connection(database = "test", username = "test", password = "test")
return connection
}
@BeforeEach
fun beforeAll() {
val initSQL = File(this::class.java.getResource("/fixtures/init.sql").toURI())
val promise = getConnextion().connect().sendQuery(initSQL.readText())
promise.join()
getConnextion().connect().createStatement().executeUpdate(initSQL.readText())
}
@AfterEach
fun afterAll() {
val downSQL = File(this::class.java.getResource("/fixtures/down.sql").toURI())
getConnextion().connect().sendQuery(downSQL.readText()).join()
getConnextion().connect().createStatement().executeUpdate(downSQL.readText())
getConnextion().connect().close()
}
}