Search in sources :

Example 1 with LmcDeleteAccountRequest

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());
    }
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) DbMailbox(com.zimbra.cs.db.DbMailbox) LmcSession(com.zimbra.cs.client.LmcSession) DbResults(com.zimbra.cs.db.DbResults) File(java.io.File) LmcDeleteAccountRequest(com.zimbra.cs.client.soap.LmcDeleteAccountRequest)

Aggregations

Account (com.zimbra.cs.account.Account)1 LmcSession (com.zimbra.cs.client.LmcSession)1 LmcDeleteAccountRequest (com.zimbra.cs.client.soap.LmcDeleteAccountRequest)1 DbMailbox (com.zimbra.cs.db.DbMailbox)1 DbResults (com.zimbra.cs.db.DbResults)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 File (java.io.File)1