mirror of
https://github.com/corda/corda.git
synced 2025-02-21 01:42:24 +00:00
CORDA-825 Test jdbc session and entity manager in corda service constructors (#5088)
This commit is contained in:
parent
2365276597
commit
268f6db430
@ -90,6 +90,16 @@ class CordaServiceTest {
|
||||
nodeA.services.cordaService(VaultQueryService::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Can query using jdbc session in constructor`() {
|
||||
nodeA.services.cordaService(JdbcSessionQueryService::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Can use entity manager in constructor`() {
|
||||
nodeA.services.cordaService(EntityManagerService::class.java)
|
||||
}
|
||||
|
||||
@StartableByService
|
||||
class DummyServiceFlow : FlowLogic<InvocationContext>() {
|
||||
companion object {
|
||||
@ -160,4 +170,20 @@ class CordaServiceTest {
|
||||
assertNotNull(Thread.currentThread().contextClassLoader, "thread context classloader should not be null during service initialisation")
|
||||
}
|
||||
}
|
||||
|
||||
@CordaService
|
||||
class JdbcSessionQueryService(val serviceHub: AppServiceHub): SingletonSerializeAsToken() {
|
||||
init {
|
||||
serviceHub.jdbcSession().prepareStatement("SELECT * FROM VAULT_STATES").execute()
|
||||
}
|
||||
}
|
||||
|
||||
@CordaService
|
||||
class EntityManagerService(val serviceHub: AppServiceHub): SingletonSerializeAsToken() {
|
||||
init {
|
||||
serviceHub.withEntityManager {
|
||||
createNativeQuery("SELECT * FROM VAULT_STATES").resultList
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user