Search in sources :

Example 91 with ZMailbox

use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.

the class TestImapThrottle method clearData.

@After
public void clearData() throws ServiceException {
    @SuppressWarnings("unused") ZMailbox // funky, but somehow it
    mbox = TestUtil.getZMailbox(USER);
    // gets us around SSL
    TestUtil.deleteAccount(USER);
    if (connection != null) {
        connection.close();
    }
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) After(org.junit.After)

Example 92 with ZMailbox

use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.

the class TestIndex method testFilenameSearch.

/**
 * Verifies the fix to bug 54613.
 */
@Test
public void testFilenameSearch() throws Exception {
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String filename = NAME_PREFIX + " testFilenameSearch.txt";
    TestUtil.createDocument(mbox, Integer.toString(Mailbox.ID_FOLDER_BRIEFCASE), filename, "text/plain", "This is the data for testFilenameSearch.".getBytes());
    Assert.assertEquals(0, TestUtil.search(mbox, "filename:Blob*", ZSearchParams.TYPE_DOCUMENT).size());
    Assert.assertEquals(1, TestUtil.search(mbox, "filename:\"" + filename + "\"", ZSearchParams.TYPE_DOCUMENT).size());
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) Test(org.junit.Test)

Example 93 with ZMailbox

use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.

the class TestIndex method sendMessage.

/**
 * Sends a message with the specified attachment, waits for the message to
 * arrives, and runs a query.
 * @param subject the subject of the message
 * @param attData attachment data
 * @param attName attachment name
 * @param attContentType attachment content type
 * @param query query to run after message arrives
 * @return <tt>true</tt> if the query returns the message
 */
private ZMessage sendMessage(String subject, byte[] attData, String attName, String attContentType) throws Exception {
    // Send message
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String attachmentId = mbox.uploadAttachment(attName, attData, attContentType, 5000);
    TestUtil.sendMessage(mbox, USER_NAME, subject, "Cranberry sauce", attachmentId);
    String query = "in:inbox subject:\"" + subject + "\"";
    return TestUtil.waitForMessage(mbox, query);
}
Also used : ZMailbox(com.zimbra.client.ZMailbox)

Example 94 with ZMailbox

use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.

the class TestJaxb method testBrowseRequestObjects.

@Test
public void testBrowseRequestObjects() throws Exception {
    TestUtil.createAccount(USER_NAME);
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    MessageBuilder mb = new MessageBuilder();
    String raw = mb.withSubject(NAME_PREFIX).withBody(bodyWithObject).withContentType(MimeConstants.CT_TEXT_PLAIN).create();
    TestUtil.addRawMessage(zmbox, raw);
    forceIndexing(USER_NAME);
    BrowseRequest browseRequest = new BrowseRequest("objects", /* browseBy */
    "", /* regex */
    10);
    BrowseResponse browseResponse = doBrowseRequest(browseRequest);
    Assert.assertNotNull("JAXB BrowseResponse object", browseResponse);
    List<BrowseData> datas = browseResponse.getBrowseDatas();
    Assert.assertNotNull("JAXB BrowseResponse datas", datas);
    Assert.assertTrue("BrowseDatas size should be greater than 0", datas.size() >= 1);
}
Also used : BrowseResponse(com.zimbra.soap.mail.message.BrowseResponse) ZMailbox(com.zimbra.client.ZMailbox) BrowseRequest(com.zimbra.soap.mail.message.BrowseRequest) BrowseData(com.zimbra.soap.mail.type.BrowseData) Test(org.junit.Test)

Example 95 with ZMailbox

use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.

the class TestJaxb method testBrowseRequestObjectsBadRegex.

/**
 * BrowseRequest should fail as regex is too complex
 */
@Test
public void testBrowseRequestObjectsBadRegex() throws Exception {
    TestUtil.createAccount(USER_NAME);
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    MessageBuilder mb = new MessageBuilder();
    String raw = mb.withSubject(NAME_PREFIX).withBody(bodyWithObject).withContentType(MimeConstants.CT_TEXT_PLAIN).create();
    TestUtil.addRawMessage(zmbox, raw);
    forceIndexing(USER_NAME);
    BrowseRequest browseRequest = new BrowseRequest("objects", /* browseBy */
    "", /* regex */
    10);
    BrowseResponse browseResponse = doBrowseRequest(browseRequest);
    Assert.assertTrue("BrowseDatas size should be greater than 1", browseResponse.getBrowseDatas().size() >= 1);
    browseRequest = new BrowseRequest("objects", /* browseBy */
    BAD_REGEX, /* regex */
    10);
    Element envelope = doBadBrowseRequest(browseRequest);
    Assert.assertNotNull("Envelope", envelope);
    Assert.assertTrue("Error contained in SOAP response", envelope.toString().contains("regular expression match involved more than 100000 accesses for pattern"));
}
Also used : BrowseResponse(com.zimbra.soap.mail.message.BrowseResponse) ZMailbox(com.zimbra.client.ZMailbox) Element(com.zimbra.common.soap.Element) BrowseRequest(com.zimbra.soap.mail.message.BrowseRequest) Test(org.junit.Test)

Aggregations

ZMailbox (com.zimbra.client.ZMailbox)383 Test (org.junit.Test)288 ZFolder (com.zimbra.client.ZFolder)90 ZMessage (com.zimbra.client.ZMessage)82 Mailbox (com.zimbra.cs.mailbox.Mailbox)61 Account (com.zimbra.cs.account.Account)60 ServiceException (com.zimbra.common.service.ServiceException)55 ArrayList (java.util.ArrayList)38 IOException (java.io.IOException)35 MessageData (com.zimbra.cs.mailclient.imap.MessageData)28 ZMountpoint (com.zimbra.client.ZMountpoint)26 Message (com.zimbra.cs.mailbox.Message)24 HashMap (java.util.HashMap)23 ZOutgoingMessage (com.zimbra.client.ZMailbox.ZOutgoingMessage)21 ZTag (com.zimbra.client.ZTag)21 SoapFaultException (com.zimbra.common.soap.SoapFaultException)21 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)21 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)20 HttpClient (org.apache.http.client.HttpClient)19 ZSearchParams (com.zimbra.client.ZSearchParams)18