am 064c1870
: Merge "DO NOT MERGE - Fix NPE in pop3 checkcapabilities" into gingerbread
* commit '064c1870195a5d53346fd591072cc487083be7b6': DO NOT MERGE - Fix NPE in pop3 checkcapabilities
This commit is contained in:
commit
4fed865309
@ -171,6 +171,10 @@ public class Pop3Store extends Store {
|
|||||||
@Override
|
@Override
|
||||||
public void checkSettings() throws MessagingException {
|
public void checkSettings() throws MessagingException {
|
||||||
Pop3Folder folder = new Pop3Folder("INBOX");
|
Pop3Folder folder = new Pop3Folder("INBOX");
|
||||||
|
// Close any open or half-open connections - checkSettings should always be "fresh"
|
||||||
|
if (mTransport.isOpen()) {
|
||||||
|
folder.close(false);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
folder.open(OpenMode.READ_WRITE, null);
|
folder.open(OpenMode.READ_WRITE, null);
|
||||||
folder.checkSettings();
|
folder.checkSettings();
|
||||||
|
@ -21,12 +21,12 @@ import com.android.email.mail.Address;
|
|||||||
import com.android.email.mail.FetchProfile;
|
import com.android.email.mail.FetchProfile;
|
||||||
import com.android.email.mail.Flag;
|
import com.android.email.mail.Flag;
|
||||||
import com.android.email.mail.Folder;
|
import com.android.email.mail.Folder;
|
||||||
import com.android.email.mail.Message;
|
|
||||||
import com.android.email.mail.MessagingException;
|
|
||||||
import com.android.email.mail.Transport;
|
|
||||||
import com.android.email.mail.Folder.FolderType;
|
import com.android.email.mail.Folder.FolderType;
|
||||||
import com.android.email.mail.Folder.OpenMode;
|
import com.android.email.mail.Folder.OpenMode;
|
||||||
|
import com.android.email.mail.Message;
|
||||||
import com.android.email.mail.Message.RecipientType;
|
import com.android.email.mail.Message.RecipientType;
|
||||||
|
import com.android.email.mail.MessagingException;
|
||||||
|
import com.android.email.mail.Transport;
|
||||||
import com.android.email.mail.internet.MimeMessage;
|
import com.android.email.mail.internet.MimeMessage;
|
||||||
import com.android.email.mail.transport.MockTransport;
|
import com.android.email.mail.transport.MockTransport;
|
||||||
|
|
||||||
@ -204,6 +204,37 @@ public class Pop3StoreUnitTests extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a strange case that causes open to proceed without mCapabilities
|
||||||
|
* open - fail with "-" error code
|
||||||
|
* then check capabilities
|
||||||
|
*/
|
||||||
|
public void testCheckSettingsCapabilities() throws MessagingException {
|
||||||
|
|
||||||
|
MockTransport mockTransport = openAndInjectMockTransport();
|
||||||
|
|
||||||
|
// First, preload an open that fails for some reason
|
||||||
|
mockTransport.expect(null, "-ERR from the Mock Transport.");
|
||||||
|
|
||||||
|
// And watch it fail
|
||||||
|
try {
|
||||||
|
Pop3Store.Pop3Folder folder = mStore.new Pop3Folder("INBOX");
|
||||||
|
folder.open(OpenMode.READ_WRITE, null);
|
||||||
|
fail("Should have thrown exception");
|
||||||
|
} catch (MessagingException me) {
|
||||||
|
// Expected - continue.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now try again (assuming a slightly different connection setup - successful)
|
||||||
|
// Note, checkSettings is going to try to close the connection again, so we expect
|
||||||
|
// one extra QUIT before we spin it up again
|
||||||
|
mockTransport.expect("QUIT", "");
|
||||||
|
mockTransport.expectClose();
|
||||||
|
setupOpenFolder(mockTransport, 0, "UIDL");
|
||||||
|
mockTransport.expect("QUIT", "");
|
||||||
|
mStore.checkSettings();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test small Store & Folder functions that manage folders & namespace
|
* Test small Store & Folder functions that manage folders & namespace
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user