Program: 42099
Project: 42099
Buggy source:
@SmallTest public void testAuthorityParsing() throws Exception {
  final Account account=new Account("String_Node_Str","String_Node_Str");
  final String authority1="String_Node_Str";
  final String authority2="String_Node_Str";
  final String authority3="String_Node_Str";
  final Bundle extras=new Bundle();
  PeriodicSync sync1=new PeriodicSync(account,authority1,extras,(long)(60 * 60 * 24));
  PeriodicSync sync2=new PeriodicSync(account,authority2,extras,(long)(60 * 60 * 24));
  PeriodicSync sync3=new PeriodicSync(account,authority3,extras,(long)(60 * 60 * 24));
  PeriodicSync sync1s=new PeriodicSync(account,authority1,extras,1000);
  PeriodicSync sync2s=new PeriodicSync(account,authority2,extras,1000);
  PeriodicSync sync3s=new PeriodicSync(account,authority3,extras,1000);
  MockContentResolver mockResolver=new MockContentResolver();
  final TestContext testContext=new TestContext(mockResolver,getContext());
  SyncStorageEngine engine=SyncStorageEngine.newTestInstance(testContext);
  byte[] accountsFileData=("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
  File syncDir=new File(new File(testContext.getFilesDir(),"String_Node_Str"),"String_Node_Str");
  syncDir.mkdirs();
  AtomicFile accountInfoFile=new AtomicFile(new File(syncDir,"String_Node_Str"));
  FileOutputStream fos=accountInfoFile.startWrite();
  fos.write(accountsFileData);
  accountInfoFile.finishWrite(fos);
  engine.clearAndReadState();
  List<PeriodicSync> syncs=engine.getPeriodicSyncs(account,authority1);
  assertEquals(1,syncs.size());
  assertEquals(sync1,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority2);
  assertEquals(1,syncs.size());
  assertEquals(sync2,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority3);
  assertEquals(1,syncs.size());
  assertEquals(sync3,syncs.get(0));
  accountsFileData=("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
  accountInfoFile=new AtomicFile(new File(syncDir,"String_Node_Str"));
  fos=accountInfoFile.startWrite();
  fos.write(accountsFileData);
  accountInfoFile.finishWrite(fos);
  engine.clearAndReadState();
  syncs=engine.getPeriodicSyncs(account,authority1);
  assertEquals(0,syncs.size());
  syncs=engine.getPeriodicSyncs(account,authority2);
  assertEquals(0,syncs.size());
  syncs=engine.getPeriodicSyncs(account,authority3);
  assertEquals(0,syncs.size());
  accountsFileData=("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
  accountInfoFile=new AtomicFile(new File(syncDir,"String_Node_Str"));
  fos=accountInfoFile.startWrite();
  fos.write(accountsFileData);
  accountInfoFile.finishWrite(fos);
  engine.clearAndReadState();
  syncs=engine.getPeriodicSyncs(account,authority1);
  assertEquals(1,syncs.size());
  assertEquals(sync1s,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority2);
  assertEquals(1,syncs.size());
  assertEquals(sync2s,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority3);
  assertEquals(1,syncs.size());
  assertEquals(sync3s,syncs.get(0));
}

Fixed version (ground truth):
@SmallTest public void testAuthorityParsing() throws Exception {
  final Account account=new Account("String_Node_Str","String_Node_Str");
  final String authority1="String_Node_Str";
  final String authority2="String_Node_Str";
  final String authority3="String_Node_Str";
  final Bundle extras=new Bundle();
  PeriodicSync sync1=new PeriodicSync(account,authority1,extras,(long)(60 * 60 * 24));
  PeriodicSync sync2=new PeriodicSync(account,authority2,extras,(long)(60 * 60 * 24));
  PeriodicSync sync3=new PeriodicSync(account,authority3,extras,(long)(60 * 60 * 24));
  PeriodicSync sync1s=new PeriodicSync(account,authority1,extras,1000);
  PeriodicSync sync2s=new PeriodicSync(account,authority2,extras,1000);
  PeriodicSync sync3s=new PeriodicSync(account,authority3,extras,1000);
  MockContentResolver mockResolver=new MockContentResolver();
  final TestContext testContext=new TestContext(mockResolver,getContext());
  byte[] accountsFileData=("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
  File syncDir=new File(new File(testContext.getFilesDir(),"String_Node_Str"),"String_Node_Str");
  syncDir.mkdirs();
  AtomicFile accountInfoFile=new AtomicFile(new File(syncDir,"String_Node_Str"));
  FileOutputStream fos=accountInfoFile.startWrite();
  fos.write(accountsFileData);
  accountInfoFile.finishWrite(fos);
  SyncStorageEngine engine=SyncStorageEngine.newTestInstance(testContext);
  List<PeriodicSync> syncs=engine.getPeriodicSyncs(account,authority1);
  assertEquals(1,syncs.size());
  assertEquals(sync1,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority2);
  assertEquals(1,syncs.size());
  assertEquals(sync2,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority3);
  assertEquals(1,syncs.size());
  assertEquals(sync3,syncs.get(0));
  accountsFileData=("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
  accountInfoFile=new AtomicFile(new File(syncDir,"String_Node_Str"));
  fos=accountInfoFile.startWrite();
  fos.write(accountsFileData);
  accountInfoFile.finishWrite(fos);
  engine.clearAndReadState();
  syncs=engine.getPeriodicSyncs(account,authority1);
  assertEquals(0,syncs.size());
  syncs=engine.getPeriodicSyncs(account,authority2);
  assertEquals(0,syncs.size());
  syncs=engine.getPeriodicSyncs(account,authority3);
  assertEquals(0,syncs.size());
  accountsFileData=("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").getBytes();
  accountInfoFile=new AtomicFile(new File(syncDir,"String_Node_Str"));
  fos=accountInfoFile.startWrite();
  fos.write(accountsFileData);
  accountInfoFile.finishWrite(fos);
  engine.clearAndReadState();
  syncs=engine.getPeriodicSyncs(account,authority1);
  assertEquals(1,syncs.size());
  assertEquals(sync1s,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority2);
  assertEquals(1,syncs.size());
  assertEquals(sync2s,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account,authority3);
  assertEquals(1,syncs.size());
  assertEquals(sync3s,syncs.get(0));
}