10.3.  Java Syntax Error due to typing error

Error Message

# Failed test 'error intended, wrong method name'
# died: No public method 'hasLanguageXXX' defined for 
# class 'main::com::pdfunit::validators::DocumentValidator' 
# at C:/.../pdfunit-typical-error_java-syntax-error.t line 36.
Can't locate object method "getMessage" via package. 
"No public method 'hasLanguageXXX' defined for 
class 'main::com::pdfunit::validators::DocumentValidator' 
at C:/.../pdfunit-typical-error_java-syntax-error.t line 36.

Explanation

The modul Inline::Java searches the method with the wrong name in all known Java classes, can't found it and throws an exception. The error message contains the name of the analyzed class. Read the Javadoc documentation, maybe you find the correct written method.

Code with Error

lives_ok {
  my $pdfUnderTest = "$resources_dir/language/localeDemo_de.pdf";
  AssertThat->document($pdfUnderTest)
            ->hasLanguageXXX('de')     # error, not existing method
  ; 
} "typical error, wrong method name";

Good Code

lives_ok {
  my $pdfUnderTest = "$resources_dir/language/localeDemo_de.pdf";
  AssertThat->document($pdfUnderTest)
            ->hasLanguageInfo('de')    # syntax OK
  ; 
} "no error, correct method name";