我目前正在与framwork dropwizard,embeddedmongo进行集成测试。但是当我执行测试时,我总是这个例外。
com.example.pointypatient.integration.PointyPatientApplicationTest Time elapsed: 3.054 sec <<< ERROR!
java.lang.RuntimeException: io.dropwizard.configuration.ConfigurationParsingException: dropwizard-angular- example-master\target\test-classes\integration.yml has an error:Configuration at dropwizard-angular-example-master\target\test-classes\integration.yml must not be empty
我的integration.yml就在这里:
dbConfig:
host: localhost
port: 12345
dbName: test
server:
applicationConnectors:
- type: http
port: 8080
- type: https
port: 8443
keyStorePath: example.keystore
keyStorePassword: example
validateCerts: false
adminConnectors:
- type: http
port: 8081
- type: https
port: 8444
keyStorePath: example.keystore
keyStorePassword: example
validateCerts: false
# Logging settings.
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: INFO
appenders:
- type: console
感谢您的帮助
答案 0 :(得分:0)
从ConfigurationFactory.java开始,仅当readTree
的方法ObjectMapper
返回null时才会抛出此异常。
ConfigurationSourceProvider
方法的build
派生类,因为它没有正确处理IOException
(我可以假设您使用的是模拟的); path
参数,看来你应该传递“dropwizard-angular- example-master \ target \ test-classes \ integration.yml”而不是“ dropwizard-angular-example-master \ target \ test-classes \ integration.yml“ *第一个路径在 dropwizard-angular - 答案 1 :(得分:0)
如果您的 dropwizard-config 文件(即 integration.yml
)在 test/resources
目录中,您不需要使用 ResourceHelpers.resourceFilePath("integration.yml")
将完整的配置路径传递到 DropwizardAppExtension
作为一个参数,你应该只传递它的名字(例如“integration.yml”)
private static DropwizardAppExtension<MyDropwizardConfiguration> RULE = new DropwizardAppExtension<>(
MyDropwizardApplication.class, "integration.yml");