use of com.zimbra.cs.client.soap.LmcDeleteAccountRequest in project zm-mailbox by Zimbra.
the class TestAccount method testDeleteAccount.
public void testDeleteAccount() throws Exception {
ZimbraLog.test.debug("testDeleteAccount()");
// Get the account and mailbox
Account account = TestUtil.getAccount(USER_NAME);
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
String dbName = DbMailbox.getDatabaseName(mbox);
ZimbraLog.test.debug("Account=" + account.getId() + ", mbox=" + mbox.getId());
// Confirm that the mailbox database exists
DbResults results = DbUtil.executeQuery("SELECT COUNT(*) FROM mailbox WHERE id = " + mbox.getId());
assertEquals("Could not find row in mailbox table", 1, results.getInt(1));
results = DbUtil.executeQuery("SHOW DATABASES LIKE '" + dbName + "'");
assertEquals("Could not find mailbox database", 1, results.size());
// Add a message to the account and confirm that the message directory exists
TestUtil.addMessage(mbox, "TestAccount testDeleteAccount");
String storePath = VolumeManager.getInstance().getCurrentMessageVolume().getMessageRootDir(mbox.getId());
File storeDir = new File(storePath);
if (TestUtil.checkLocalBlobs()) {
assertTrue(storePath + " does not exist", storeDir.exists());
assertTrue(storePath + " is not a directory", storeDir.isDirectory());
}
// Delete the account
LmcSession session = TestUtil.getAdminSoapSession();
LmcDeleteAccountRequest req = new LmcDeleteAccountRequest(account.getId());
req.setSession(session);
req.invoke(TestUtil.getAdminSoapUrl());
// Confirm that the mailbox was deleted
results = DbUtil.executeQuery("SELECT COUNT(*) FROM mailbox WHERE id = " + mbox.getId());
assertEquals("Unexpected row in mailbox table", 0, results.getInt(1));
if (TestUtil.checkLocalBlobs()) {
// Confirm that the message directory was deleted
assertFalse(storePath + " exists", storeDir.exists());
}
}
Aggregations