SingleThreadColocationLoggerFactory implements ColocationLoggerFactory { @Override public ColocationLogger startColocationLogger(PartitionedRegion region) { return constructor.create(region, logIntervalMillis / 2, logIntervalMillis).start(); } SingleThreadColocationLoggerFactory(); @VisibleForTesting  SingleThreadColocationLoggerFactory(SingleThreadColocationLoggerConstructor constructor); private  SingleThreadColocationLoggerFactory(long logIntervalMillis,
      SingleThreadColocationLoggerConstructor constructor); @Override ColocationLogger startColocationLogger(PartitionedRegion region);  }
@Test public void startColocationLoggerStartsNewColocationLogger() { ColocationLoggerFactory factory = new SingleThreadColocationLoggerFactory(constructor); factory.startColocationLogger(region); verify(restartableColocationLogger).start(); }
@Test public void startColocationLoggerUsesSpecifiedRegion() { ColocationLoggerFactory factory = new SingleThreadColocationLoggerFactory(constructor); factory.startColocationLogger(region); verify(constructor).create(same(region), anyLong(), anyLong()); }
@Test public void startColocationLoggerUsesHalfDefaultLogIntervalAsDelayMillis() { ColocationLoggerFactory factory = new SingleThreadColocationLoggerFactory(constructor); factory.startColocationLogger(region); long expectedDelayMillis = DEFAULT_LOG_INTERVAL / 2; verify(constructor).create(any(), eq(expectedDelayMillis), anyLong()); }
@Test public void startColocationLoggerUsesDefaultLogIntervalAsIntervalMillis() { ColocationLoggerFactory factory = new SingleThreadColocationLoggerFactory(constructor); factory.startColocationLogger(region); verify(constructor).create(any(), anyLong(), eq(DEFAULT_LOG_INTERVAL)); }
@Test public void startColocationLoggerOverridesDefaultIntervalMillisIfSystemPropertyIsSet() { long logIntervalValue = 40_001; System.setProperty(LOG_INTERVAL_PROPERTY, String.valueOf(logIntervalValue)); ColocationLoggerFactory factory = new SingleThreadColocationLoggerFactory(constructor); factory.startColocationLogger(region); verify(constructor).create(any(), anyLong(), eq(logIntervalValue)); }
@Test public void startColocationLoggerOverridesDefaultDelayMillisIfSystemPropertyIsSet() { long logIntervalValue = 50_001; System.setProperty(LOG_INTERVAL_PROPERTY, String.valueOf(logIntervalValue)); ColocationLoggerFactory factory = new SingleThreadColocationLoggerFactory(constructor); factory.startColocationLogger(region); verify(constructor).create(any(), eq(logIntervalValue / 2), anyLong()); }