Skip to content

Commit

Permalink
enabling sqlite usage within scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Hub committed Aug 1, 2022
1 parent 5ec3651 commit 99559e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import com.github.kagkarlsson.scheduler.task.schedule.Schedules
import io.ktor.application.*
import kotlinx.coroutines.runBlocking
import org.eclipse.tractusx.managedidentitywallets.Services
import org.eclipse.tractusx.managedidentitywallets.persistence.entities.SchedulerTasks
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction
import org.postgresql.ds.PGSimpleDataSource
import org.sqlite.SQLiteDataSource
import java.sql.DriverManager
Expand Down Expand Up @@ -63,6 +66,12 @@ fun initDatabase(jdbcUrl: String): DataSource {
// just a keepAliveConnection
DriverManager.getConnection(jdbcUrl)

transaction {
// Create missing tables
SchemaUtils.createMissingTablesAndColumns(SchedulerTasks)
commit()
}

return dataSource
} else {
val dataSource = PGSimpleDataSource()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ApplicationTest {
put("auth.redirectUrl", System.getenv("CX_AUTH_REDIRECT_URL") ?: "http://localhost:8080/callback")

put("bpdm.datapoolUrl", System.getenv("BPDM_DATAPOOL_URL") ?: "http://0.0.0.0:8080")
put("bpdm.pullDataAtHour", System.getenv("BPDM_PULL_DATA_AT_HOUR") ?: "23")
}
// just a keepAliveConnection
DriverManager.getConnection(jdbcUrl)
Expand Down Expand Up @@ -1611,4 +1612,23 @@ class ApplicationTest {

}
}

@Test
fun testJobs() {
withTestApplication({
setupEnvironment(environment)
configurePersistence()
configureOpenAPI()
configureSecurity()
configureRouting(walletService)
appRoutes(walletService, bpdService)
configureSerialization()
configureJobs()
Services.walletService = walletService
Services.businessPartnerDataService = bpdService
}) {
// expecting a successfull start
assertTrue(true)
}
}
}

0 comments on commit 99559e5

Please sign in to comment.