[ 
https://issues.apache.org/jira/browse/PDFBOX-5667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767017#comment-17767017
 ] 

Andreas Lehmkühler commented on PDFBOX-5667:
--------------------------------------------

It is not an issue with the test framework. 

ExtractText is a command line tool and supposed to be called from the command 
line. The class ExtractText is newly loaded every time it is called from the 
command line.

If ExtractText is used mulitple times within the same instance of a JVM the 
class is loaded once at the beginning and those static variables are 
initialized exactly once. If the value of System.out is changed during 
subsequent calls of ExtractText those changes don't matter as the static value 
in ExtractText isn't changed.

If you want to test text extraction you might use the class PDFTextStripper 
directly to avoid that issue. 

IMHO we should change all command line tools w.r.t. the handling of 
System.out/System.err. All static instances should be made non static to avoid 
such suprises

> Can't create test for ExtractText command line tool
> ---------------------------------------------------
>
>                 Key: PDFBOX-5667
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5667
>             Project: PDFBox
>          Issue Type: Test
>          Components: Text extraction
>    Affects Versions: 3.0.0 PDFBox
>         Environment: openjdk 11.0.20 2023-07-18
> OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04)
> OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed 
> mode, sharing)
>            Reporter: Marcelo Modesto
>            Priority: Minor
>         Attachments: TestExtractText fails.txt
>
>
> I think it's an issue with the testing framework, not PDFBox.
> When I try to create a new test for the ExtractText command line tool, it 
> fails because the standard output is empty after running the first test.
> If I change the declaration of a ExtractText variable (removing "static 
> final") that references System.out the test works.
> If you can confirm it's an issue with the test framework I would appreciate 
> it!
> Thank you! 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to