use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method isConnected_afterOpen_shouldReturnTrue.
@Test
public void isConnected_afterOpen_shouldReturnTrue() throws Exception {
MockImapServer server = new MockImapServer();
ImapConnection imapConnection = simpleOpen(server);
boolean result = imapConnection.isConnected();
assertTrue(result);
server.verifyConnectionStillOpen();
server.shutdown();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method isIdleCapable_withIdleCapability.
@Test
public void isIdleCapable_withIdleCapability() throws Exception {
MockImapServer server = new MockImapServer();
ImapConnection imapConnection = simpleOpenWithCapabilities(server, "IDLE");
boolean result = imapConnection.isIdleCapable();
assertTrue(result);
server.shutdown();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_withCapabilitiesInInitialResponse_shouldNotIssueCapabilitiesCommand.
@Test
public void open_withCapabilitiesInInitialResponse_shouldNotIssueCapabilitiesCommand() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
server.output("* OK [CAPABILITY IMAP4 IMAP4REV1 AUTH=PLAIN]");
server.expect("1 AUTHENTICATE PLAIN");
server.output("+");
server.expect(ByteString.encodeUtf8("\000" + USERNAME + "\000" + PASSWORD).base64());
server.output("1 OK Success");
server.expect("2 LIST \"\" \"\"");
server.output("* LIST () \"/\" foo/bar");
server.output("2 OK");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_authPlainWithLoginDisabled_shouldThrow.
@Test
public void open_authPlainWithLoginDisabled_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server, "LOGINDISABLED");
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
try {
imapConnection.open();
fail("Expected exception");
} catch (MessagingException e) {
assertEquals("Server doesn't support unencrypted passwords using AUTH=PLAIN and LOGIN is disabled.", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
use of com.fsck.k9.mail.store.imap.mockserver.MockImapServer in project k-9 by k9mail.
the class ImapConnectionTest method open_afterCloseWasCalled_shouldThrow.
@Test
public void open_afterCloseWasCalled_shouldThrow() throws Exception {
settings.setAuthType(AuthType.PLAIN);
MockImapServer server = new MockImapServer();
preAuthenticationDialog(server);
server.expect("2 LOGIN \"" + USERNAME + "\" \"" + PASSWORD + "\"");
server.output("2 OK LOGIN completed");
simplePostAuthenticationDialog(server);
ImapConnection imapConnection = startServerAndCreateImapConnection(server);
imapConnection.open();
imapConnection.close();
try {
imapConnection.open();
fail("Expected exception");
} catch (IllegalStateException e) {
assertEquals("open() called after close(). Check wrapped exception to see where close() was called.", e.getMessage());
}
}
Aggregations