From 85c32676111d40c4250c83456d4418345fc97007 Mon Sep 17 00:00:00 2001 From: mekya Date: Tue, 31 Dec 2024 09:37:02 +0300 Subject: [PATCH] Fix setter/getter name and improve test stability --- src/main/java/io/antmedia/AppSettings.java | 22 ++++++++++++------- .../io/antmedia/integration/MuxingTest.java | 4 ++-- .../io/antmedia/test/AppSettingsUnitTest.java | 2 +- .../java/io/antmedia/test/MuxerUnitTest.java | 2 +- .../antmedia/test/StreamFetcherUnitTest.java | 4 +++- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/antmedia/AppSettings.java b/src/main/java/io/antmedia/AppSettings.java index 132363bbf..f95ceabd4 100644 --- a/src/main/java/io/antmedia/AppSettings.java +++ b/src/main/java/io/antmedia/AppSettings.java @@ -4053,14 +4053,6 @@ public void setHlsSegmentType(String hlsSegmentType) { this.hlsSegmentType = hlsSegmentType; } - public String getHlsSegmentFileSuffixFormat() { - return hlsSegmentFileSuffixFormat; - } - - public void setHlsSegmentFileNameFormat(String hlsSegmentFileSuffixFormat) { - this.hlsSegmentFileSuffixFormat = hlsSegmentFileSuffixFormat; - } - public String getRecordingSubfolder() { return recordingSubfolder; } @@ -4249,4 +4241,18 @@ public Map> getEncoderParameters() { public void setEncoderParameters(Map> encoderParameters) { this.encoderParameters = encoderParameters; } + + /** + * @return the hlsSegmentFileSuffixFormat + */ + public String getHlsSegmentFileSuffixFormat() { + return hlsSegmentFileSuffixFormat; + } + + /** + * @param hlsSegmentFileSuffixFormat the hlsSegmentFileSuffixFormat to set + */ + public void setHlsSegmentFileSuffixFormat(String hlsSegmentFileSuffixFormat) { + this.hlsSegmentFileSuffixFormat = hlsSegmentFileSuffixFormat; + } } diff --git a/src/test/java/io/antmedia/integration/MuxingTest.java b/src/test/java/io/antmedia/integration/MuxingTest.java index 2cf751fad..853381eec 100644 --- a/src/test/java/io/antmedia/integration/MuxingTest.java +++ b/src/test/java/io/antmedia/integration/MuxingTest.java @@ -833,7 +833,7 @@ public void testHLSSegmentFileName() { boolean hlsEnabled = appSettings.isHlsMuxingEnabled(); appSettings.setHlsMuxingEnabled(true); String hlsSegmentFileNameFormat = appSettings.getHlsSegmentFileSuffixFormat(); - appSettings.setHlsSegmentFileNameFormat("-%Y%m%d-%s"); + appSettings.setHlsSegmentFileSuffixFormat("-%Y%m%d-%s"); result = ConsoleAppRestServiceTest.callSetAppSettings("LiveApp", appSettings); assertTrue(result.isSuccess()); @@ -887,7 +887,7 @@ public void testHLSSegmentFileName() { }); appSettings.setHlsMuxingEnabled(hlsEnabled); - appSettings.setHlsSegmentFileNameFormat(hlsSegmentFileNameFormat); + appSettings.setHlsSegmentFileSuffixFormat(hlsSegmentFileNameFormat); ConsoleAppRestServiceTest.callSetAppSettings("LiveApp", appSettings); } catch (Exception e) { e.printStackTrace(); diff --git a/src/test/java/io/antmedia/test/AppSettingsUnitTest.java b/src/test/java/io/antmedia/test/AppSettingsUnitTest.java index 4fcac4d91..a16e0971a 100644 --- a/src/test/java/io/antmedia/test/AppSettingsUnitTest.java +++ b/src/test/java/io/antmedia/test/AppSettingsUnitTest.java @@ -648,7 +648,7 @@ public void testUnsetAppSettings(AppSettings appSettings) { assertFalse(appSettings.isWriteSubscriberEventsToDatastore()); assertEquals("%09d", appSettings.getHlsSegmentFileSuffixFormat()); - appSettings.setHlsSegmentFileNameFormat("%s"); + appSettings.setHlsSegmentFileSuffixFormat("%s"); assertEquals("%s", appSettings.getHlsSegmentFileSuffixFormat()); diff --git a/src/test/java/io/antmedia/test/MuxerUnitTest.java b/src/test/java/io/antmedia/test/MuxerUnitTest.java index 002553f8e..51e443810 100644 --- a/src/test/java/io/antmedia/test/MuxerUnitTest.java +++ b/src/test/java/io/antmedia/test/MuxerUnitTest.java @@ -4006,7 +4006,7 @@ public void testHLSNaming() { hlsMuxer.init(appScope, "test", 300, "", 400000); assertEquals("./webapps/junit/streams/test_300p400kbps%09d.ts", hlsMuxer.getSegmentFilename()); - getAppSettings().setHlsSegmentFileNameFormat("-%Y%m%d-%s"); + getAppSettings().setHlsSegmentFileSuffixFormat("-%Y%m%d-%s"); hlsMuxer = new HLSMuxer(vertx, Mockito.mock(StorageClient.class), "", 7, null, false); hlsMuxer.init(appScope, "test", 0, "", 0); assertEquals("./webapps/junit/streams/test-%Y%m%d-%s.ts", hlsMuxer.getSegmentFilename()); diff --git a/src/test/java/io/antmedia/test/StreamFetcherUnitTest.java b/src/test/java/io/antmedia/test/StreamFetcherUnitTest.java index 37ba9e3b7..26c0c14a3 100644 --- a/src/test/java/io/antmedia/test/StreamFetcherUnitTest.java +++ b/src/test/java/io/antmedia/test/StreamFetcherUnitTest.java @@ -973,7 +973,9 @@ public void testHLSSourceFmp4() { String[] filesInStreams = new File("webapps/junit/streams").list(); boolean initFileFound = false; - String regex = streamId + "_" + System.currentTimeMillis()/100000 + "\\d{5}_init.mp4"; + + //matches 13 digits because System.currentTimeMillis() is used in the file + String regex = streamId + "_\\d{13}_init.mp4"; System.out.println("regex:"+regex); for (int i = 0; i < filesInStreams.length; i++) {