Program: 89520
Project: 89520
Buggy source:
/** 
 * Test that the OnBatchReply method updates state and responds correctly. This is a rather complex test, but should not attempt to test processCheckSum(). It has to set up the following: outstandingChecksumFiles should contain an entry replyOfId->arcfilename msg should contain id, errmsg, resultfile, filesprocessed, filesfailed, but the channels are not used. ad should contain some checksum for the arcfilename but no replyinfo -- we can check the effect by seeing warnings and state.
 * @throws Exception if exception is thrown
 */
@Test public void DISABLED_testOnBatchReply() throws Exception {
  LogbackRecorder lr=LogbackRecorder.startRecorder();
  ArcRepository a=ArcRepository.getInstance();
  UpdateableAdminData ad=UpdateableAdminData.getUpdateableInstance();
  Field ocf=a.getClass().getDeclaredField("String_Node_Str");
  ocf.setAccessible(true);
  Map<String,String> outstanding=(Map<String,String>)ocf.get(a);
  Field adm=ad.getClass().getSuperclass().getDeclaredField("String_Node_Str");
  adm.setAccessible(true);
  Map<String,ArcRepositoryEntry> admindataentries=(Map<String,ArcRepositoryEntry>)adm.get(ad);
  String id1="String_Node_Str";
  String arcname1="String_Node_Str";
  outstanding.put(id1,arcname1);
  ad.addEntry(arcname1,null,"String_Node_Str");
  BatchReplyMessage bamsg0=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new StringRemoteFile(arcname1 + ChecksumJob.STRING_FILENAME_SEPARATOR + "String_Node_Str"));
  JMSConnectionMockupMQ.updateMsgID(bamsg0,id1);
  a.onBatchReply(bamsg0);
  lr.assertLogNotContains("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",ReplicaStoreState.UPLOAD_COMPLETED,ad.getState(arcname1,Channels.getTheBamon().getName()));
  outstanding.put(id1,arcname1);
  ad.addEntry(arcname1,null,"String_Node_Str");
  BatchReplyMessage bamsg2=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new NullRemoteFile());
  JMSConnectionMockupMQ.updateMsgID(bamsg2,id1);
  bamsg2.setNotOk("String_Node_Str");
  a.onBatchReply(bamsg2);
  lr.assertLogContains("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",ReplicaStoreState.UPLOAD_FAILED,ad.getState(arcname1,Channels.getTheBamon().getName()));
  admindataentries.remove(arcname1);
  outstanding.put(id1,arcname1);
  BatchReplyMessage bamsg3=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new NullRemoteFile());
  JMSConnectionMockupMQ.updateMsgID(bamsg3,id1);
  bamsg3.setNotOk("String_Node_Str");
  try {
    a.onBatchReply(bamsg3);
    fail("String_Node_Str" + arcname1);
  }
 catch (  UnknownID e) {
    StringAsserts.assertStringContains("String_Node_Str" + "String_Node_Str",arcname1,e.getMessage());
  }
  lr.assertLogContains("String_Node_Str","String_Node_Str");
  assertFalse("String_Node_Str",ad.hasEntry(arcname1));
  BatchReplyMessage bamsg1=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new NullRemoteFile());
  a.onBatchReply(bamsg1);
  lr.assertLogContains("String_Node_Str","String_Node_Str" + id1);
  assertFalse("String_Node_Str",ad.hasEntry(arcname1));
  lr.stopRecorder();
}

Fixed version (ground truth):
/** 
 * DISABLED because it fails on travis constantly! Test that the OnBatchReply method updates state and responds correctly. This is a rather complex test, but should not attempt to test processCheckSum(). It has to set up the following: outstandingChecksumFiles should contain an entry replyOfId->arcfilename msg should contain id, errmsg, resultfile, filesprocessed, filesfailed, but the channels are not used. ad should contain some checksum for the arcfilename but no replyinfo -- we can check the effect by seeing warnings and state.
 * @throws Exception if exception is thrown
 */
public void DISABLED_testOnBatchReply() throws Exception {
  LogbackRecorder lr=LogbackRecorder.startRecorder();
  ArcRepository a=ArcRepository.getInstance();
  UpdateableAdminData ad=UpdateableAdminData.getUpdateableInstance();
  Field ocf=a.getClass().getDeclaredField("String_Node_Str");
  ocf.setAccessible(true);
  Map<String,String> outstanding=(Map<String,String>)ocf.get(a);
  Field adm=ad.getClass().getSuperclass().getDeclaredField("String_Node_Str");
  adm.setAccessible(true);
  Map<String,ArcRepositoryEntry> admindataentries=(Map<String,ArcRepositoryEntry>)adm.get(ad);
  String id1="String_Node_Str";
  String arcname1="String_Node_Str";
  outstanding.put(id1,arcname1);
  ad.addEntry(arcname1,null,"String_Node_Str");
  BatchReplyMessage bamsg0=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new StringRemoteFile(arcname1 + ChecksumJob.STRING_FILENAME_SEPARATOR + "String_Node_Str"));
  JMSConnectionMockupMQ.updateMsgID(bamsg0,id1);
  a.onBatchReply(bamsg0);
  lr.assertLogNotContains("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",ReplicaStoreState.UPLOAD_COMPLETED,ad.getState(arcname1,Channels.getTheBamon().getName()));
  outstanding.put(id1,arcname1);
  ad.addEntry(arcname1,null,"String_Node_Str");
  BatchReplyMessage bamsg2=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new NullRemoteFile());
  JMSConnectionMockupMQ.updateMsgID(bamsg2,id1);
  bamsg2.setNotOk("String_Node_Str");
  a.onBatchReply(bamsg2);
  lr.assertLogContains("String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",ReplicaStoreState.UPLOAD_FAILED,ad.getState(arcname1,Channels.getTheBamon().getName()));
  admindataentries.remove(arcname1);
  outstanding.put(id1,arcname1);
  BatchReplyMessage bamsg3=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new NullRemoteFile());
  JMSConnectionMockupMQ.updateMsgID(bamsg3,id1);
  bamsg3.setNotOk("String_Node_Str");
  try {
    a.onBatchReply(bamsg3);
    fail("String_Node_Str" + arcname1);
  }
 catch (  UnknownID e) {
    StringAsserts.assertStringContains("String_Node_Str" + "String_Node_Str",arcname1,e.getMessage());
  }
  lr.assertLogContains("String_Node_Str","String_Node_Str");
  assertFalse("String_Node_Str",ad.hasEntry(arcname1));
  BatchReplyMessage bamsg1=new BatchReplyMessage(Channels.getTheRepos(),Channels.getTheBamon(),id1,0,new ArrayList<File>(0),new NullRemoteFile());
  a.onBatchReply(bamsg1);
  lr.assertLogContains("String_Node_Str","String_Node_Str" + id1);
  assertFalse("String_Node_Str",ad.hasEntry(arcname1));
  lr.stopRecorder();
}