Skip to content

Commit

Permalink
Increased test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fschleich committed Sep 30, 2024
1 parent 0ebf06a commit e3e416b
Show file tree
Hide file tree
Showing 31 changed files with 4,181 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public static List<ErrorLogger.ErrorObject> analyzeFile(File inputFile) throws I
default:
errorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMP_VALIDATOR_PAYLOAD_ERROR,
IMFErrorLogger.IMFErrors.ErrorLevels.FATAL,
String.format("Unknown AssetType"));
String.format("Unknown AssetType"));
}

return errorLogger.getErrors();
Expand Down
128 changes: 123 additions & 5 deletions src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;

import static com.netflix.imflibrary.app.IMPAnalyzer.analyzePackage;
import static com.netflix.imflibrary.app.IMPAnalyzer.analyzeFile;

@Test(groups = "unit")
public class IMPAnalyzerTest
Expand Down Expand Up @@ -47,6 +48,44 @@ public void IMPAnalyzerTestPHDR() throws IOException

}

@Test
public void IMPAnalyzerTestTimedText() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/TimedTextImageAndTextProfile/");
Map<String, List<ErrorLogger.ErrorObject>> errorMap = analyzePackage(inputFile);
Assert.assertEquals(errorMap.size(), 8);
errorMap.entrySet().stream().forEach( e ->
{
if (e.getKey().matches("CPL.*")) {
Assert.assertEquals(e.getValue().size(), 0);
} else {
Assert.assertEquals(e.getValue().size(), 0);
}
}
);

}

@Test
public void IMPAnalyzerTestMissingFilesAndAssetMapEntries() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/MissingFilesAndAssetMapEntries/");
Map<String, List<ErrorLogger.ErrorObject>> errorMap = analyzePackage(inputFile);
Assert.assertEquals(errorMap.size(), 4);
errorMap.entrySet().stream().forEach( e ->
{
if (e.getKey().matches("PKL.*")) {
Assert.assertEquals(e.getValue().size(), 4);
Assert.assertTrue(e.getValue().get(0).getErrorDescription().contains("Failed to get path for Asset with ID = bc1a3912-a90a-41b2-b16c-0915a2a1e088"));
Assert.assertTrue(e.getValue().get(1).getErrorDescription().contains("Cannot find asset with path"));
} else {
Assert.assertEquals(e.getValue().size(), 0);
}
}
);

}

@Test
public void IMPAnalyzerTestIDMismatches() throws IOException
{
Expand All @@ -60,19 +99,19 @@ public void IMPAnalyzerTestIDMismatches() throws IOException
}
else if (e.getKey().matches("ASSETMAP.*")) {
Assert.assertEquals(e.getValue().size(), 1);
e.getValue().get(0).getErrorDescription().contains("ERROR-AssetMap references PKL with ID f5e93462-aed2-44ad-a4ba-2adb65823e7d, but PKL contains ID f5e93462-aed2-44ad-a4ba-2adb65823e7c");
Assert.assertTrue(e.getValue().get(0).getErrorDescription().contains("AssetMap references PKL with ID f5e93462-aed2-44ad-a4ba-2adb65823e7d, but PKL contains ID f5e93462-aed2-44ad-a4ba-2adb65823e7c"));
}
else if (e.getKey().matches("CPL.*")) {
Assert.assertEquals(e.getValue().size(), 2);
e.getValue().get(0).getErrorDescription().contains("ERROR-UUID 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca84 in the CPL is not same as UUID 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85 of the CPL in the AssetMap");
Assert.assertTrue(e.getValue().get(0).getErrorDescription().contains("UUID 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca84 in the CPL is not same as UUID 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85 of the CPL in the AssetMap"));
}
else if (e.getKey().matches("OPL.*")) {
Assert.assertEquals(e.getValue().size(), 2);
e.getValue().get(0).getErrorDescription().contains("ERROR-UUID 8cf83c32-4949-4f00-b081-01e12b18932e in the OPL is not same as UUID 8cf83c32-4949-4f00-b081-01e12b18932f of the OPL in the AssetMap");
e.getValue().get(1).getErrorDescription().contains("Failed to get application composition with ID = 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85");
Assert.assertTrue(e.getValue().get(0).getErrorDescription().contains("UUID 8cf83c32-4949-4f00-b081-01e12b18932e in the OPL is not same as UUID 8cf83c32-4949-4f00-b081-01e12b18932f of the OPL in the AssetMap"));
Assert.assertTrue(e.getValue().get(1).getErrorDescription().contains("Failed to get application composition with ID = 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85"));
} else if (e.getKey().matches("MERIDIAN_Netflix_Photon_161006_00.mxf.*")) {
Assert.assertEquals(e.getValue().size(), 1);
e.getValue().get(0).getErrorDescription().contains("ERROR-UUID 61d91654-2650-4abf-abbc-ad2c7f640bf8 in the MXF file is not same as UUID 61d91654-2650-4abf-abbc-ad2c7f640bf9 of the MXF file in the AssetMap");
Assert.assertTrue(e.getValue().get(0).getErrorDescription().contains("UUID 61d91654-2650-4abf-abbc-ad2c7f640bf8 in the MXF file is not same as UUID 61d91654-2650-4abf-abbc-ad2c7f640bf9 of the MXF file in the AssetMap"));
}
}
);
Expand All @@ -96,4 +135,83 @@ public void IMPAnalyzerTestMimeTypeErrors() throws IOException
}
);
}

