use of com.aws.iot.edgeconnectorforkvs.diskmanager.callback.TestWatchEventCallBack in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_Build_Recorder_Files_Success_Case.
@Test
public void testWatchService_Build_Recorder_Files_Success_Case(@TempDir Path tempDir) {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(tempDir).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
filePath = tempDir.resolve(FILE_NAME);
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then
diskManager.initDiskManager();
assertTrue(diskManagerUtil.getRecordedFilesMap().size() > 0);
}
use of com.aws.iot.edgeconnectorforkvs.diskmanager.callback.TestWatchEventCallBack in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_File_Monitor_Thread_Exists_Case.
@Test
public void testWatchService_File_Monitor_Thread_Exists_Case(@TempDir Path tempDir) throws InterruptedException, IOException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(Paths.get("NonExistentFile.txt")).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then and verify
diskManager.setupDiskManagerThread();
diskManager.setupDiskManagerThread();
Thread.sleep(3000);
filePath = tempDir.resolve(FILE_NAME);
Files.write(filePath, Collections.singletonList(MOCK_VALUE));
// then
try {
diskManager.setupDiskManagerThread();
Thread.sleep(3000);
} catch (EdgeConnectorForKVSException | InterruptedException e) {
assertEquals(e.getClass(), EdgeConnectorForKVSException.class);
}
}
use of com.aws.iot.edgeconnectorforkvs.diskmanager.callback.TestWatchEventCallBack in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_Path_Register_Failed_Case.
@Test
public void testWatchService_Path_Register_Failed_Case() {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(Paths.get("NonExistentFile.txt")).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then
try {
diskManager.setupDiskManagerThread();
} catch (EdgeConnectorForKVSException e) {
assertEquals(e.getClass(), EdgeConnectorForKVSException.class);
}
}
use of com.aws.iot.edgeconnectorforkvs.diskmanager.callback.TestWatchEventCallBack in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_File_Creation_Case.
@Test
public void testWatchService_File_Creation_Case(@TempDir Path tempDir) throws InterruptedException, IOException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(tempDir).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then
diskManager.setupDiskManagerThread();
Thread.sleep(3000);
filePath = tempDir.resolve(FILE_NAME);
Files.write(filePath, Collections.singletonList(MOCK_VALUE));
// verify
synchronized (events) {
int i = 0;
while (events.size() < 1 && i < testRepeatTimes) {
events.wait(3000);
i++;
}
assertEquals(1, events.size());
}
}
use of com.aws.iot.edgeconnectorforkvs.diskmanager.callback.TestWatchEventCallBack in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_Build_Recorder_Files_Exception_Case.
@Test
public void testWatchService_Build_Recorder_Files_Exception_Case() {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(Paths.get("NonExistentFile.txt")).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then and verify
assertThrows(EdgeConnectorForKVSException.class, () -> diskManager.initDiskManager());
}
Aggregations