我目前正在使用框架 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
感谢您的帮助
在 ConfigurationFactory.java 中,仅当
readTree
中的方法 ObjectMapper
返回 null 时才会抛出此异常。
ConfigurationSourceProvider
方法的 build
派生类,因为它没有正确处理 IOException
(我可以假设您正在使用模拟的);path
参数,看来你应该传递 "dropwizard-angular- example-master arget est-classes\integration.yml" 而不是 "dropwizard-angular-example-master arget est-classes\integration .yml" *第一个路径在 dropwizard-angular-如果您的 dropwizard-config 文件(即
integration.yml
)位于 test/resources
目录中,则无需使用 ResourceHelpers.resourceFilePath("integration.yml")
将完整配置路径传递到 DropwizardAppExtension
作为参数,您应该只传递其名称(例如“集成.yml”)
private static DropwizardAppExtension<MyDropwizardConfiguration> RULE = new DropwizardAppExtension<>(
MyDropwizardApplication.class, "integration.yml");
@updo,你得到答案了吗?我也面临着同样的问题...