use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestFolders method testCreateManyFolders.
@Ignore
@Test
public void testCreateManyFolders() throws Exception {
// normally skip this test since it takes a long time to complete. just keep it around for quick perf checks
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String parentPath = "/parent";
ZFolder parent = TestUtil.createFolder(mbox, parentPath);
int max = 10000;
int pad = ((int) Math.log10(max)) + 1;
long totalTime = 0;
double avgTime;
long maxTime = 0;
for (int i = 0; i < max; i++) {
long start = System.currentTimeMillis();
TestUtil.createFolder(mbox, parent.getId(), "child" + Strings.padStart(i + "", pad, '0'));
long end = System.currentTimeMillis();
long elapsed = (end - start);
totalTime += elapsed;
if (elapsed > maxTime) {
maxTime = elapsed;
ZimbraLog.mailbox.info("FOLDER TIME new max time %dms at index %d", maxTime, i);
}
if (i > 0 && (i % 100 == 0 || i == max - 1)) {
avgTime = (totalTime * 1.0) / (i * 1.0);
ZimbraLog.mailbox.info("FOLDER TIME average after %d = %dms", i, Math.round(avgTime));
}
}
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestCalDav method testCalendarQueryOnInbox.
@Test
public void testCalendarQueryOnInbox() throws Exception {
String url = getSchedulingInboxUrl(dav1, dav1);
Document doc = calendarQuery(url, dav1);
org.w3c.dom.Element rootElem = doc.getDocumentElement();
assertFalse("response when there are no items should have no child elements", rootElem.hasChildNodes());
// Send an invite from user1 and check tags.
ZMailbox organizer = TestUtil.getZMailbox(USER_NAME);
String subject = TEST_NAME + " testInvite request 1";
Date startDate = new Date(System.currentTimeMillis() + Constants.MILLIS_PER_DAY);
Date endDate = new Date(startDate.getTime() + Constants.MILLIS_PER_HOUR);
TestUtil.createAppointment(organizer, subject, dav1.getName(), startDate, endDate);
waitForNewSchedulingRequestByUID(dav1, "");
doc = calendarQuery(url, dav1);
rootElem = doc.getDocumentElement();
assertTrue("response should have child elements", rootElem.hasChildNodes());
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestCalDav method testAppleCaldavProxyFunctions.
/**
* http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/doc/Extensions/caldav-proxy.txt
* This is an Apple standard implemented by Apple Mac OSX at least up to Yosemite and offers a fairly simple
* sharing model for calendars. The model is simpler than Zimbra's native model and there are mismatches,
* for instance Zimbra requires the proposed delegate to accept shares.
*/
@Test
public void testAppleCaldavProxyFunctions() throws ServiceException, IOException {
Account sharer = dav3;
Account sharee1 = dav1;
Account sharee2 = dav2;
ZMailbox mboxSharer = TestUtil.getZMailbox(sharer.getName());
ZMailbox mboxSharee1 = TestUtil.getZMailbox(sharee1.getName());
ZMailbox mboxSharee2 = TestUtil.getZMailbox(sharee2.getName());
setZimbraPrefAppleIcalDelegationEnabled(mboxSharer, true);
setZimbraPrefAppleIcalDelegationEnabled(mboxSharee1, true);
setZimbraPrefAppleIcalDelegationEnabled(mboxSharee2, true);
// Test PROPPATCH to "calendar-proxy-read" URL
setGroupMemberSet(TestCalDav.getCalendarProxyReadUrl(sharer), sharer, sharee2);
// Test PROPPATCH to "calendar-proxy-write" URL
setGroupMemberSet(TestCalDav.getCalendarProxyWriteUrl(sharer), sharer, sharee1);
// verify that adding new members to groups triggered notification messages
List<ZMessage> msgs = TestUtil.waitForMessages(mboxSharee1, "in:inbox subject:\"Share Created: Calendar shared by \"", 1, 10000);
assertNotNull(String.format("Notification msgs for %s", sharee1.getName()), msgs);
assertEquals(String.format("num msgs for %s", sharee1.getName()), 1, msgs.size());
msgs = TestUtil.waitForMessages(mboxSharee2, "in:inbox subject:\"Share Created: Calendar shared by \"", 1, 10000);
assertNotNull(String.format("Notification msgs for %s", sharee2.getName()), msgs);
assertEquals(String.format("num msgs for %s", sharee2.getName()), 1, msgs.size());
// Simulate acceptance of the shares (would normally need to be done in ZWC
createCalendarMountPoint(mboxSharee1, sharer);
createCalendarMountPoint(mboxSharee2, sharer);
Document doc = delegateForExpandProperty(sharee1);
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(TestCalDav.NamespaceContextForXPath.forCalDAV());
XPathExpression xPathExpr;
try {
String xpathS = "/D:multistatus/D:response/D:href/text()";
xPathExpr = xpath.compile(xpathS);
NodeList result = (NodeList) xPathExpr.evaluate(doc, XPathConstants.NODESET);
assertEquals(String.format("num XPath nodes for %s for %s", xpathS, sharee1.getName()), 1, result.getLength());
String text = (String) xPathExpr.evaluate(doc, XPathConstants.STRING);
assertEquals("HREF for account owner", UrlNamespace.getPrincipalUrl(sharee1).replaceAll("@", "%40"), text);
xpathS = "/D:multistatus/D:response/D:propstat/D:prop/CS:calendar-proxy-write-for/D:response/D:href/text()";
xPathExpr = xpath.compile(xpathS);
result = (NodeList) xPathExpr.evaluate(doc, XPathConstants.NODESET);
assertEquals(String.format("num XPath nodes for %s for %s", xpathS, sharee1.getName()), 1, result.getLength());
text = (String) xPathExpr.evaluate(doc, XPathConstants.STRING);
assertEquals("HREF for sharer", UrlNamespace.getPrincipalUrl(sharer).replaceAll("@", "%40"), text);
} catch (XPathExpressionException e1) {
ZimbraLog.test.debug("xpath problem", e1);
}
// Check that proxy write has sharee1 in it
doc = groupMemberSetExpandProperty(sharer, sharee1, true);
// Check that proxy read has sharee2 in it
doc = groupMemberSetExpandProperty(sharer, sharee2, false);
String davBaseName = "notAllowed@There";
String url = String.format("%s%s", getFolderUrl(sharee1, "Shared Calendar"), davBaseName);
HttpMethodExecutor exe;
if (DebugConfig.enableDAVclientCanChooseResourceBaseName) {
exe = doIcalPut(url, sharee1, simpleEvent(sharer), HttpStatus.SC_CREATED);
// rest of test deals with how redirecting to new name works - not needed here
return;
} else {
exe = doIcalPut(url, sharee1, simpleEvent(sharer), HttpStatus.SC_MOVED_TEMPORARILY);
}
String location = exe.getNonNullHeaderValue("Location", "When creating in shared calendar");
url = String.format("%s%s", getFolderUrl(sharee1, "Shared Calendar"), location.substring(location.lastIndexOf('/') + 1));
doIcalPut(url, sharee1, simpleEvent(sharer), HttpStatus.SC_CREATED);
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestDocument method testContentType.
/**
* Tests the content-type based on file extension.
*/
@Test
public void testContentType() throws Exception {
TestUtil.createAccount(USER_NAME);
// Create two documents.
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String folderId = Integer.toString(Mailbox.ID_FOLDER_BRIEFCASE);
ZDocument doc1 = TestUtil.createDocument(mbox, folderId, NAME_PREFIX + "-docOne.doc", "application/octet-stream", "doc1".getBytes());
ZDocument doc2 = TestUtil.createDocument(mbox, folderId, NAME_PREFIX + "-docTwo.xls", "application/ms-tnef", "doc2".getBytes());
// Confirm that the content-type changed based on file extension
Assert.assertEquals("application/msword", doc1.getContentType());
Assert.assertEquals("application/vnd.ms-excel", doc2.getContentType());
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestConversion method downloadAttachmentsFromTNEFmsg.
/**
* Tests downloading attachments from a TNEF message (bug 44263).
*/
@Test
public void downloadAttachmentsFromTNEFmsg() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String msgName = "/unittest/tnef.msg";
File tnefMsg = new File(LC.zimbra_home.value() + msgName);
Assert.assertTrue(String.format("To run this test copy data%1$s to /opt/zimbra%1$s", msgName), tnefMsg.exists() && tnefMsg.canRead());
// Add the TNEF message
String msgContent = new String(ByteUtil.getContent(tnefMsg));
TestUtil.addMessageLmtp(new String[] { USER_NAME }, USER_NAME, msgContent);
// Test downloading attachments.
ZMessage msg = TestUtil.getMessage(mbox, "in:inbox subject:\"" + NAME_PREFIX + " Rich text (TNEF) test\"");
byte[] data = TestUtil.getContent(mbox, msg.getId(), "upload.gif");
Assert.assertEquals(73, data.length);
data = TestUtil.getContent(mbox, msg.getId(), "upload2.gif");
Assert.assertEquals(851, data.length);
ZMimePart part = TestUtil.getPart(msg, "upload.gif");
checkPartSize(73, part.getSize());
part = TestUtil.getPart(msg, "upload2.gif");
checkPartSize(851, part.getSize());
}
Aggregations