@@ -131,11 +131,11 @@ public void unsupportedGlyphTest() throws IOException, InterruptedException {
131
131
String destinationPdfUa1 = DESTINATION_FOLDER + "unsupportedGlyphUa1.pdf" ;
132
132
String destinationPdfUa2 = DESTINATION_FOLDER + "unsupportedGlyphUa2.pdf" ;
133
133
134
- String expectedUa1Message = MessageFormatUtil .format (
134
+ String expectedUaMessage = MessageFormatUtil .format (
135
135
PdfUAExceptionMessageConstants .GLYPH_IS_NOT_DEFINED_OR_WITHOUT_UNICODE , '中' );
136
136
137
- convertToUa1AndCheckCompliance (sourceHtml , destinationPdfUa1 , cmpPdfUa1 , false , expectedUa1Message );
138
- convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , false );
137
+ convertToUa1AndCheckCompliance (sourceHtml , destinationPdfUa1 , cmpPdfUa1 , false , expectedUaMessage );
138
+ convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , false , expectedUaMessage );
139
139
}
140
140
141
141
@ Test
@@ -247,9 +247,8 @@ public void inputWithTitleTagTest() throws IOException, InterruptedException {
247
247
ConverterProperties converterProperties = new ConverterProperties ();
248
248
converterProperties .setCreateAcroForm (true );
249
249
250
- convertToUa1AndCheckCompliance (sourceHtml , destinationPdfUa1 , cmpPdfUa1 , converterProperties , true ,
251
- null );
252
- convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , converterProperties , true );
250
+ convertToUa1AndCheckCompliance (sourceHtml , destinationPdfUa1 , cmpPdfUa1 , converterProperties , true , null );
251
+ convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , converterProperties , true , null );
253
252
}
254
253
255
254
@ Test
@@ -385,7 +384,15 @@ private void convertToUa1AndCheckCompliance(String sourceHtml, String destinatio
385
384
private void convertToUa2AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
386
385
boolean isExpectedOk )
387
386
throws IOException , InterruptedException {
388
- convertToUa2AndCheckCompliance (sourceHtml , destinationPdf , cmpPdf , new ConverterProperties (), isExpectedOk );
387
+ convertToUa2AndCheckCompliance (sourceHtml , destinationPdf , cmpPdf , new ConverterProperties (), isExpectedOk ,
388
+ null );
389
+ }
390
+
391
+ private void convertToUa2AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
392
+ boolean isExpectedOk , String expectedErrorMessage )
393
+ throws IOException , InterruptedException {
394
+ convertToUa2AndCheckCompliance (sourceHtml , destinationPdf , cmpPdf , new ConverterProperties (), isExpectedOk ,
395
+ expectedErrorMessage );
389
396
}
390
397
391
398
private void convertToUa1AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
@@ -418,7 +425,8 @@ private void convertToUa1AndCheckCompliance(String sourceHtml, String destinatio
418
425
}
419
426
420
427
private void convertToUa2AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
421
- ConverterProperties converterProperties , boolean isExpectedOk )
428
+ ConverterProperties converterProperties , boolean isExpectedOk ,
429
+ String expectedErrorMessage )
422
430
throws IOException , InterruptedException {
423
431
PdfDocument pdfDocument = new PdfUADocument (new PdfWriter (destinationPdf , new WriterProperties ().setPdfVersion (
424
432
PdfVersion .PDF_2_0 )), new PdfUAConfig (PdfUAConformance .PDF_UA_2 , "simple doc" , "en-US" ));
@@ -434,8 +442,15 @@ private void convertToUa2AndCheckCompliance(String sourceHtml, String destinatio
434
442
converterPropertiesCopy .setFontProvider (fontProvider );
435
443
converterPropertiesCopy .setBaseUri (SOURCE_FOLDER );
436
444
converterPropertiesCopy .setOutlineHandler (OutlineHandler .createStandardHandler ());
437
- HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument , converterPropertiesCopy );
438
445
439
- compareAndCheckCompliance (destinationPdf , cmpPdf , isExpectedOk );
446
+ if (expectedErrorMessage != null ) {
447
+ Exception e = Assertions .assertThrows (PdfUAConformanceException .class ,
448
+ () -> HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument ,
449
+ converterPropertiesCopy ));
450
+ Assertions .assertEquals (expectedErrorMessage , e .getMessage ());
451
+ } else {
452
+ HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument , converterPropertiesCopy );
453
+ compareAndCheckCompliance (destinationPdf , cmpPdf , isExpectedOk );
454
+ }
440
455
}
441
456
}
0 commit comments