* Ensure correct static loggers creation/removal as well as file creation.
*
* @throws Exception If failed.
*/
public void testCreateDelete() throws Exception {
GridGgfsLogger log = GridGgfsLogger.logger(ENDPOINT, GGFS_NAME, LOG_DIR, 10);
GridGgfsLogger sameLog0 = GridGgfsLogger.logger(ENDPOINT, GGFS_NAME, LOG_DIR, 10);
// Loggers for the same endpoint must be the same object.
assert log == sameLog0;
GridGgfsLogger otherLog = GridGgfsLogger.logger("other" + ENDPOINT, GGFS_NAME, LOG_DIR, 10);
// Logger for another endpoint must be different.
assert log != otherLog;
otherLog.close();
log.logDelete(PATH, PRIMARY, false);
log.close();
File logFile = new File(LOG_FILE);
// When there are multiple loggers, closing one must not force flushing.
assert !logFile.exists();
GridGgfsLogger sameLog1 = GridGgfsLogger.logger(ENDPOINT, GGFS_NAME, LOG_DIR, 10);
assert sameLog0 == sameLog1;
sameLog0.close();
assert !logFile.exists();
sameLog1.close();
// When we cloe the last logger, it must flush data to disk.
assert logFile.exists();
logFile.delete();
GridGgfsLogger sameLog2 = GridGgfsLogger.logger(ENDPOINT, GGFS_NAME, LOG_DIR, 10);
// This time we expect new logger instance to be created.
assert sameLog0 != sameLog2;
sameLog2.close();
// As we do not add any records to the logger, we do not expect flushing.
assert !logFile.exists();
}