@Test
public void IMPAnalyzerAnalyzeCPLValid() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/PHDR/CPL_3aa56098-7709-4673-9266-7f0c70ba10d8.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 0);

}

@Test
public void IMPAnalyzerAnalyzeCPLError() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/Application2Extended/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_JPEG2000SubDescriptorError.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 4);
}

@Test
public void IMPAnalyzerAnalyzePKLValid() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/PHDR/PKL_913ef906-893f-4851-8664-2d053bd2ec95.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 0);

}

@Test
public void IMPAnalyzerAnalyzePKLError() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/BadXML/PKL_d54a68ed-332e-4ddd-b163-c0317abb1e52.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 2);
}

@Test
public void IMPAnalyzerAnalyzeAssetMapValid() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/PHDR/ASSETMAP.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 0);

}

@Test
public void IMPAnalyzerAnalyzeAssetMapError() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/BadXML/ASSETMAP.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 4);
}

@Test
public void IMPAnalyzerAnalyzeOPLValid() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/OPL/OPL_8cf83c32-4949-4f00-b081-01e12b18932f_simple.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 0);

}

@Test
public void IMPAnalyzerAnalyzeOPLError() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/BadXML/OPL_8cf83c32-4949-4f00-b081-01e12b18932f_simple.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 2);
}

@Test
public void IMPAnalyzerAnalyzeUnknownFileError() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/BadXML/CPL_67be5fc8-87f1-4172-8d52-819ca14c7a20.xml");
List<ErrorLogger.ErrorObject> errorList = analyzeFile(inputFile);
Assert.assertEquals(errorList.size(), 1);
Assert.assertTrue(errorList.get(0).getErrorDescription().contains("Unknown AssetType"));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.netflix.imflibrary.IMFErrorLogger;
import com.netflix.imflibrary.IMFErrorLoggerImpl;
import com.netflix.imflibrary.st2067_2.ApplicationComposition;
import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
Expand All @@ -21,7 +22,14 @@ public void ValidCPL() throws IOException
File inputFile = TestHelper.findResourceByPath("TestIMP/Application2E2021/CPL_b2e1ace2-9c7d-4c12-b2f7-24bde303869e.xml");
IMFErrorLogger logger = new IMFErrorLoggerImpl();

ApplicationCompositionFactory.getApplicationComposition(inputFile, logger);
ApplicationComposition applicationComposition = ApplicationCompositionFactory.getApplicationComposition(inputFile, logger);

/* Make sure its 2020 core constraints */
Assert.assertEquals(applicationComposition.getCoreConstraintsSchema(), "http://www.smpte-ra.org/ns/2067-2/2020");

/* Make sure its APP2#E Composition */
Assert.assertEquals(applicationComposition.getApplicationCompositionType(), ApplicationCompositionFactory.ApplicationCompositionType.APPLICATION_2E2021_COMPOSITION_TYPE);

logger.getErrors().forEach(e -> {System.out.println(e.getErrorDescription());});
Assert.assertEquals(logger.getErrors().size(), 0);
}
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTestApp5.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
package com.netflix.imflibrary.app;

import com.netflix.imflibrary.IMFErrorLogger;
import com.netflix.imflibrary.IMFErrorLoggerImpl;
import com.netflix.imflibrary.st2067_2.ApplicationComposition;
import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory;
import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory.ApplicationCompositionType;
import com.netflix.imflibrary.utils.ErrorLogger;
import org.testng.Assert;
Expand Down Expand Up @@ -50,4 +54,25 @@ public void IMPAnalyzerTestApp5() throws IOException
);

}

