java-tutorials/pdf-2/src/test/java/com/baeldung/pdfinfo/PdfInfoPdfBoxUnitTest.java

30 lines
902 B
Java
Raw Normal View History

package com.baeldung.pdfinfo;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
public class PdfInfoPdfBoxUnitTest {
private static final String PDF_FILE = "src/test/resources/input.pdf";
@Test
2022-11-09 11:55:20 +03:30
public void givenPdf_whenGetNumberOfPages_thenOK() throws IOException {
Assert.assertEquals(4, PdfInfoPdfBox.getNumberOfPages(PDF_FILE));
}
@Test
public void givenPdf_whenIsPasswordRequired_thenOK() throws IOException {
2022-11-09 11:55:20 +03:30
Assert.assertEquals(false, PdfInfoPdfBox.isPasswordRequired(PDF_FILE));
}
@Test
public void givenPdf_whenGetInfo_thenOK() throws IOException {
PDDocumentInformation info = PdfInfoPdfBox.getInfo(PDF_FILE);
2022-11-09 11:55:20 +03:30
Assert.assertEquals("LibreOffice 4.2", info.getProducer());
Assert.assertEquals("Writer", info.getCreator());
}
}