updo
updo

Reputation: 97

dropwizard test integration give an exception ConfigurationParsingException

I 'm currently doing an integration test with the framwork 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:

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

Upvotes: 1

Views: 1994

Answers (2)

If your dropwizard-config file (i.e. 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 (e.g. "integration.yml")

private static DropwizardAppExtension<MyDropwizardConfiguration> RULE = new DropwizardAppExtension<>(
            MyDropwizardApplication.class, "integration.yml");

Upvotes: 1

Cleiton
Cleiton

Reputation: 18123

From ConfigurationFactory.java, this exception is thrown only if the method readTree from ObjectMapper returns null.

  • Look at 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);
  • Look at 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-

Upvotes: 1

Related Questions