Skip to content

Commit e148b47

Browse files
committed
#322 use host prop
1 parent e59658d commit e148b47

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

src/main/kotlin/com/github/mgramin/sqlboot/model/connection/SimpleEndpoint.kt

+7-11
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import com.google.gson.reflect.TypeToken
3030
import org.apache.tomcat.jdbc.pool.DataSource
3131
import org.springframework.core.io.Resource
3232

33-
3433
/**
3534
* @author Maksim Gramin ([email protected])
3635
* @version $Id: f221782080d430e77aed80ef8446745687c350f4 $
3736
* @since 0.1
3837
*/
3938
open class SimpleEndpoint(
4039
var name: String? = null,
40+
var host: String? = null,
4141
@JsonIgnore var baseFolder: Resource? = null,
4242
var user: String? = null,
4343
@JsonIgnore var password: String? = null,
@@ -47,20 +47,16 @@ open class SimpleEndpoint(
4747
var dialect: String? = null
4848
) : Endpoint {
4949

50-
override fun name() = this.name!!
51-
52-
override fun host(): String {
53-
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
54-
}
50+
override fun name() = name!!
5551

56-
override fun dialect() = this.dialect!!
52+
override fun host() = host!!
5753

58-
private var dataSource: DataSource? = null
54+
override fun dialect() = dialect!!
5955

60-
override fun properties(): Map<String, Any> {
61-
return Gson().fromJson(properties, object : TypeToken<Map<String, Any>>() {}.type)
62-
}
56+
override fun properties(): Map<String, Any> =
57+
Gson().fromJson(properties, object : TypeToken<Map<String, Any>>() {}.type)
6358

59+
private var dataSource: DataSource? = null
6460

6561
@JsonIgnore
6662
override fun getDataSource(): DataSource {

src/test/kotlin/com/github/mgramin/sqlboot/model/resourcetype/impl/FsResourceTypeTest.kt

+12-2
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,26 @@ class FsResourceTypeTest {
5454

5555
init {
5656
dbMd.name = "unit_test_db_md"
57+
dbMd.host = "127.0.0.1"
5758
dbMd.dialect = "h2"
5859
dbMd.baseFolder = FileSystemResource("conf/h2/md/database")
5960
dbMd.paginationQueryTemplate = "${'$'}{query} offset ${'$'}{uri.pageSize()*(uri.pageNumber()-1)} limit ${'$'}{uri.pageSize()}"
60-
dbMd.properties = """{ "url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';" }"""
61+
dbMd.properties = """
62+
{
63+
"url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';"
64+
}
65+
""".trimIndent()
6166

6267
dbSql.name = "unit_test_db_sql"
68+
dbSql.host = "127.0.0.1"
6369
dbSql.dialect = "h2"
6470
dbSql.baseFolder = FileSystemResource("conf/h2/sql/database")
6571
dbSql.paginationQueryTemplate = "${'$'}{query} offset ${'$'}{uri.pageSize()*(uri.pageNumber()-1)} limit ${'$'}{uri.pageSize()}"
66-
dbSql.properties = """{ "url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';" }"""
72+
dbSql.properties = """
73+
{
74+
"url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';"
75+
}
76+
""".trimIndent()
6777
}
6878

6979
@ParameterizedTest

src/test/kotlin/com/github/mgramin/sqlboot/model/resourcetype/impl/SqlResourceTypeTest.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ class SqlResourceTypeTest {
5151

5252
init {
5353
db.name = "unit_test_db"
54+
db.host = "127.0.0.1"
5455
db.dialect = "h2"
5556
db.baseFolder = FileSystemResource("conf/h2/database")
5657
db.paginationQueryTemplate = "${'$'}{query} offset ${'$'}{uri.pageSize()*(uri.pageNumber()-1)} limit ${'$'}{uri.pageSize()}"
57-
db.properties = """{ "url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';" }"""
58+
db.properties = """
59+
{
60+
"url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';"
61+
}
62+
""".trimIndent()
5863
}
5964

6065
@Test

src/test/resources/application.yml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ conf:
77
88
endpoints:
99
- name: h2
10+
host: 127.0.0.1
1011
dialect: h2
1112
baseFolder: file:conf/h2/md/database
1213
driverClassName: org.h2.Driver
@@ -17,6 +18,7 @@ conf:
1718
"description": "Embedded db for unit tests only"
1819
}
1920
- name: dev
21+
host: 127.0.0.1
2022
dialect: h2
2123
baseFolder: file:conf/h2/md/database
2224
driverClassName: org.h2.Driver
@@ -29,6 +31,7 @@ conf:
2931
"css_class": "fas fa-fw fa-2x fa-tools"
3032
}
3133
- name: test
34+
host: 127.0.0.1
3235
dialect: h2
3336
baseFolder: file:conf/h2/md/database
3437
driverClassName: org.h2.Driver
@@ -41,6 +44,7 @@ conf:
4144
"css_class": "fas fa-fw fa-2x fa-bug"
4245
}
4346
- name: prod
47+
host: 127.0.0.1
4448
dialect: h2
4549
baseFolder: file:conf/h2/md/database
4650
driverClassName: org.h2.Driver

0 commit comments

Comments
 (0)