I want to do an integration test on my project which store some data into MongoDB in test mode. I am using org.Mongo .
I have some testing unit class in /test folder. However when I run the unit class from eclipse, there is no data found at all from Mongo DB, nor can I get any collection instance from it.
Here is the test code like:
@Test
public void test(){
running(testServer(3333, fakeApplication(conf.asMap())), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
String body = "\"name:\": \"abc\"";
MongoStore.store(body);
}
});
}
Conf is different config file other than application.conf, which I use to provide staging config. MongoStore is just a wrapper to store data in mongoDB.
I can never store the date into Mongo ( I am pretty sure the rest of mongo connection is good to use ), Nor can I get an instance of DBCollection.
Anyone know how to connect the play to mongo db when running in test unit?