public void addAppOsTest_startRecording_writeOStream()

in src/integrationtests/java/com/aws/iot/integrationtests/edgeconnectorforkvs/videorecorder/VideoRecorderIntegrationTest.java [176:218]


    public void addAppOsTest_startRecording_writeOStream() {
        VideoRecorderBuilder builder = new VideoRecorderBuilder((rec, st, desc) -> {
        });

        // register app callback
        final String filePath = FILE_FOLDER + "/"
                + RandomStringUtils.randomAlphanumeric(RECORDING_FILE_PREFIX_LEN) + ".mkv";

        try {
            testOutputStream = new FileOutputStream(filePath);
        } catch (FileNotFoundException e) {
            Assertions.fail();
        }

        Assertions.assertTrue(() -> builder.registerCamera(REC_TYPE, SRC_URL));
        Assertions.assertThrows(NullPointerException.class,
                () -> builder.registerAppDataOutputStream(ContainerType.MATROSKA, null));
        Assertions.assertTrue(
                builder.registerAppDataOutputStream(ContainerType.MATROSKA, testOutputStream));
        Assertions.assertFalse(
                builder.registerAppDataOutputStream(ContainerType.MATROSKA, testOutputStream));

        VideoRecorder recorder = builder.construct();

        // Start recording
        Thread recordThread = new Thread(new RunnableRecorder(recorder));
        recordThread.start();
        recorder.toggleAppDataOutputStream(true);

        try {
            TimeUnit.SECONDS.sleep(RECORDING_TIME_IN_SECONDS);
        } catch (InterruptedException e) {
            Assertions.fail();
        }
        recorder.toggleAppDataOutputStream(false);
        recorder.stopRecording();

        // Check stored files
        File f = new File(filePath);
        System.out.println("addAppOsTest_startRecording_writeOStream: " + f.length());
        Assertions.assertTrue(f.length() > 0);
        f.delete();
    }