[英]dropwizard test integration give an exception ConfigurationParsingException
I 'm currently doing an integration test with the framwork dropwizard , embeddedmongo .我目前正在使用框架 dropwizard、embeddedmongo 进行集成测试。 but when I execute the tests , I always this exception .但是当我执行测试时,我总是这个异常。
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
and my integration.yml is here:我的 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
thank you for any help感谢您的任何帮助
From ConfigurationFactory.java , this exception is thrown only if the method readTree
from ObjectMapper
returns null.在ConfigurationFactory.java 中,仅当ObjectMapper
readTree
方法返回 null 时才会抛出此异常。
ConfigurationSourceProvider
derived class that you are passing to build
method, as it is not handling IOException
properly ( I can assume you are using a mocked one);查看您传递给build
方法的ConfigurationSourceProvider
派生类,因为它没有正确处理IOException
(我可以假设您使用的是模拟的);path
argument, it seems you should be passing "dropwizard-angular- example-master\\target\\test-classes\\integration.yml" instead of "dropwizard-angular-example-master\\target\\test-classes\\integration.yml" *first path has an empty space just after dropwizard-angular-查看path
参数,您似乎应该传递“dropwizard-angular-example-master\\target\\test-classes\\integration.yml”而不是“dropwizard-angular-example-master\\target\\test-classes\\integration.yml” " *第一条路径在dropwizard-angular之后有一个空白空间-If your dropwizard-config file (ie integration.yml
) is in test/resources
directory, you don't need to use ResourceHelpers.resourceFilePath("integration.yml")
to pass full config path into DropwizardAppExtension
as a param, you should only pass its name (eg "integration.yml")如果您的 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.