Author: tilman
Date: Tue Nov 11 13:13:28 2025
New Revision: 1929656
Log:
PDFBOX-6096: include test file instead of loading it 8x
Added:
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/PDFBOX-3656-SF1199AEG
(Complete).pdf (contents, props changed)
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java
Tue Nov 11 13:13:23 2025 (r1929655)
+++
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/TestRadioButtons.java
Tue Nov 11 13:13:28 2025 (r1929656)
@@ -16,6 +16,7 @@
*/
package org.apache.pdfbox.pdmodel.interactive.form;
+import java.io.File;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -24,10 +25,6 @@ import static org.junit.jupiter.api.Asse
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
import java.util.ArrayList;
import java.util.List;
@@ -35,7 +32,6 @@ import org.apache.pdfbox.Loader;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.io.RandomAccessReadBuffer;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
@@ -49,6 +45,9 @@ import org.junit.jupiter.api.Test;
*/
class TestRadioButtons
{
+ static final File TESTFILE3656 =
+ new
File("src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/PDFBOX-3656-SF1199AEG
(Complete).pdf");
+
/**
* This will test the radio button PDModel.
*
@@ -137,16 +136,11 @@ class TestRadioButtons
* PDFBOX-3656 Radio button field with FLAG_RADIOS_IN_UNISON false
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox3656NotInUnison() throws IOException, URISyntaxException
+ void testPDFBox3656NotInUnison() throws IOException
{
-
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -162,15 +156,11 @@ class TestRadioButtons
* Setting by the first export value shall only select the first radio
button
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByValidExportValue() throws IOException,
URISyntaxException
+ void testPDFBox3656ByValidExportValue() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -189,15 +179,11 @@ class TestRadioButtons
* PDFBOX-3656 Set by invalid export value
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByInvalidExportValue() throws IOException,
URISyntaxException
+ void testPDFBox3656ByInvalidExportValue() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -214,7 +200,7 @@ class TestRadioButtons
// compare the messages
String expectedMessage = "value 'Invalid' is not a valid option
for the field Checking/Savings, valid values are: [Checking, Savings] and Off";
String actualMessage = exception.getMessage();
-
+
assertTrue(actualMessage.contains(expectedMessage));
assertEquals("Off", field.getValue(), "no option shall be
selected");
@@ -229,15 +215,11 @@ class TestRadioButtons
* Setting by the index shall only select the corresponding radio button
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByValidIndex() throws IOException, URISyntaxException
+ void testPDFBox3656ByValidIndex() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -259,16 +241,11 @@ class TestRadioButtons
* Setting by the index shall only select the corresponding radio button
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox3656ByInvalidIndex() throws IOException, URISyntaxException
+ void testPDFBox3656ByInvalidIndex() throws IOException
{
-
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -285,7 +262,7 @@ class TestRadioButtons
// compare the messages
String expectedMessage = "index '6' is not a valid index for the
field Checking/Savings, valid indices are from 0 to 5";
String actualMessage = exception.getMessage();
-
+
assertTrue(actualMessage.contains(expectedMessage));
assertEquals("Off", field.getValue(), "no option shall be
selected");
@@ -297,15 +274,11 @@ class TestRadioButtons
* PDFBOX-4617 Enable getting selected index
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox4617IndexNoneSelected() throws IOException,
URISyntaxException
+ void testPDFBox4617IndexNoneSelected() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -318,15 +291,11 @@ class TestRadioButtons
* PDFBOX-4617 Enable getting selected index for value being set by option
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox4617IndexForSetByOption() throws IOException,
URISyntaxException
+ void testPDFBox4617IndexForSetByOption() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -340,15 +309,11 @@ class TestRadioButtons
* PDFBOX-4617 Enable getting selected index for value being set by index
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox4617IndexForSetByIndex() throws IOException,
URISyntaxException
+ void testPDFBox4617IndexForSetByIndex() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Checking/Savings");
@@ -364,15 +329,11 @@ class TestRadioButtons
* PDFBOX-5831 Numeric value for Opt entry
*
* @throws IOException
- * @throws URISyntaxException
*/
@Test
- void testPDFBox5831NumericValueForOpt() throws IOException,
URISyntaxException
+ void testPDFBox5831NumericValueForOpt() throws IOException
{
- String sourceUrl =
"https://issues.apache.org/jira/secure/attachment/13069137/AU_Erklaerung_final.pdf";
-
- try (PDDocument testPdf = Loader.loadPDF(
- RandomAccessReadBuffer.createBufferFromStream(new
URI(sourceUrl).toURL().openStream())))
+ try (PDDocument testPdf = Loader.loadPDF(TESTFILE3656))
{
PDAcroForm acroForm = testPdf.getDocumentCatalog().getAcroForm();
PDRadioButton field = (PDRadioButton)
acroForm.getField("Formular1[0].Seite1[0].TF_P[0].Optionsfeldliste[0]");
Added:
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/PDFBOX-3656-SF1199AEG
(Complete).pdf
==============================================================================
Binary file. No diff available.