### Question:
RollingLocationLogAppender extends FileAppender<ILoggingEvent> implements Flushable, Syncable { private void rollover(final LocationIdentifier identifier, ILoggingEvent event) throws RolloverFailure, IOException { closeInvalidStream(); if (!locationManager.getActiveLocations().containsKey(identifier)) { return; } final LocationOutputStream locationOutputStream = locationManager.getActiveLocations().get(identifier); if (triggeringPolicy instanceof LocationTriggeringPolicy) { if (locationTriggeringPolicy == null) { locationTriggeringPolicy = ((LocationTriggeringPolicy) triggeringPolicy); } locationTriggeringPolicy.setLocation(locationOutputStream.getLocation()); locationTriggeringPolicy.setActiveLocationSize(locationOutputStream.getNumOfBytes()); if (locationTriggeringPolicy.isTriggeringEvent(event)) { if (rollingPolicy instanceof LocationRollingPolicy) { if (locationRollingPolicy == null) { locationRollingPolicy = ((LocationRollingPolicy) rollingPolicy); } locationRollingPolicy.setLocation(locationOutputStream.getLocation(), new Closeable() { @Override public void close() throws IOException { locationManager.getActiveLocations().remove(identifier); try { locationOutputStream.close(); } catch (IOException e) { locationManager.setInvalidOutputStream(locationOutputStream); LOG.trace("Exception while closing the output stream for {}, will retry to close it later", identifier, e); throw e; } } }); locationRollingPolicy.rollover(); } } } } RollingLocationLogAppender(); @Override void start(); @Override void doAppend(ILoggingEvent eventObject); @Override void flush(); @Override void sync(); @Override void stop(); @Override void setOutputStream(OutputStream outputStream); void setRollingPolicy(RollingPolicy policy); void setTriggeringPolicy(TriggeringPolicy<ILoggingEvent> policy); String getBasePath(); void setBasePath(String basePath); String getFilePermissions(); void setFilePermissions(String filePermissions); String getFilePath(); void setFilePath(String filePath); String getDirPermissions(); void setDirPermissions(String dirPermissions); void setFileMaxInactiveTimeMs(long fileMaxInactiveTimeMs); long getFileMaxInactiveTimeMs();  }### Answer:
@Test public void testRollOver() throws Exception { AppenderContext appenderContext = new LocalAppenderContext(injector.getInstance(TransactionRunner.class), injector.getInstance(LocationFactory.class), new NoOpMetricsCollectionService()); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(appenderContext); appenderContext.reset(); configurator.doConfigure(getClass().getResourceAsStream("/rolling-appender-logback-test.xml")); StatusPrinter.printInCaseOfErrorsOrWarnings(appenderContext); RollingLocationLogAppender rollingAppender = (RollingLocationLogAppender) appenderContext.getLogger(RollingLocationLogAppenderTest.class) .getAppender("rollingAppender"); addTagsToMdc("testNs", "testApp"); Logger logger = appenderContext.getLogger(RollingLocationLogAppenderTest.class); ingestLogs(logger, 20000); Map<LocationIdentifier, LocationOutputStream> activeFiles = rollingAppender.getLocationManager() .getActiveLocations(); Assert.assertEquals(1, activeFiles.size()); LocationOutputStream locationOutputStream = activeFiles.get(new LocationIdentifier("testNs", "testApp")); Location parentDir = Locations.getParent(locationOutputStream.getLocation()); Assert.assertEquals(10, parentDir.list().size()); addTagsToMdc("testNs", "testApp1"); ingestLogs(logger, 20000); activeFiles = rollingAppender.getLocationManager().getActiveLocations(); Assert.assertEquals(2, activeFiles.size()); locationOutputStream = activeFiles.get(new LocationIdentifier("testNs", "testApp1")); parentDir = Locations.getParent(locationOutputStream.getLocation()); Assert.assertEquals(10, parentDir.list().size()); addTagsToMdc("testNs1", "testApp1"); ingestLogs(logger, 20000); activeFiles = rollingAppender.getLocationManager().getActiveLocations(); Assert.assertEquals(3, activeFiles.size()); locationOutputStream = activeFiles.get(new LocationIdentifier("testNs1", "testApp1")); parentDir = Locations.getParent(locationOutputStream.getLocation()); Assert.assertEquals(10, parentDir.list().size()); }