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();
}
}
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());
}
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);
}
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);
}
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"));
}
Aggregations