Search in sources :

Example 1 with TestDataSourceRequest

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

the class ZMailbox method testDataSource.

/**
 * Tests a data source.
 *
 * @return <tt>null</tt> on success, or the error string on failure
 */
public String testDataSource(ZDataSource source) throws ServiceException {
    TestDataSourceRequest req = new TestDataSourceRequest();
    DataSource jaxbObj = source.toJaxb();
    req.setDataSource(jaxbObj);
    TestDataSourceResponse resp = (TestDataSourceResponse) invokeJaxb(req);
    List<TestDataSource> dataSources = resp.getDataSources();
    int success = 0;
    if (dataSources.size() > 0 && dataSources.get(0) != null) {
        TestDataSource ds = dataSources.get(0);
        success = ds.getSuccess();
        if (success < 1) {
            return ds.getError();
        } else {
            return null;
        }
    }
    return null;
}
Also used : TestDataSourceRequest(com.zimbra.soap.mail.message.TestDataSourceRequest) TestDataSource(com.zimbra.soap.mail.type.TestDataSource) TestDataSourceResponse(com.zimbra.soap.mail.message.TestDataSourceResponse) RssDataSource(com.zimbra.soap.type.RssDataSource) TestDataSource(com.zimbra.soap.mail.type.TestDataSource) DataSource(com.zimbra.soap.type.DataSource) Pop3DataSource(com.zimbra.soap.type.Pop3DataSource) ImapDataSource(com.zimbra.soap.type.ImapDataSource) CalDataSource(com.zimbra.soap.type.CalDataSource)

Example 2 with TestDataSourceRequest

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

the class DataSourceJaxbTest method testTestDataSourceRequest.

@Test
public void testTestDataSourceRequest() throws Exception {
    JAXBContext jaxb = JAXBContext.newInstance(TestDataSourceRequest.class);
    Unmarshaller unmarshaller = jaxb.createUnmarshaller();
    TestDataSourceRequest req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestUnknownDataSourceRequest.xml"));
    DataSource ds = req.getDataSource();
    assertNotNull("Generic DataSource should not be NULL", ds);
    assertNotNull("Generic DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for generic DataSource", "11e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailDataSource", ds instanceof MailDataSource);
    req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestImapDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("IMAP DataSource should not be NULL", ds);
    assertNotNull("IMAP DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for IMAP DataSource", "71e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailImapDataSource", ds instanceof MailImapDataSource);
    req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestCalDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("Cal DataSource should not be NULL", ds);
    assertNotNull("Cal DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for Cal DataSource", "31e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailCalDataSource", ds instanceof MailCalDataSource);
    req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestGalDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("GAL DataSource should not be NULL", ds);
    assertNotNull("GAL DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for GAL DataSource", "51e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailGalDataSource", ds instanceof MailGalDataSource);
    req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestPop3DataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("POP3 DataSource should not be NULL", ds);
    assertNotNull("POP3 DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for POP3 DataSource", "41e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailPop3DataSource", ds instanceof MailPop3DataSource);
    req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestCaldavDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("Caldav DataSource should not be NULL", ds);
    assertNotNull("Caldav DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for Caldav DataSource", "31e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailCaldavDataSource", ds instanceof MailCaldavDataSource);
    req = (TestDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("TestRssDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("RSS DataSource should not be NULL", ds);
    assertNotNull("RSS DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for RSS DataSource", "21e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailRssDataSource", ds instanceof MailRssDataSource);
}
Also used : MailCalDataSource(com.zimbra.soap.mail.type.MailCalDataSource) TestDataSourceRequest(com.zimbra.soap.mail.message.TestDataSourceRequest) MailDataSource(com.zimbra.soap.mail.type.MailDataSource) MailCaldavDataSource(com.zimbra.soap.mail.type.MailCaldavDataSource) MailGalDataSource(com.zimbra.soap.mail.type.MailGalDataSource) MailRssDataSource(com.zimbra.soap.mail.type.MailRssDataSource) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) MailImapDataSource(com.zimbra.soap.mail.type.MailImapDataSource) MailPop3DataSource(com.zimbra.soap.mail.type.MailPop3DataSource) MailCalDataSource(com.zimbra.soap.mail.type.MailCalDataSource) MailDataSource(com.zimbra.soap.mail.type.MailDataSource) MailGalDataSource(com.zimbra.soap.mail.type.MailGalDataSource) MailImapDataSource(com.zimbra.soap.mail.type.MailImapDataSource) MailCaldavDataSource(com.zimbra.soap.mail.type.MailCaldavDataSource) MailPop3DataSource(com.zimbra.soap.mail.type.MailPop3DataSource) MailRssDataSource(com.zimbra.soap.mail.type.MailRssDataSource) DataSource(com.zimbra.soap.type.DataSource) Test(org.junit.Test)

Aggregations

TestDataSourceRequest (com.zimbra.soap.mail.message.TestDataSourceRequest)2 DataSource (com.zimbra.soap.type.DataSource)2 TestDataSourceResponse (com.zimbra.soap.mail.message.TestDataSourceResponse)1 MailCalDataSource (com.zimbra.soap.mail.type.MailCalDataSource)1 MailCaldavDataSource (com.zimbra.soap.mail.type.MailCaldavDataSource)1 MailDataSource (com.zimbra.soap.mail.type.MailDataSource)1 MailGalDataSource (com.zimbra.soap.mail.type.MailGalDataSource)1 MailImapDataSource (com.zimbra.soap.mail.type.MailImapDataSource)1 MailPop3DataSource (com.zimbra.soap.mail.type.MailPop3DataSource)1 MailRssDataSource (com.zimbra.soap.mail.type.MailRssDataSource)1 TestDataSource (com.zimbra.soap.mail.type.TestDataSource)1 CalDataSource (com.zimbra.soap.type.CalDataSource)1 ImapDataSource (com.zimbra.soap.type.ImapDataSource)1 Pop3DataSource (com.zimbra.soap.type.Pop3DataSource)1 RssDataSource (com.zimbra.soap.type.RssDataSource)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Test (org.junit.Test)1