当我使用multiTenancy时,如何测试域类?
我可以看到,我需要使用HibernateSpec进行扩展并覆盖getConfiguration。
当我使用ServiceUnitTest时,这是可以的,但对于DomainUnitTest则不行。
简单的示例: application.yml是通过以下方式设置的:
grails:
gorm:
multiTenancy:
mode: DISCRIMINATOR
tenantResolverClass: security.CompanyTenantResolver我的测试:
class TestSpec extends HibernateSpec implements DomainUnitTest<Test>{
void "expect ok test"() {
expect:
true
}
def setup() {
System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME, 'unit-test')
}
def cleanup() {
System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME, '')
}
@Override
Map getConfiguration() {
[(Settings.SETTING_MULTI_TENANT_RESOLVER_CLASS): SystemPropertyTenantResolver]
}
}无论我如何努力,我都会得到:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.grails.beans.ConstraintsEvaluator': Cannot resolve reference to bean 'grailsDomainClassMappingContext' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.datastore.mapping.simple.SimpleMapDatastore]: Constructor threw exception; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Class<?>]是grails中的错误还是忘记了什么?
发布于 2018-02-26 12:24:36
这是grails版本3.3.2中的一个错误,在3.3.0版本中工作正常
https://stackoverflow.com/questions/48978398
复制相似问题