I have a regular Spring Boot application (1.3.2) with MongoDB using MongoRepository
.
I would like to write an integration test for one of my endpoints that gets the data from the MongoDB. As far as I see from the Spring Boot 1.3 Release Notes Spring has auto-configuration for Embedded MongoDB (de.flapdoodle.embed.mongo
). However, I cannot figure out from Spring and flapdoodle documentation on how to write an integration test that would use already installed version of MongoDB on my filesystem.
So far my integration test looks like this:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class) // my application class
@WebAppConfiguration
public class IntegrationTest {
@Autowired
private MyRepository myRepository;
@Before
public void setup() {
myRepository.save(new MyEntity());
}
@Test
public void test() {
// here I will fire requests against the endpoint
}
}
I have added two dependencies with test
scope: spring-boot-starter-test
and de.flapdoodle.embed:de.flapdoodle.embed.mongo
. So when I run the test, I can see that flapdoodle attempts to download version of MongoDB, but fails since I am behind the proxy. But I do not want to download any versions, I want it to use my locally installed MongoDB. Is it possible to do this?
Aucun commentaire:
Enregistrer un commentaire