Java Code Examples for com.mongodb.MongoClient#dropDatabase()

The following examples show how to use com.mongodb.MongoClient#dropDatabase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicStorageTest.java    From lumongo with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void cleanDatabaseAndInit() throws Exception {

	MongoClient mongo = TestHelper.getMongo();
	mongo.dropDatabase(TestHelper.TEST_DATABASE_NAME);
	directory = new DistributedDirectory(new MongoDirectory(mongo, TestHelper.TEST_DATABASE_NAME, STORAGE_TEST_INDEX, false));

	StandardAnalyzer analyzer = new StandardAnalyzer();
	IndexWriterConfig config = new IndexWriterConfig(analyzer);

	IndexWriter w = new IndexWriter(directory, config);

	addDoc(w, "Random perl Title that is long", "id-1");
	addDoc(w, "Random java Title that is long", "id-1");
	addDoc(w, "MongoDB is awesome", "id-2");
	addDoc(w, "This is a long title with nothing interesting", "id-3");
	addDoc(w, "Java is awesome", "id-4");
	addDoc(w, "Really big fish", "id-5");

	w.commit();
	w.close();
}
 
Example 2
Source File: HVDFChannelTest.java    From hvdf with Apache License 2.0 5 votes vote down vote up
public HVDFChannelTest() 
        throws UnknownHostException {
    
    Map<String, Object> defaultConfig = new LinkedHashMap<String, Object>();
    defaultConfig.put(ServiceManager.MODEL_KEY, "DefaultChannelService");
    

    MongoClientURI uri = new MongoClientURI(BASE_URI + databaseName);
    testClient = new MongoClient(uri);
    testClient.dropDatabase(databaseName);
    
    // Load the configured ContentService implementation 
    ServiceFactory factory = new ServiceFactory();
    this.channelSvc = factory.createService(ChannelService.class, defaultConfig, uri);
}
 
Example 3
Source File: FacetStorageTest.java    From lumongo with Apache License 2.0 4 votes vote down vote up
public static void init() throws IOException {
	MongoClient mongo = TestHelper.getMongo();
	mongo.dropDatabase(TestHelper.TEST_DATABASE_NAME);
	directory = new DistributedDirectory(new MongoDirectory(mongo, TestHelper.TEST_DATABASE_NAME, STORAGE_TEST_INDEX, false));
}