@@ -543,13 +543,14 @@ void testLenientBagSeqMixup() throws XmpParsingException
543543 " </rdf:RDF>\n " +
544544 "</x:xmpmeta>\n " +
545545 "<?xpacket end='w'?>" ;
546+ final DomXmpParser xmpParser1 = new DomXmpParser ();
546547 XmpParsingException ex = assertThrows (
547548 XmpParsingException .class ,
548- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
549+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
549550 assertEquals ("Invalid array type, expecting Bag and found Seq [prefix=dc; name=subject]" , ex .getMessage ());
550- DomXmpParser xmpParser = new DomXmpParser ();
551- xmpParser .setStrictParsing (false );
552- XMPMetadata xmp = xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 ));
551+ final DomXmpParser xmpParser2 = new DomXmpParser ();
552+ xmpParser2 .setStrictParsing (false );
553+ XMPMetadata xmp = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
553554 DublinCoreSchema dublinCoreSchema = xmp .getDublinCoreSchema ();
554555 List <String > subjects = dublinCoreSchema .getSubjects ();
555556 assertEquals (2 , subjects .size ());
@@ -573,13 +574,14 @@ void testBadAttr() throws XmpParsingException
573574 " </rdf:Description>\n " +
574575 " </rdf:RDF>\n " +
575576 "</x:xmpmeta><?xpacket end=\" r\" ?>" ;
577+ final DomXmpParser xmpParser1 = new DomXmpParser ();
576578 XmpParsingException ex = assertThrows (
577579 XmpParsingException .class ,
578- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
580+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
579581 assertEquals ("No type defined for {http://ns.adobe.com/xap/1.0/sType/Dimensions#}X" , ex .getMessage ());
580- DomXmpParser xmpParser = new DomXmpParser ();
581- xmpParser .setStrictParsing (false );
582- XMPMetadata xmp = xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 ));
582+ final DomXmpParser xmpParser2 = new DomXmpParser ();
583+ xmpParser2 .setStrictParsing (false );
584+ XMPMetadata xmp = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
583585 XMPPageTextSchema pageTextSchema = xmp .getPageTextSchema ();
584586 DimensionsType dim = (DimensionsType ) pageTextSchema .getProperty (XMPPageTextSchema .MAX_PAGE_SIZE );
585587 assertEquals ("DimensionsType{null x null null}" , dim .toString ());
@@ -601,13 +603,14 @@ void testBadType() throws XmpParsingException
601603 " pdf:Author=\" edocslib\" />\n " +
602604 "</rdf:RDF>\n " +
603605 "<?xpacket end='r'?>" ;
606+ final DomXmpParser xmpParser1 = new DomXmpParser ();
604607 XmpParsingException ex = assertThrows (
605608 XmpParsingException .class ,
606- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
609+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
607610 assertEquals ("No type defined for {http://ns.adobe.com/pdf/1.3/}Author" , ex .getMessage ());
608- DomXmpParser xmpParser = new DomXmpParser ();
609- xmpParser .setStrictParsing (false );
610- XMPMetadata xmp = xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 ));
611+ final DomXmpParser xmpParser2 = new DomXmpParser ();
612+ xmpParser2 .setStrictParsing (false );
613+ XMPMetadata xmp = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
611614 AdobePDFSchema adobePDFSchema = xmp .getAdobePDFSchema ();
612615 TextType tt = (TextType ) adobePDFSchema .getProperty ("Author" );
613616 assertEquals ("[Author=TextType:edocslib]" , tt .toString ());
@@ -622,9 +625,10 @@ void testBadLocalName() throws XmpParsingException
622625 " <rdf:RDF xmlns:iX=\" http://ns.adobe.com/iX/1.0/\" xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >\n " +
623626 " </rdf:RDF>\n " +
624627 "</x:xapmeta><?xpacket end='w'?>" ;
628+ final DomXmpParser xmpParser = new DomXmpParser ();
625629 XmpParsingException ex = assertThrows (
626630 XmpParsingException .class ,
627- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
631+ () -> xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 )));
628632 assertEquals ("Expecting local name 'xmpmeta' and found 'xapmeta'" , ex .getMessage ());
629633 }
630634
@@ -639,9 +643,10 @@ void testBadXPacketEnd1() throws XmpParsingException
639643 " </rdf:Description>\n " +
640644 " </rdf:RDF>\n " +
641645 "</x:xmpmeta><?xpacket ends=\" w\" ?>" ;
646+ final DomXmpParser xmpParser = new DomXmpParser ();
642647 XmpParsingException ex = assertThrows (
643648 XmpParsingException .class ,
644- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
649+ () -> xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 )));
645650 assertEquals ("Excepted xpacket 'end' attribute (must be present and placed in first)" , ex .getMessage ());
646651 }
647652
@@ -656,9 +661,10 @@ void testBadXPacketEnd2() throws XmpParsingException
656661 " </rdf:Description>\n " +
657662 " </rdf:RDF>\n " +
658663 "</x:xmpmeta><?xpacket end=\" k\" ?>" ;
664+ final DomXmpParser xmpParser = new DomXmpParser ();
659665 XmpParsingException ex = assertThrows (
660666 XmpParsingException .class ,
661- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
667+ () -> xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 )));
662668 assertEquals ("Excepted xpacket 'end' attribute with value 'r' or 'w' " , ex .getMessage ());
663669 }
664670
@@ -669,9 +675,10 @@ void testNoRdfChildren() throws XmpParsingException
669675 "<?xpacket begin=\" \" id=\" W5M0MpCehiHzreSzNTczkc9d\" ?>" +
670676 " <x:xmpmeta xmlns:x=\" adobe:ns:meta/\" />\n " +
671677 "<?xpacket end=\" w\" ?>" ;
678+ final DomXmpParser xmpParser = new DomXmpParser ();
672679 XmpParsingException ex = assertThrows (
673680 XmpParsingException .class ,
674- () -> new DomXmpParser () .parse (s .getBytes (StandardCharsets .UTF_8 )));
681+ () -> xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 )));
675682 assertEquals ("No rdf description found in xmp" , ex .getMessage ());
676683 }
677684}
0 commit comments