diff options
| author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2026-06-10 14:53:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-10 14:53:17 +0200 |
| commit | 4e9263067734225a43b91aec3b38bede71038303 (patch) | |
| tree | 0f6b096a3d534a8e7872ae5893dfc3f0d6d01936 | |
| parent | 7a204f2c2520a875fa9c4166c243775e52f03e77 (diff) | |
| download | pdf-as-4-4e9263067734225a43b91aec3b38bede71038303.tar.gz pdf-as-4-4e9263067734225a43b91aec3b38bede71038303.tar.bz2 pdf-as-4-4e9263067734225a43b91aec3b38bede71038303.zip | |
use pdf-as-web.properties as a spring configuration source (#95)
3 files changed, 42 insertions, 0 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/PdfAsWebSpringConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/PdfAsWebSpringConfiguration.java index fcaf2b81..631247e2 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/PdfAsWebSpringConfiguration.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/PdfAsWebSpringConfiguration.java @@ -4,12 +4,20 @@ import lombok.Getter; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; @Component @Slf4j public class PdfAsWebSpringConfiguration { + /** path to pdf-as-web.properties as loaded from spring sources */ @Value("${pdf-as-web.conf}") @Getter @NonNull String pdfAsWebConfPath; + + /** then also add pdf-as-web.properties itself as a spring property source (so it supplements application.properties) */ + @Configuration + @PropertySource("file:${pdf-as-web.conf}") + public static class AsSpringPropertySource {} } diff --git a/pdf-as-web/src/test/java/at/gv/egiz/pdfas/web/test/SpringIntegrationTest.java b/pdf-as-web/src/test/java/at/gv/egiz/pdfas/web/test/SpringIntegrationTest.java new file mode 100644 index 00000000..2f0ce8f7 --- /dev/null +++ b/pdf-as-web/src/test/java/at/gv/egiz/pdfas/web/test/SpringIntegrationTest.java @@ -0,0 +1,32 @@ +package at.gv.egiz.pdfas.web.test; + +import lombok.Getter; +import lombok.SneakyThrows; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class SpringIntegrationTest { + @BeforeAll + @SneakyThrows + public static void classInitializer() { + final String current = new java.io.File(".").getCanonicalPath(); + System.setProperty("pdf-as-web.conf", + current + "/src/test/resources/config/pdfas/pdf-as-web.properties"); + } + + @Value("${dummy.springtest.parameter:#{null}}") + @Getter + String dummy; + + @Test + @SneakyThrows + public void springPropertySourceTest() { + // this is set in pdf-as-web.properties in the test resources, as loaded by the class initializer + Assertions.assertEquals("42", dummy); + } + +} diff --git a/pdf-as-web/src/test/resources/config/pdfas/pdf-as-web.properties b/pdf-as-web/src/test/resources/config/pdfas/pdf-as-web.properties index 78969371..242920df 100644 --- a/pdf-as-web/src/test/resources/config/pdfas/pdf-as-web.properties +++ b/pdf-as-web/src/test/resources/config/pdfas/pdf-as-web.properties @@ -59,3 +59,5 @@ allow.ext.overwrite=true ext.overwrite.wl.01=sig_obj.type.defadult default.protectPDF = true + +dummy.springtest.parameter = 42 |
