i have a test case for dao implementation.
Test Class Code -
@RunWith(SpringRunner.class)
@RestClientTest({XyzDaoImpl.class})
@TestPropertySource(locations = "classpath:application-test.properties")
public class XyzDaoTest {
@Autowired
XyzDaoImpl xyzDaoImpl;
@Test
public void testGetXyzDetails(){
assertThat(xyzDaoImpl.getXyzDetails("123", null)).isNotNull();
}
}
xyzDaoImpl.getXyzDetails method implementation calls a backend using RestTemplate.
This test works fine when my config class code contains -
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
but if i create the rest template using builder to set timeout etc , Test fails -
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder
.setConnectTimeout(timeout)
.build();
}
Tried creating Bean using @Profile("test") default and @Profile("!test") - custom setting, still test fails.
Error is -
testException = java.lang.AssertionError: No further requests expected: HTTP POST http://... url.
Aucun commentaire:
Enregistrer un commentaire