Skip to content

Commit

Permalink
#322 use host prop
Browse files Browse the repository at this point in the history
  • Loading branch information
mgramin committed May 18, 2019
1 parent e59658d commit e148b47
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import com.google.gson.reflect.TypeToken
import org.apache.tomcat.jdbc.pool.DataSource
import org.springframework.core.io.Resource


/**
* @author Maksim Gramin ([email protected])
* @version $Id: f221782080d430e77aed80ef8446745687c350f4 $
* @since 0.1
*/
open class SimpleEndpoint(
var name: String? = null,
var host: String? = null,
@JsonIgnore var baseFolder: Resource? = null,
var user: String? = null,
@JsonIgnore var password: String? = null,
Expand All @@ -47,20 +47,16 @@ open class SimpleEndpoint(
var dialect: String? = null
) : Endpoint {

override fun name() = this.name!!

override fun host(): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun name() = name!!

override fun dialect() = this.dialect!!
override fun host() = host!!

private var dataSource: DataSource? = null
override fun dialect() = dialect!!

override fun properties(): Map<String, Any> {
return Gson().fromJson(properties, object : TypeToken<Map<String, Any>>() {}.type)
}
override fun properties(): Map<String, Any> =
Gson().fromJson(properties, object : TypeToken<Map<String, Any>>() {}.type)

private var dataSource: DataSource? = null

@JsonIgnore
override fun getDataSource(): DataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,26 @@ class FsResourceTypeTest {

init {
dbMd.name = "unit_test_db_md"
dbMd.host = "127.0.0.1"
dbMd.dialect = "h2"
dbMd.baseFolder = FileSystemResource("conf/h2/md/database")
dbMd.paginationQueryTemplate = "${'$'}{query} offset ${'$'}{uri.pageSize()*(uri.pageNumber()-1)} limit ${'$'}{uri.pageSize()}"
dbMd.properties = """{ "url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';" }"""
dbMd.properties = """
{
"url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';"
}
""".trimIndent()

dbSql.name = "unit_test_db_sql"
dbSql.host = "127.0.0.1"
dbSql.dialect = "h2"
dbSql.baseFolder = FileSystemResource("conf/h2/sql/database")
dbSql.paginationQueryTemplate = "${'$'}{query} offset ${'$'}{uri.pageSize()*(uri.pageNumber()-1)} limit ${'$'}{uri.pageSize()}"
dbSql.properties = """{ "url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';" }"""
dbSql.properties = """
{
"url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';"
}
""".trimIndent()
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ class SqlResourceTypeTest {

init {
db.name = "unit_test_db"
db.host = "127.0.0.1"
db.dialect = "h2"
db.baseFolder = FileSystemResource("conf/h2/database")
db.paginationQueryTemplate = "${'$'}{query} offset ${'$'}{uri.pageSize()*(uri.pageNumber()-1)} limit ${'$'}{uri.pageSize()}"
db.properties = """{ "url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';" }"""
db.properties = """
{
"url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';"
}
""".trimIndent()
}

@Test
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ conf:
endpoints:
- name: h2
host: 127.0.0.1
dialect: h2
baseFolder: file:conf/h2/md/database
driverClassName: org.h2.Driver
Expand All @@ -17,6 +18,7 @@ conf:
"description": "Embedded db for unit tests only"
}
- name: dev
host: 127.0.0.1
dialect: h2
baseFolder: file:conf/h2/md/database
driverClassName: org.h2.Driver
Expand All @@ -29,6 +31,7 @@ conf:
"css_class": "fas fa-fw fa-2x fa-tools"
}
- name: test
host: 127.0.0.1
dialect: h2
baseFolder: file:conf/h2/md/database
driverClassName: org.h2.Driver
Expand All @@ -41,6 +44,7 @@ conf:
"css_class": "fas fa-fw fa-2x fa-bug"
}
- name: prod
host: 127.0.0.1
dialect: h2
baseFolder: file:conf/h2/md/database
driverClassName: org.h2.Driver
Expand Down

0 comments on commit e148b47

Please sign in to comment.