如何在multiTenancy时使用DomainUnitTest进行测试

时间:2018-02-25 20:58:37

标签: grails gorm spock

使用multiTenancy时如何测试域类?

我可以看到我需要使用HibernateSpec进行扩展并覆盖getConfiguration。

当我使用ServiceUnitTest而不是DomainUnitTest

时,这没关系

简单示例: application.yml设置为:

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<?>]

无论我尝试得到什么:

{{1}}

这是grails中的错误还是遗忘了什么?

0 个答案:

没有答案