@Test
public void ValidApplicationTypeCPL() throws IOException
{
File inputFile = TestHelper.findResourceByPath("TestIMP/Application5/PhotonApp5Test/CPL_cfad00b4-77b5-4d06-bd9d-48bc21c8fc0e.xml");
IMFErrorLogger logger = new IMFErrorLoggerImpl();

ApplicationComposition applicationComposition = ApplicationCompositionFactory.getApplicationComposition(inputFile, logger);

/* Make sure its 2020 core constraints */
Assert.assertEquals(applicationComposition.getCoreConstraintsSchema(), "http://www.smpte-ra.org/schemas/2067-2/2016");

/* Make sure its APP #5 Composition */
Assert.assertEquals(applicationComposition.getApplicationCompositionType(), ApplicationCompositionFactory.ApplicationCompositionType.APPLICATION_5_COMPOSITION_TYPE);

logger.getErrors().forEach(e -> {System.out.println(e.getErrorDescription());});
Assert.assertEquals(logger.getErrors().size(), 3);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,21 @@ public void app2CompositionPictureEssenceCodingErrorTest() throws IOException {
Assert.assertEquals(imfErrorLogger.getErrors().size(), 1);
}

@Test
public void app2CompositionStoredWidthErrorTest() throws IOException {
File inputFile = TestHelper.findResourceByPath
("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_StoredWidthError.xml");
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger);
Assert.assertEquals(imfErrorLogger.getErrors().size(), 1);
}

@Test
public void app2CompositionEssenceCodingErrorTest() throws IOException {
File inputFile = TestHelper.findResourceByPath
("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_EssenceCodingError.xml");
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger);
Assert.assertEquals(imfErrorLogger.getErrors().size(), 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public void app2ExtendedCompositionYUV4KTest() throws IOException {
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
ApplicationComposition applicationComposition = ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger);

/* Make sure its 2013 core constraints */
Assert.assertEquals(applicationComposition.getCoreConstraintsSchema(), "http://www.smpte-ra.org/schemas/2067-2/2013");

/* Make sure its APP2#E Composition */
Assert.assertEquals(applicationComposition.getApplicationCompositionType(), ApplicationCompositionFactory.ApplicationCompositionType.APPLICATION_2E_COMPOSITION_TYPE);

Expand Down Expand Up @@ -240,4 +243,23 @@ public void validJ2KHeaderParameters() throws IOException
Assert.assertEquals(p.cod.transformation, 0x01);
Assert.assertEquals(p.cod.precinctSizes, new short[] { 0x77, 0x88, 0x88, 0x88, 0x88, 0x88 });
}

@Test
public void app2ExtendedCompositionEssenceCodingErrorTest() throws IOException {
File inputFile = TestHelper.findResourceByPath
("TestIMP/Application2Extended/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_CodecError.xml");
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger);
Assert.assertEquals(imfErrorLogger.getErrors().size(), 1);
}

@Test
public void app2ExtendedCompositionJ2kProfileErrorTest() throws IOException {
File inputFile = TestHelper.findResourceByPath
("TestIMP/Application2Extended/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_J2kProfileError.xml");
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger);
Assert.assertEquals(imfErrorLogger.getErrors().size(), 1);
}

}
28 changes: 28 additions & 0 deletions src/test/resources/PKL_2067_2_2050.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<PackingList xmlns="http://www.smpte-ra.org/schemas/2067-2/2050/PKL">
<Id>urn:uuid:7281a71b-0dcb-4ed7-93a4-97b7929e2a7c</Id>
<AnnotationText>Test file with invalid namespace</AnnotationText>
<IssueDate>2016-06-30T18:19:27-00:00</IssueDate>
<Issuer>Netflix</Issuer>
<Creator>Netflix</Creator>
<AssetList>
<Asset>
<Id>urn:uuid:88b5b453-a342-46eb-bc0a-4c9645f4d627</Id>
<AnnotationText>1.mxf</AnnotationText>
<Hash>oQjE4GVsXTeawQOL//tMJ3HAMzk=</Hash>
<Size>19139240035</Size>
<Type>application/mxf</Type>
<OriginalFileName>1.mxf</OriginalFileName>
<HashAlgorithm Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</Asset>
<Asset>
<Id>urn:uuid:e7d1ba66-84ad-4974-8d9d-a1e6d2431a9c</Id>
<AnnotationText>2.mxf</AnnotationText>
<Hash>CDh8VxZEyF9pQ1vtuqtUWwsTwz4=</Hash>
<Size>112457857</Size>
<Type>application/mxf</Type>
<OriginalFileName>2.mxf</OriginalFileName>
<HashAlgorithm Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</Asset>
</AssetList>
</PackingList>
Loading

0 comments on commit e3e416b

Please sign in to comment.