本文整理匯總了Java中com.mongodb.MongoClient.dropDatabase方法的典型用法代碼示例。如果您正苦於以下問題:Java MongoClient.dropDatabase方法的具體用法?Java MongoClient.dropDatabase怎麽用?Java MongoClient.dropDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.mongodb.MongoClient
的用法示例。
在下文中一共展示了MongoClient.dropDatabase方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: single_host_without_credentials
import com.mongodb.MongoClient; //導入方法依賴的package包/類
@Test
public void single_host_without_credentials() throws InitializationException {
final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
final StandardMongoClientService service = new StandardMongoClientService();
runner.addControllerService("test-good1", service);
runner.setProperty(service, StandardMongoClientService.HOSTS, "localhost:27017");
runner.enableControllerService(service);
runner.assertValid(service);
StandardMongoClientService mongoService = (StandardMongoClientService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-good1");
assertNotNull(mongoService);
MongoClient mongoClient = mongoService.getMongoClient();
assertNotNull(mongoClient);
assertEquals(0, mongoClient.getDatabase(MONGO_DATABASE_NAME).getCollection("sample").count());
mongoClient.dropDatabase(MONGO_DATABASE_NAME);
}
示例2: destroyTestStorageGuard
import com.mongodb.MongoClient; //導入方法依賴的package包/類
/**
* A method that destroys the test storage guard.
*/
private void destroyTestStorageGuard() {
MongoClient testMongoClient = testStorageGuard.getMongo();
testMongoClient.dropDatabase(TEST_DATABASE_NAME);
testMongoClient.close();
}