Search in sources :

Example 1 with GitProperties

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");
}
Also used : GitProperties(org.springframework.boot.info.GitProperties) GitProperties(org.springframework.boot.info.GitProperties) Properties(java.util.Properties) Map(java.util.Map) Test(org.junit.Test)

Example 2 with GitProperties

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"));
}
Also used : GitProperties(org.springframework.boot.info.GitProperties) Test(org.junit.Test)

Example 3 with GitProperties

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);
}
Also used : GitProperties(org.springframework.boot.info.GitProperties) Test(org.junit.Test)

Example 4 with GitProperties

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();
}
Also used : GitProperties(org.springframework.boot.info.GitProperties) Test(org.junit.Test)

Example 5 with GitProperties

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);
}
Also used : GitProperties(org.springframework.boot.info.GitProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 GitProperties (org.springframework.boot.info.GitProperties)6 Map (java.util.Map)2 Properties (java.util.Properties)2 Date (java.util.Date)1