@Test(expected = NoResourceException.class) public void deleteDb_dbNotExist_exception() { String dbName = "mazha_test_deletedb_not_exist"; CouchClient customClient = new CouchClient(getCouchConfig(dbName)); Preconditions.checkArgument(!isDbExist(dbName), "%s must not exist", dbName); customClient.deleteDb(); }
@Test(expected = CouchException.class) public void createDb_invalidDBNmae_exception() { // Couch does not like capital character in db name String dbName = "mazha_test_INVALID_DB_NAME"; CouchClient customClient = new CouchClient(getCouchConfig(dbName)); customClient.createDb(); }
private boolean isDbExist(String dbName) { try { CouchClient c = new CouchClient(getCouchConfig(dbName)); c.getDbInfo(); return true; } catch (CouchException ce) { return false; } }
@Test public void deleteDb_dbMustBeDeleted() { String dbName = "mazha_test_deletedb" + System.currentTimeMillis(); CouchClient customClient = new CouchClient(getCouchConfig(dbName)); ClientTestUtils.deleteQuietly(client); customClient.createDb(); Assert.assertTrue("DB must exist.", isDbExist(dbName)); customClient.deleteDb(); Assert.assertFalse("DB must not exist.", isDbExist(dbName)); }
@Test(expected = CouchException.class) public void getDbInfo_invalidDbName_exception() { String dbName = "mazha_test_A"; CouchClient customClient = new CouchClient(getCouchConfig(dbName)); customClient.getDbInfo(); }