@@ -61,10 +61,37 @@ void testEmptyStream() throws Exception {
6161 assertNotNull (results , "empty stream could not be analyzed" );
6262 assertEquals ("text/plain" , results .get (MimeTypeAction .KEY ));
6363 assertEquals ("txt" , results .get (ExtensionAction .KEY ));
64- assertEquals ("Binary data, ASCII Text Document" , results .get (DescriptionAction .KEY ));
64+ assertEquals ("ASCII Text Document" , results .get (DescriptionAction .KEY ));
6565 }
6666
67- public static Stream <Arguments > dataProvider () {
67+ public static Stream <Arguments > dataProviderVarious () {
68+ return Stream .of (
69+ arguments ("/various_types/test.png" , "image/png" , "PNG image data, colormap," , "png" ),
70+ arguments ("/various_types/File-PNG_8pbc_GRAY.png" , "image/png" , "PNG image data, grayscale," , "png" ),
71+ arguments ("/various_types/File-PNG_8bpc_RGBA.png" , "image/png" , "PNG image data, \\ b/color RGBA," , "png" ),
72+ arguments ("/various_types/File-PNG_16bpc_RGBA.png" , "image/png" , "PNG image data, \\ b/color RGBA," , "png" ),
73+ arguments ("/various_types/sample-rtf-files-sample2.rtf" , "text/rtf" , "Rich Text Format data" , "rtf" )
74+ );
75+ }
76+
77+ @ ParameterizedTest
78+ @ MethodSource ("dataProviderVarious" )
79+ void testVariousTypesExplicitly (String resource , String expectedMimeType , String expectedDescription , String expectedExtension ) throws Exception {
80+ final URL url = getClass ().getResource (resource );
81+ assertNotNull (url );
82+ final File file = new File (url .toURI ());
83+ final Map <String , Object > results = analyzer .analyze (file );
84+ printResult (results );
85+ assertNotNull (results , file + " could not be analyzed" );
86+ assertNotNull (results .get (MimeTypeAction .KEY ), "mimeType missing" );
87+ assertEquals (expectedMimeType , results .get (MimeTypeAction .KEY ), "wrong mimeType" );
88+ assertNotNull (results .get (DescriptionAction .KEY ), "description missing" );
89+ assertEquals (expectedDescription , results .get (DescriptionAction .KEY ), "wrong description" );
90+ assertNotNull (results .get (ExtensionAction .KEY ), "could not be analyzed" );
91+ assertEquals (expectedExtension , results .get (ExtensionAction .KEY ), "wrong extension" );
92+ }
93+
94+ public static Stream <Arguments > dataProviderXRechnung () {
6895 return Stream .of (
6996 arguments ("/various_types/BASIC_Einfach.pdf" , "application/pdf" ),
7097 arguments ("/various_types/EN16931_Einfach.pdf" , "application/pdf" ),
@@ -75,7 +102,7 @@ public static Stream<Arguments> dataProvider() {
75102 }
76103
77104 @ ParameterizedTest
78- @ MethodSource ("dataProvider " )
105+ @ MethodSource ("dataProviderXRechnung " )
79106 void testXRechnung (String resource , String expectedMimeType ) throws Exception {
80107 final URL url = getClass ().getResource (resource );
81108 assertNotNull (url );
@@ -109,7 +136,7 @@ private void ensureXRechnungIsTrue(final Map<String, Object> results, final Stri
109136 }
110137
111138
112- private static void printResult (final Map <String , Object > results ) {
139+ public static void printResult (final Map <String , Object > results ) {
113140 for (final Map .Entry <String , Object > e : results .entrySet ()) {
114141 LOGGER .info (" {}={}" , e .getKey (), e .getValue ());
115142 }
0 commit comments