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