1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

Fix test cases

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1413 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-09-02 20:21:41 +00:00
parent dc9659fe3d
commit e96dd865ae
4 changed files with 22 additions and 11 deletions

View File

@ -164,8 +164,7 @@ public class TestCaldav extends AbstractDavMailTestCase {
session.lt("dtend", session.formatSearchDate(end))
);
List<ExchangeSession.Event> events = session.searchEvents("/users/" + session.getEmail() + "/calendar/",
session.or(session.isNull("instancetype"),
session.isEqualTo("instancetype", 1),
session.or(session.isEqualTo("instancetype", 1),
session.and(session.isEqualTo("instancetype", 0), dateCondition))
);

View File

@ -64,10 +64,13 @@ public class TestImap extends AbstractDavMailTestCase {
@Override
public void setUp() throws IOException {
boolean needStart = !loaded;
super.setUp();
if (clientSocket == null) {
if (needStart) {
// start gateway
DavGateway.start();
}
if (clientSocket == null) {
clientSocket = new Socket("localhost", Settings.getIntProperty("davmail.imapPort"));
socketWriter = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
socketReader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
@ -294,6 +297,7 @@ public class TestImap extends AbstractDavMailTestCase {
public void testLogout() throws IOException {
writeLine(". LOGOUT");
assertEquals("* BYE Closing connection", socketReader.readLine());
clientSocket = null;
}
public void testBrokenPipe() throws IOException, InterruptedException {

View File

@ -41,10 +41,13 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
@Override
public void setUp() throws IOException {
boolean needStart = !loaded;
super.setUp();
if (ldapContext == null) {
if (needStart) {
// start gateway
DavGateway.start();
}
if (ldapContext == null) {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.security.authentication", "simple");
env.put("java.naming.security.principal", Settings.getProperty("davmail.username"));
@ -95,14 +98,15 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
Attributes attributes = searchResult.getAttributes();
Attribute attribute = attributes.get("uid");
assertEquals(session.getAlias(), attribute.get());
assertNotNull(attributes.get("givenName"));
// given name not available on Exchange 2007 over Dav (no gallookup)
//assertNotNull(attributes.get("givenName"));
}
public void testOSXSearch() throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
searchControls.setReturningAttributes(new String[]{"uid", "jpegphoto", "postalcode", "mail", "sn", "apple-emailcontacts", "c", "street", "givenname", "l", "apple-user-picture", "telephonenumber", "cn", "st", "apple-imhandle"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("cn=users, o=od", "(&(objectclass=inetOrgPerson)(|(givenname=Charles*)(|(uid=Charles*)(cn=Charles*))(sn=Charles*))(objectclass=shadowAccount)(objectclass=extensibleObject)(objectclass=posixAccount)(objectclass=apple-user))", searchControls);
NamingEnumeration<SearchResult> searchResults = ldapContext.search("cn=users, o=od", "(&(objectclass=inetOrgPerson)(|(givenname=Charles*)(|(uid=Ch*)(cn=Ch*))(sn=Ch*))(objectclass=shadowAccount)(objectclass=extensibleObject)(objectclass=posixAccount)(objectclass=apple-user))", searchControls);
assertTrue(searchResults.hasMore());
}

View File

@ -42,7 +42,6 @@ public class TestSmtp extends AbstractDavMailTestCase {
static Socket clientSocket;
static BufferedOutputStream socketOutputStream;
static BufferedInputStream socketInputStream;
static final byte[] CRLF = {13, 10};
enum State {
CHAR, CR, CRLF
@ -55,7 +54,8 @@ public class TestSmtp extends AbstractDavMailTestCase {
protected void writeLine(String line) throws IOException {
write(line);
socketOutputStream.write(CRLF);
socketOutputStream.write(13);
socketOutputStream.write(10);
socketOutputStream.flush();
}
@ -140,9 +140,12 @@ public class TestSmtp extends AbstractDavMailTestCase {
Thread.sleep(1000);
}
assertEquals(1, messages.size());
ExchangeSession.Message message = messages.get(0);
message.getMimeMessage().writeTo(System.out);
assertEquals(mimeMessage.getDataHandler().getContent(), (String) message.getMimeMessage().getDataHandler().getContent());
ExchangeSession.Message sentMessage = messages.get(0);
sentMessage.getMimeMessage().writeTo(System.out);
// message is converted to html over Dav
if (Settings.getBooleanProperty("davmail.enableEws")) {
assertEquals(mimeMessage.getDataHandler().getContent(), sentMessage.getMimeMessage().getDataHandler().getContent());
}
}
public void testSendSimpleMessage() throws IOException, MessagingException, InterruptedException {
@ -193,6 +196,7 @@ public class TestSmtp extends AbstractDavMailTestCase {
}
public void testSendMessageTwice() throws IOException, MessagingException, InterruptedException {
Settings.setProperty("davmail.smtpCheckDuplicates", "true");
String body = "First line\r\n.\r\nSecond line";
MimeMessage mimeMessage = new MimeMessage((Session) null);
mimeMessage.addHeader("to", Settings.getProperty("davmail.to"));