我编写了一个基于Spring Boot的Web应用程序,预计将在WildFly服务器中运行。应用程序运行良好,但问题在于测试。
我有服务器处理的数据库连接,缓存和事务管理。现在,我需要能够测试它们。虽然我能够通过模拟JNDI连接和事务管理来解决数据库连接问题,但我不确定如何处理缓存测试。
一种解决方案是使用Arquillian项目。但是,要么这个项目无法识别Spring Boot /我做错了什么,这让我很难测试应用程序。
有人可以建议解决这个问题吗?下面是我的hibernate特定属性
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2008Dialect
spring.jpa.properties.hibernate.cache.region.factory_class=org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory
spring.jpa.properties.hibernate.cache.infinispan.cachemanager=java:jboss/infinispan/container/hibernate
spring.jpa.properties.hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.hibernate.cache.use_query_cache=false
spring.jpa.properties.hibernate.hbm2ddl.auto=none
spring.jpa.properties.hibernate.generate_statistics=true
spring.jpa.properties.hibernate.cache.infinispan.statistics=true
spring.jpa.properties.hibernate.search.default.directory_provider=infinispan
spring.jpa.properties.hibernate.search.infinispan.cachemanager_jndiname=java:jboss/infinispan/container/hibernate
答案 0 :(得分:0)
我建议为测试创建单独的配置。此配置将包含TransactionManager bean的定义 - here is an example from other post。下一步是提供您自己的TransactionManagerLookup实施并将其应用于传输配置 - 如the manual中所述。