Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,84 @@ void registerHints() {
.matches(resource().forResource("/org/apache/pdfbox/resources/version.properties"));
}

@Test
void registerHintsWithNullRuntimeHints() {
// Test null safety for RuntimeHints parameter
PdfReaderRuntimeHints pdfReaderRuntimeHints = new PdfReaderRuntimeHints();

Assertions.assertThatThrownBy(() -> pdfReaderRuntimeHints.registerHints(null, null))
.isInstanceOf(NullPointerException.class);
}

@Test
void registerHintsMultipleTimes() {
// Test that multiple calls don't cause issues (idempotent behavior)
RuntimeHints runtimeHints = new RuntimeHints();
PdfReaderRuntimeHints pdfReaderRuntimeHints = new PdfReaderRuntimeHints();

// Register hints multiple times
pdfReaderRuntimeHints.registerHints(runtimeHints, null);
pdfReaderRuntimeHints.registerHints(runtimeHints, null);

// Should still work correctly
Assertions.assertThat(runtimeHints)
.matches(resource().forResource("/org/apache/pdfbox/resources/glyphlist/zapfdingbats.txt"));
Assertions.assertThat(runtimeHints)
.matches(resource().forResource("/org/apache/pdfbox/resources/glyphlist/glyphlist.txt"));
Assertions.assertThat(runtimeHints)
.matches(resource().forResource("/org/apache/pdfbox/resources/version.properties"));
}

@Test
void verifyAllExpectedResourcesRegistered() {
// Test that all necessary PDFBox resources are registered
RuntimeHints runtimeHints = new RuntimeHints();
PdfReaderRuntimeHints pdfReaderRuntimeHints = new PdfReaderRuntimeHints();
pdfReaderRuntimeHints.registerHints(runtimeHints, null);

// Core glyph list resources
Assertions.assertThat(runtimeHints)
.matches(resource().forResource("/org/apache/pdfbox/resources/glyphlist/zapfdingbats.txt"));
Assertions.assertThat(runtimeHints)
.matches(resource().forResource("/org/apache/pdfbox/resources/glyphlist/glyphlist.txt"));

// Version properties
Assertions.assertThat(runtimeHints)
.matches(resource().forResource("/org/apache/pdfbox/resources/version.properties"));

// Test that uncommented resource patterns are NOT registered (if they shouldn't
// be)
// This validates the current implementation only registers what's needed
}

@Test
void verifyClassLoaderContextParameterIgnored() {
// Test that the ClassLoader parameter doesn't affect resource registration
RuntimeHints runtimeHints1 = new RuntimeHints();
RuntimeHints runtimeHints2 = new RuntimeHints();
PdfReaderRuntimeHints pdfReaderRuntimeHints = new PdfReaderRuntimeHints();

// Register with null ClassLoader
pdfReaderRuntimeHints.registerHints(runtimeHints1, null);

// Register with current ClassLoader
pdfReaderRuntimeHints.registerHints(runtimeHints2, getClass().getClassLoader());

// Both should have the same resources registered
Assertions.assertThat(runtimeHints1)
.matches(resource().forResource("/org/apache/pdfbox/resources/glyphlist/zapfdingbats.txt"));
Assertions.assertThat(runtimeHints2)
.matches(resource().forResource("/org/apache/pdfbox/resources/glyphlist/zapfdingbats.txt"));
}

@Test
void verifyRuntimeHintsRegistrationInterface() {
// Test that PdfReaderRuntimeHints properly implements RuntimeHintsRegistrar
PdfReaderRuntimeHints pdfReaderRuntimeHints = new PdfReaderRuntimeHints();

// Verify it's a RuntimeHintsRegistrar
Assertions.assertThat(pdfReaderRuntimeHints)
.isInstanceOf(org.springframework.aot.hint.RuntimeHintsRegistrar.class);
}

}