use of org.springframework.boot.info.GitProperties in project spring-boot by spring-projects.
the class GitInfoContributorTests method shortenCommitId.
@SuppressWarnings("unchecked")
@Test
public void shortenCommitId() {
Properties properties = new Properties();
properties.put("branch", "master");
properties.put("commit.id", "8e29a0b0d423d2665c6ee5171947c101a5c15681");
GitInfoContributor contributor = new GitInfoContributor(new GitProperties(properties));
Map<String, Object> content = contributor.generateContent();
assertThat(content.get("commit")).isInstanceOf(Map.class);
Map<String, Object> commit = (Map<String, Object>) content.get("commit");
assertThat(commit.get("id")).isEqualTo("8e29a0b");
}
use of org.springframework.boot.info.GitProperties in project spring-boot by spring-projects.
the class ProjectInfoAutoConfigurationTests method gitPropertiesFallbackWithGitPropertiesBean.
@Test
public void gitPropertiesFallbackWithGitPropertiesBean() {
load(CustomInfoPropertiesConfiguration.class, "spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git.properties");
GitProperties gitProperties = this.context.getBean(GitProperties.class);
assertThat(gitProperties).isSameAs(this.context.getBean("customGitProperties"));
}
use of org.springframework.boot.info.GitProperties in project spring-boot by spring-projects.
the class ProjectInfoAutoConfigurationTests method gitLocationTakesPrecedenceOverLegacyKey.
@Test
public void gitLocationTakesPrecedenceOverLegacyKey() {
load("spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git.properties", "spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
GitProperties gitProperties = this.context.getBean(GitProperties.class);
assertThat(gitProperties.getBranch()).isNull();
assertThat(gitProperties.getCommitId()).isEqualTo("f95038ec09e29d8f91982fd1cbcc0f3b131b1d0a");
assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1456995720000L);
}
use of org.springframework.boot.info.GitProperties in project spring-boot by spring-projects.
the class ProjectInfoAutoConfigurationTests method gitPropertiesWithNoData.
@Test
public void gitPropertiesWithNoData() {
load("spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
GitProperties gitProperties = this.context.getBean(GitProperties.class);
assertThat(gitProperties.getBranch()).isNull();
}
use of org.springframework.boot.info.GitProperties in project spring-boot by spring-projects.
the class ProjectInfoAutoConfigurationTests method gitLegacyKeyIsUsedAsFallback.
@Test
public void gitLegacyKeyIsUsedAsFallback() {
load("spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-epoch.properties");
GitProperties gitProperties = this.context.getBean(GitProperties.class);
assertThat(gitProperties.getBranch()).isEqualTo("master");
assertThat(gitProperties.getCommitId()).isEqualTo("5009933788f5f8c687719de6a697074ff80b1b69");
assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1457103850000L);
}
Aggregations