/** M: Test the sync function */
  public void testSync() throws IOException {
    ArrayList<Long> ids = setupAccountMailboxAndMessages(4);
    setupSyncParserAndAdapter(mAccount, mMailbox);
    mSyncAdapter.mService = EasSyncService.setupServiceForAccount(mProviderContext, mAccount);
    mSyncAdapter.mService.mMailbox = mMailbox;
    mSyncAdapter.mService.mContentResolver = mResolver;
    MessageMoveRequest req1 = new MessageMoveRequest(ids.get(0), mMailbox.mId);
    FetchMailRequest req2 = new FetchMailRequest(ids.get(1));
    MeetingResponseRequest req3 = new MeetingResponseRequest(ids.get(2), 2);
    Attachment att = new Attachment();
    att.mId = 1;
    att.mLocation = "location1";
    att.mMessageKey = ids.get(3);
    att.mAccountKey = mAccount.mId;
    PartRequest req4 = new PartRequest(att, "dest1", "content1");

    ContentValues cv = new ContentValues();
    cv.put(Message.MAILBOX_KEY, 2);
    mResolver.update(
        ContentUris.withAppendedId(Message.SYNCED_CONTENT_URI, ids.get(0)), cv, null, null);

    Message msg = Message.restoreMessageWithId(mProviderContext, ids.get(2));
    Exchange.sBadSyncKeyMailboxId = mMailbox.mId;
    mSyncAdapter.mService.addRequest(req4);
    mSyncAdapter.mService.sync(mSyncAdapter);
    mSyncAdapter.mService.clearRequests();
    mSyncAdapter.mService.addRequest(req1);
    mSyncAdapter.mService.addRequest(req2);
    mSyncAdapter.mService.addRequest(req3);
    mSyncAdapter.mService.mProtocolVersionDouble = 12.0;
    mSyncAdapter.mService.sync(mSyncAdapter);
    mSyncAdapter.mService.clearRequests();
    mSyncAdapter.mService.addRequest(req4);
    mSyncAdapter.mService.mProtocolVersionDouble = 2.5;
    mSyncAdapter.mService.sync(mSyncAdapter);
    assertEquals(1, mSyncAdapter.mService.getSendStatus());
    assertEquals(Eas.EAS_SYNC_RECOVER, mSyncAdapter.mService.getSnycStatus());
  }
 /** NOTE See the comment on the super method. It's called on a worker thread. */
 @Override
 protected Message openMessageSync(Activity activity) {
   return Message.restoreMessageWithId(activity, getMessageId());
 }