diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 378864a1df..0d076581b7 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-properties 0.0.1-SNAPSHOT @@ -74,6 +74,25 @@ + + org.springframework.boot + spring-boot-maven-plugin + + + build-info + + build-info + + + + ${java.version} + ${project.description} + 123 + + + + + org.apache.maven.plugins maven-resources-plugin diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildPropertiesUnitTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildPropertiesUnitTest.java new file mode 100644 index 0000000000..cf9b9336e6 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildPropertiesUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.buildproperties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.info.BuildProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@SpringBootTest +@ExtendWith(SpringExtension.class) +public class BuildPropertiesUnitTest { + @Autowired + private BuildProperties buildProperties; + + @Test + void givenBuildPropertiesBean_WhenFetchDefaultBuildProperties_ThenGetValidValues() { + Assertions.assertEquals("spring-boot-properties", buildProperties.getArtifact()); + Assertions.assertEquals("com.baeldung.spring-boot-modules", buildProperties.getGroup()); + Assertions.assertEquals("0.0.1-SNAPSHOT", buildProperties.getVersion()); + } + + @Test + void givenBuildPropertiesBean_WhenFetchCustomBuildProprties_ThenGetValidValues() { + Assertions.assertEquals("123", buildProperties.get("custom.value")); + Assertions.assertNotNull(buildProperties.get("java.version")); + Assertions.assertEquals("Spring Boot Properties Module", buildProperties.get("description")); + } +}