Closed ursjoss closed 8 years ago
It seems that even with the @DataJpaTest annotation he is using the DemoApplication as the entry point. Cause of the interitence he creates the WicketBootStandardWebApplication bean and can't find the GeneralSettingsProperties bean.
Workaround: You can move the WicketBootStandardWebApplication in a separated class. So that the WicketBootStandardWebApplication is not created at all.
I will think of an alternative aproach...
I don't see any other alternative. Did you tried out my proposal?
Hi Marc
I managed to get the test running while still extending WicketBootStandardApplication
. I simply provided the two missing dependencies by mocking them using @MockBean
, i.e.
@RunWith(SpringRunner.class)
@DataJpaTest
public class CustomerRepositoryTest {
@Autowired
private CustomerRepository repo;
@MockBean
private GeneralSettingsProperties generalSettingsProperties;
@MockBean
private WicketClassCandidatesHolder classCandidates;
@Test
public void test() {
assertThat(repo.count()).isEqualTo(0);
}
}
Hi Marc
I am experimenting with the new test features of spring-boot-1.4 in a JPA project. If I extend my application class from either
WicketBootStandardWebApplication
orWicketBootSecuredWebApplication
, a working JPA integration test using the@DataJpaTest
fails with the following exception:Note that the test is supposed to test the JPA layer in isolation, trying not to load regular
@Component
s or anything from the Web layer into the application context.I have created a relatively minimal example to illustrate the case: Example project on github The
CustomerRepositoryTest
fails with the given configuration. You can see it pass if you modify theDemoApplication
class to not extendWicketBootStandardWebApplication
.Thanks upfront for checking this out. Thanks and cheers Urs
Here's the full stack trace for reference: