1
1
package com.github.aysnc.sql.db.integration
2
2
3
- import com.github.jasync.sql.db.postgis.Geom
4
- import com.github.jasync.sql.db.postgis.JtsColumnDecoder
5
- import com.github.jasync.sql.db.postgresql.column.PostgreSQLColumnDecoderRegistry
3
+ import com.github.jasync.sql.db.postgis.JasyncPostgisRegister
6
4
import org.assertj.core.api.Assertions.assertThat
7
5
import org.junit.Test
8
6
import org.locationtech.jts.geom.GeometryFactory
@@ -11,25 +9,44 @@ import org.locationtech.jts.io.WKTReader
11
9
12
10
class PostgisSpec : DatabaseTestHelper () {
13
11
14
- init {
15
- PostgreSQLColumnDecoderRegistry .Instance .registerDecoder(Geom .GeometryColumnType , JtsColumnDecoder ())
16
- }
17
-
18
12
private val lineString = WKTReader (GeometryFactory (PrecisionModel (), 4326 )).read(" LINESTRING(1 2, 3 4)" )
13
+ private val pointString = WKTReader (GeometryFactory (PrecisionModel (), 4326 )).read(" POINT(1 2)" )
14
+
15
+ private fun setup () {
16
+ withHandler { connection ->
17
+ JasyncPostgisRegister .init (connection).get()
18
+ }
19
+ }
19
20
20
21
@Test
21
- fun `simple query ` () {
22
+ fun `test version ` () {
22
23
withHandler { handler ->
23
24
val res1 = executeQuery(handler, " SELECT postgis_full_version()" )
24
25
assertThat(res1.rows[0 ][0 ].toString()).contains(" POSTGIS=" )
25
- // val res2 = executeQuery(handler, "SELECT ST_GeomFromText('POINT(1 2)',4326)")
26
- val res2 = executeQuery(handler, " SELECT ST_GeomFromText('LINESTRING(1 2, 3 4)',4326)" )
27
- assertThat(res2.rows[0 ][0 ]).isEqualTo(lineString)
26
+ }
27
+ }
28
+
29
+ @Test
30
+ fun `simple line query` () {
31
+ setup()
32
+ withHandler { handler ->
33
+ val res = executeQuery(handler, " SELECT ST_GeomFromText('LINESTRING(1 2, 3 4)',4326)" )
34
+ assertThat(res.rows[0 ][0 ]).isEqualTo(lineString)
35
+ }
36
+ }
37
+
38
+ @Test
39
+ fun `simple point query` () {
40
+ setup()
41
+ withHandler { handler ->
42
+ val res = executeQuery(handler, " SELECT ST_GeomFromText('POINT(1 2)',4326)" )
43
+ assertThat(res.rows[0 ][0 ]).isEqualTo(pointString)
28
44
}
29
45
}
30
46
31
47
@Test
32
48
fun `insert and query` () {
49
+ setup()
33
50
withHandler { handler ->
34
51
executeQuery(handler, " DROP TABLE if exists postgis_geom_test" )
35
52
executeQuery(handler, " CREATE TABLE postgis_geom_test (geom geometry NOT NULL)" )
0 commit comments