[英]dropwizard test integration give an exception ConfigurationParsingException
我目前正在使用框架 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 中,僅當ObjectMapper
readTree
方法返回 null 時才會拋出此異常。
build
方法的ConfigurationSourceProvider
派生類,因為它沒有正確處理IOException
(我可以假設您使用的是模擬的);path
參數,您似乎應該傳遞“dropwizard-angular-example-master\\target\\test-classes\\integration.yml”而不是“dropwizard-angular-example-master\\target\\test-classes\\integration.yml” " *第一條路徑在dropwizard-angular之后有一個空白空間-如果您的 dropwizard-config 文件(即integration.yml
)在test/resources
目錄中,您不需要使用ResourceHelpers.resourceFilePath("integration.yml")
將完整的配置路徑作為參數傳遞給DropwizardAppExtension
,您應該只傳遞其名稱(例如“integration.yml”)
private static DropwizardAppExtension<MyDropwizardConfiguration> RULE = new DropwizardAppExtension<>(
MyDropwizardApplication.class, "integration.yml");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.