Search in sources :

Example 1 with ConvActionRequest

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

the class JaxbToElementTest method ConvActionRequestJaxbSubclassHandlingTestDisabled.

/**
     * Explore handling of Jaxb classes which specify an @XmlElement with
     * a super class.  How do subclasses get treated with this?
     * WSDLJaxbTest.ConvActionRequestJaxbSubclassHandlingTest passes,
     * i.e. it successfully unmarshalls to a ConvActionRequest with
     * a FolderActionSelector member.
     * However, even if I use those class files (with package name changed)
     * in place of the committed ones, this test only seems to unmarshall
     * with an ActionSelector member - i.e. the "recursive" and "url"
     * attribute information gets lost.
     */
// @Test
public void ConvActionRequestJaxbSubclassHandlingTestDisabled() throws Exception {
    ConvActionSelector actionSelector = ConvActionSelector.createForIdsAndOperation("ids", "op");
    actionSelector.setAcctRelativePath("folder");
    ConvActionRequest car = new ConvActionRequest(actionSelector);
    Element carE = JaxbUtil.jaxbToElement(car);
    String eXml = carE.toString();
    ZimbraLog.test.debug("ConvActionRequestJaxbSubclassHandling: marshalled XML=%s", eXml);
    Assert.assertTrue("Xml should contain acctRelPath attribute", eXml.contains("acctRelPath=\"folder\""));
    carE = Element.XMLElement.mFactory.createElement(MailConstants.CONV_ACTION_REQUEST);
    Element actionE = carE.addNonUniqueElement(MailConstants.E_ACTION);
    actionE.addAttribute(MailConstants.A_OPERATION, "op");
    actionE.addAttribute(MailConstants.A_ID, "ids");
    actionE.addAttribute(MailConstants.A_ACCT_RELATIVE_PATH, "folder");
    ZimbraLog.test.debug("ConvActionRequestJaxbSubclassHandling: half baked XML=%s", carE.toString());
    car = JaxbUtil.elementToJaxb(carE);
    carE = JaxbUtil.jaxbToElement(car);
    eXml = carE.toString();
    ZimbraLog.test.debug("ConvActionRequestJaxbSubclassHandling: round tripped XML=%s", eXml);
    ConvActionSelector as = car.getAction();
    Assert.assertEquals("acctRelPath attr value", "folder", as.getAcctRelativePath());
}
Also used : ConvActionSelector(com.zimbra.soap.mail.type.ConvActionSelector) ConvActionRequest(com.zimbra.soap.mail.message.ConvActionRequest) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) JAXBElement(javax.xml.bind.JAXBElement)

Example 2 with ConvActionRequest

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

the class TestDataSource method testRss.

/**
     * Creates a folder that syncs to another folder via RSS, and verifies that an
     * RSS data source was implicitly created.
     */
@Test
public void testRss() throws Exception {
    // Create source folder, make it publicly readable, and add a message to it.
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String parentId = Integer.toString(Mailbox.ID_FOLDER_USER_ROOT);
    ZFolder sourceFolder = TestUtil.createFolder(mbox, "/" + NAME_PREFIX + " testRss source");
    mbox.modifyFolderGrant(sourceFolder.getId(), GranteeType.pub, null, "r", null);
    String subject = NAME_PREFIX + " testRss";
    TestUtil.addMessage(mbox, subject, sourceFolder.getId());
    // Create destination folder that syncs to the source folder via RSS.
    String urlString = String.format("https://%s:%s/home/%s%s.rss", TestUtil.getServerAttr(Provisioning.A_zimbraServiceHostname), TestUtil.getServerAttr(Provisioning.A_zimbraMailSSLPort), USER_NAME, sourceFolder.getPath());
    urlString = HttpUtil.encodePath(urlString);
    ZFolder rssFolder = mbox.createFolder(parentId, NAME_PREFIX + " testRss destination", null, null, null, urlString);
    // Get the data source that was implicitly created.
    ZRssDataSource ds = (ZRssDataSource) getDataSource(mbox, rssFolder.getId());
    assertNotNull(ds);
    assertNull(mbox.testDataSource(ds));
    // Import data and validate the synced message.
    List<ZDataSource> list = new ArrayList<ZDataSource>();
    list.add(ds);
    mbox.importData(list);
    waitForData(mbox, rssFolder);
    ZMessage syncedMsg = TestUtil.getMessage(mbox, "in:\"" + rssFolder.getPath() + "\"");
    assertEquals(subject, syncedMsg.getSubject());
    /*
         *   Bug 102261 - simulate ZWC deleting an item from the folder
         */
    ConvActionSelector sel = ConvActionSelector.createForIdsAndOperation(syncedMsg.getConversationId(), "trash");
    sel.setConstraint("-dtjs");
    sel.setFolder(syncedMsg.getFolderId());
    try {
        mbox.invokeJaxb(new ConvActionRequest(sel));
    } catch (SoapFaultException sfe) {
        fail("SoapFaultException caught when deleting item from RSS datasource folder - " + sfe.getMessage());
    }
    // Delete folder, import data, and make sure that the data source was deleted.
    // Data source import runs asynchronously, so poll until the data source is gone.
    mbox.deleteFolder(rssFolder.getId());
//JBF - do not do the import; it will fail if DS is already deleted
//mbox.importData(list);
// XXX bburtin: disabled check to avoid false positives (bug 54816).  Some sort
// of race condition is causing this check to fail intermittently.  I was unable
// to consistently repro.
/*
        for (int i = 1; i <= 10; i++) {
            ds = (ZRssDataSource) getDataSource(mbox, rssFolder.getId());
            if (ds == null) {
                break;
            }
            Thread.sleep(500);
        }
        assertNull(ds);
        */
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZMailbox(com.zimbra.client.ZMailbox) ConvActionSelector(com.zimbra.soap.mail.type.ConvActionSelector) ConvActionRequest(com.zimbra.soap.mail.message.ConvActionRequest) ArrayList(java.util.ArrayList) ZRssDataSource(com.zimbra.client.ZRssDataSource) ZFolder(com.zimbra.client.ZFolder) ZDataSource(com.zimbra.client.ZDataSource) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Aggregations

ConvActionRequest (com.zimbra.soap.mail.message.ConvActionRequest)2 ConvActionSelector (com.zimbra.soap.mail.type.ConvActionSelector)2 ZDataSource (com.zimbra.client.ZDataSource)1 ZFolder (com.zimbra.client.ZFolder)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZMessage (com.zimbra.client.ZMessage)1 ZRssDataSource (com.zimbra.client.ZRssDataSource)1 Element (com.zimbra.common.soap.Element)1 JSONElement (com.zimbra.common.soap.Element.JSONElement)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 ArrayList (java.util.ArrayList)1 JAXBElement (javax.xml.bind.JAXBElement)1 Test (org.junit.Test)1