From ad9986874f7ee832548f22f26e3c72ac553a5728 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Mon, 15 Aug 2016 11:33:21 +0200 Subject: [PATCH] Refactor CommitId examples --- .../com/baeldung/git/CommitIdApplication.java | 2 +- .../src/main/resources/application.properties | 4 +++- .../java/com/baeldung/git/CommitIdTest.java | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java b/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java index 1f774dbead..b535c8bd4a 100644 --- a/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java +++ b/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.PropertySource; -@PropertySource("classpath:/git.properties") +@PropertySource(value = "classpath:/git.properties", ignoreResourceNotFound = true) @SpringBootApplication(scanBasePackages = { "com.baeldung.git"}) public class CommitIdApplication { public static void main(String[] args) { diff --git a/spring-boot/src/main/resources/application.properties b/spring-boot/src/main/resources/application.properties index 78bcf4cc05..d30045d1dc 100644 --- a/spring-boot/src/main/resources/application.properties +++ b/spring-boot/src/main/resources/application.properties @@ -26,4 +26,6 @@ info.app.version=1.0.0 ## Spring Security Configurations security.user.name=admin1 security.user.password=secret1 -management.security.role=SUPERUSER \ No newline at end of file +management.security.role=SUPERUSER + +logging.level.org.springframework=INFO \ No newline at end of file diff --git a/spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java b/spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java index b06b511bb4..cddc0d60bc 100644 --- a/spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java +++ b/spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java @@ -2,6 +2,8 @@ package com.baeldung.git; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -12,27 +14,31 @@ import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = CommitIdApplication.class) public class CommitIdTest { - private static final String UNKNOWN_STATUS = "UNKNOWN"; + private static final Logger LOG = LoggerFactory.getLogger(CommitIdTest.class); @Value("${git.commit.message.short:#{'UNKNOWN'}}") private String commitMessage; - @Value("${git.branch:#{'UNKNOWN'}") + @Value("${git.branch:#{'UNKNOWN'}}") private String branch; - @Value("${git.commit.id:#{'UNKNOWN'}") + @Value("${git.commit.id:#{'UNKNOWN'}}") private String commitId; @Test public void shouldInjectGitInfoProperties() throws Exception { + LOG.info(commitId); + LOG.info(commitMessage); + LOG.info(branch); + assertThat(commitMessage) - .isNotEqualTo(UNKNOWN_STATUS); + .isNotEqualTo("UNKNOWN"); assertThat(branch) - .isNotEqualTo(UNKNOWN_STATUS); + .isNotEqualTo("UNKNOWN"); assertThat(commitId) - .isNotEqualTo(UNKNOWN_STATUS); + .isNotEqualTo("UNKNOWN"); } } \ No newline at end of file