}
@Test
public void testReadWriteApplicationHistory() throws Exception {
// Out of order
ApplicationId appId = ApplicationId.newInstance(0, 1);
try {
writeApplicationFinishData(appId);
Assert.fail();
} catch (IOException e) {
Assert.assertTrue(e.getMessage().contains(
"is stored before the start information"));
}
// Normal
int numApps = 5;
for (int i = 1; i <= numApps; ++i) {
appId = ApplicationId.newInstance(0, i);
writeApplicationStartData(appId);
writeApplicationFinishData(appId);
}
Assert.assertEquals(numApps, store.getAllApplications().size());
for (int i = 1; i <= numApps; ++i) {
appId = ApplicationId.newInstance(0, i);
ApplicationHistoryData data = store.getApplication(appId);
Assert.assertNotNull(data);
Assert.assertEquals(appId.toString(), data.getApplicationName());
Assert.assertEquals(appId.toString(), data.getDiagnosticsInfo());
}
// Write again
appId = ApplicationId.newInstance(0, 1);
try {
writeApplicationStartData(appId);