Methods Summary |
---|
private void | doTestImapList()
ImapResponseParser parser = new ImapResponseParser(null);
ImapResponseParser.ImapList list = parser.new ImapList();
String key = "key";
String date = "01-Jan-2009 01:00:00 -0800";
list.add(key);
list.add(date);
Date result = list.getKeyedDate(key);
// "01-Jan-2009 09:00:00 +0000" => 1230800400000L
assertEquals(1230800400000L, result.getTime());
|
private com.android.email.mail.transport.MockTransport | openAndInjectMockTransport()TODO: Test the scenario where the transport is "open" but not really (e.g. server closed).
/**
Set up a basic MockTransport. open it, and inject it into mStore
// Create mock transport and inject it into the ImapStore that's already set up
MockTransport mockTransport = new MockTransport();
mockTransport.setSecurity(Transport.CONNECTION_SECURITY_NONE);
mStore.setTransport(mockTransport);
return mockTransport;
|
protected void | setUp()Setup code. We generate a lightweight ImapStore and ImapStore.ImapFolder.
super.setUp();
// These are needed so we can get at the inner classes
mStore = new ImapStore("imap://user:password@server:999");
mFolder = (ImapStore.ImapFolder) mStore.getFolder("INBOX");
// This is needed for parsing mime messages
BinaryTempFileBody.setTempDirectory(this.getContext().getCacheDir());
|
private void | setupOpenFolder(com.android.email.mail.transport.MockTransport mockTransport)Helper which stuffs the mock with enough strings to satisfy a call to ImapFolder.open()
mockTransport.expect(null, "* OK Imap 2000 Ready To Assist You");
mockTransport.expect("1 LOGIN user \"password\"",
"1 OK user authenticated (Success)");
mockTransport.expect("2 SELECT \"INBOX\"", new String[] {
"* FLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen)",
"* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen \\*)]",
"* 0 EXISTS",
"* 0 RECENT",
"* OK [UNSEEN 0]",
"* OK [UIDNEXT 1]",
"2 OK [READ-WRITE] INBOX selected. (Success)"});
|
public void | testImapListWithUsLocale()Confirms that ImapList object correctly returns an appropriate Date object
without throwning MessagingException when getKeyedDate() is called.
Here, we try a same test twice using two locales, Locale.US and the other.
ImapList uses Locale class internally, and as a result, there's a
possibility in which it may throw a MessageException when Locale is
not Locale.US. Locale.JAPAN is a typical locale which emits different
date formats, which had caused a bug before.
Locale savedLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
doTestImapList();
Locale.setDefault(Locale.JAPAN);
doTestImapList();
Locale.setDefault(savedLocale);
|
public void | testSimpleLogin()Confirms simple non-SSL non-TLS login
MockTransport mockTransport = openAndInjectMockTransport();
// try to open it
setupOpenFolder(mockTransport);
mFolder.open(OpenMode.READ_WRITE);
// TODO: inject specific facts in the initial folder SELECT and check them here
|