-
-
Save pvardanega/9d82f8b977a4f332627a to your computer and use it in GitHub Desktop.
Fongo Jongo Junit rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.fakemongo.Fongo; | |
import org.jongo.Jongo; | |
import org.jongo.MongoCollection; | |
import org.junit.rules.ExternalResource; | |
public class FongoJongo extends ExternalResource { | |
private final Jongo jongo; | |
private FongoJongo() { | |
jongo = new Jongo(new Fongo("Test").getDB("Database")); | |
} | |
@Override | |
protected void after() { | |
super.after(); | |
for (String collectionName : jongo.getDatabase().getCollectionNames()) { | |
getCollection(collectionName).drop(); | |
} | |
} | |
public MongoCollection getCollection(String collectionName) { | |
return jongo.getCollection(collectionName); | |
} | |
[...] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment