Skip to content

DataSource initialization fails for tests if @EnableCaching is on #1711

Closed
@ericdahl

Description

@ericdahl

I ran into a strange issue when enabling caching on an app: my tests started failing due to the database not having been loaded with data from data.sql.

Here's a test case that reproduces it: https://github.com/ericdahl/spring-boot-db-initialization-test

$ git clone https://github.com/ericdahl/spring-boot-db-initialization-test.git
$ cd spring-boot-db-initialization-test
$ mvn test
...
(various output)
2014-10-14 10:31:46.998  INFO 3788 --- [           main] o.s.jdbc.datasource.init.ScriptUtils     : Executing SQL script from URL [file:/Users/edahl/repos/github/spring-boot-db-initialization-test/target/classes/schema.sql]
2014-10-14 10:31:46.999  INFO 3788 --- [           main] o.s.jdbc.datasource.init.ScriptUtils     : Executed SQL script from URL [file:/Users/edahl/repos/github/spring-boot-db-initialization-test/target/classes/schema.sql] in 1 ms.
2014-10-14 10:31:47.000  WARN 3788 --- [           main] o.s.b.a.jdbc.DataSourceInitializer       : Could not send event to complete DataSource initialization (ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.web.context.support.GenericWebApplicationContext@4cc5aa00: startup date [Tue Oct 14 10:31:45 PDT 2014]; root of context hierarchy)
...
Expected: is a value greater than <0>
     but: <0> was equal to <0>

If I comment out @EnableCaching in Application.java, the test passes and there's no warning message emitted from the DataSourceInitializer. Alternatively, if I comment out @WebAppConfiguration in the test, it passes.

This was reproduced with:

  • 1.1.7.RELEASE
  • 1.1.8.RELEASE
  • 1.2.0.BUILD-SNAPSHOT

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions