Search in sources :

Example 1 with BrowseResponse

use of com.zimbra.soap.mail.message.BrowseResponse in project zm-mailbox by Zimbra.

the class TestJaxb method testBrowseRequestAttachments.

@Test
public void testBrowseRequestAttachments() 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_APPLICATION_PDF).create();
    TestUtil.addRawMessage(zmbox, raw);
    forceIndexing(USER_NAME);
    BrowseRequest browseRequest = new BrowseRequest("attachments", /* 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("JAXB BrowseResponse datas", 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 2 with BrowseResponse

use of com.zimbra.soap.mail.message.BrowseResponse 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 3 with BrowseResponse

use of com.zimbra.soap.mail.message.BrowseResponse 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)

Example 4 with BrowseResponse

use of com.zimbra.soap.mail.message.BrowseResponse in project zm-mailbox by Zimbra.

the class TestJaxb method doBrowseRequest.

public BrowseResponse doBrowseRequest(BrowseRequest browseRequest) throws Exception {
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String authToken = mbox.getAuthToken().getValue();
    DocumentResult dr = new DocumentResult();
    marshaller.marshal(browseRequest, dr);
    Document doc = dr.getDocument();
    ZimbraLog.test.debug(doc.getRootElement().asXML());
    return (BrowseResponse) sendReq(envelope(authToken, doc.getRootElement().asXML()), "BrowseRequest");
}
Also used : BrowseResponse(com.zimbra.soap.mail.message.BrowseResponse) ZMailbox(com.zimbra.client.ZMailbox) DocumentResult(org.dom4j.io.DocumentResult) Document(org.dom4j.Document)

Example 5 with BrowseResponse

use of com.zimbra.soap.mail.message.BrowseResponse in project zm-mailbox by Zimbra.

the class TestJaxb method testBrowseRequestDomains.

@Test
public void testBrowseRequestDomains() throws Exception {
    TestUtil.createAccount(USER_NAME);
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    TestUtil.addMessage(mbox, NAME_PREFIX);
    BrowseRequest browseRequest = new BrowseRequest("domains", /* browseBy */
    "", /* regex */
    10);
    BrowseResponse browseResponse = doBrowseRequest(browseRequest);
    Assert.assertNotNull("JAXB BrowseResponse object", browseResponse);
    List<BrowseData> datas = browseResponse.getBrowseDatas();
    Assert.assertNotNull("JAXB BrowseResponse datas", datas);
}
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)

Aggregations

ZMailbox (com.zimbra.client.ZMailbox)5 BrowseResponse (com.zimbra.soap.mail.message.BrowseResponse)5 BrowseRequest (com.zimbra.soap.mail.message.BrowseRequest)4 Test (org.junit.Test)4 BrowseData (com.zimbra.soap.mail.type.BrowseData)3 Element (com.zimbra.common.soap.Element)1 Document (org.dom4j.Document)1 DocumentResult (org.dom4j.io.DocumentResult)1