From 150d95dabcd7b5a036d403dcd0d407b2ce9a3650 Mon Sep 17 00:00:00 2001 From: yoep Date: Thu, 21 Dec 2023 14:44:25 +0100 Subject: [PATCH 1/2] Fixed Spring Boot 3 autoconfiguration loading --- pom.xml | 5 ++++ src/main/resources/META-INF/spring.factories | 2 -- ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../javafx/JavaFxAutoConfigurationTest.java | 28 +++++++++++++++++++ .../spring/boot/javafx/TestConfiguration.java | 13 +++++++++ .../javafx/font/FontRegistryImplTest.java | 23 +++++++++++++++ 6 files changed, 70 insertions(+), 2 deletions(-) delete mode 100644 src/main/resources/META-INF/spring.factories create mode 100644 src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 src/test/java/com/github/spring/boot/javafx/JavaFxAutoConfigurationTest.java create mode 100644 src/test/java/com/github/spring/boot/javafx/TestConfiguration.java create mode 100644 src/test/java/com/github/spring/boot/javafx/font/FontRegistryImplTest.java diff --git a/pom.xml b/pom.xml index ac79e62..1946398 100644 --- a/pom.xml +++ b/pom.xml @@ -128,6 +128,11 @@ ${testfx.junit.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 885cfd0..0000000 --- a/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.github.spring.boot.javafx.JavaFxAutoConfiguration \ No newline at end of file diff --git a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..d6531d3 --- /dev/null +++ b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.github.spring.boot.javafx.JavaFxAutoConfiguration \ No newline at end of file diff --git a/src/test/java/com/github/spring/boot/javafx/JavaFxAutoConfigurationTest.java b/src/test/java/com/github/spring/boot/javafx/JavaFxAutoConfigurationTest.java new file mode 100644 index 0000000..17210d8 --- /dev/null +++ b/src/test/java/com/github/spring/boot/javafx/JavaFxAutoConfigurationTest.java @@ -0,0 +1,28 @@ +package com.github.spring.boot.javafx; + +import com.github.spring.boot.javafx.view.ViewLoader; +import com.github.spring.boot.javafx.view.ViewManager; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@SpringBootTest( + classes = { + JavaFxAutoConfiguration.class, + TestConfiguration.class + } +) +class JavaFxAutoConfigurationTest { + @Autowired + private ViewManager viewManager; + @Autowired + private ViewLoader viewLoader; + + @Test + void testAutoConfiguration() { + assertNotNull(viewManager, "expected a view manager to have been created"); + assertNotNull(viewLoader, "expected a view loader to have been created"); + } +} \ No newline at end of file diff --git a/src/test/java/com/github/spring/boot/javafx/TestConfiguration.java b/src/test/java/com/github/spring/boot/javafx/TestConfiguration.java new file mode 100644 index 0000000..eb0b2b0 --- /dev/null +++ b/src/test/java/com/github/spring/boot/javafx/TestConfiguration.java @@ -0,0 +1,13 @@ +package com.github.spring.boot.javafx; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ResourceBundleMessageSource; + +@Configuration +public class TestConfiguration { + @Bean + public ResourceBundleMessageSource resourceBundleMessageSource() { + return new ResourceBundleMessageSource(); + } +} diff --git a/src/test/java/com/github/spring/boot/javafx/font/FontRegistryImplTest.java b/src/test/java/com/github/spring/boot/javafx/font/FontRegistryImplTest.java new file mode 100644 index 0000000..91efcfa --- /dev/null +++ b/src/test/java/com/github/spring/boot/javafx/font/FontRegistryImplTest.java @@ -0,0 +1,23 @@ +package com.github.spring.boot.javafx.font; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class FontRegistryImplTest { + @Test + void testGetInstance() { + var result = FontRegistryImpl.getInstance(); + + assertNotNull(result, "expected a font registry instance to have been returned"); + } + + @Test + void testLoadFont() { + var registry = FontRegistryImpl.getInstance(); + + var font = registry.loadFont("fontawesome-regular.ttf"); + + assertNotNull(font, "expected a font to have been returned"); + } +} \ No newline at end of file From 37d827570ee25cc38fcd3b7533fbaf39d416977c Mon Sep 17 00:00:00 2001 From: yoep Date: Thu, 21 Dec 2023 14:46:27 +0100 Subject: [PATCH 2/2] Added Github actions workflow for testing the library --- .github/workflows/maven-build.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/maven-build.yml diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml new file mode 100644 index 0000000..d6e4b70 --- /dev/null +++ b/.github/workflows/maven-build.yml @@ -0,0 +1,31 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + inputs: {} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: 17 + cache: 'maven' + - name: Maven test + run: | + mvn -B test \ No newline at end of file