BAEL-3765: Code Upload (#8804)

This commit is contained in:
sergio41 2020-03-06 18:05:48 +01:00 committed by GitHub
parent 7a2c941024
commit 40a17f0f63
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package com.baeldung.version;
import org.springframework.boot.system.JavaVersion;
import org.springframework.boot.system.SystemProperties;
import org.springframework.core.SpringVersion;
public class VersionObtainer {
public String getSpringVersion() {
return SpringVersion.getVersion();
}
public String getJavaVersion() {
return JavaVersion.getJavaVersion().toString();
}
public String getJdkVersion() {
return SystemProperties.get("java.version");
}
}

View File

@ -0,0 +1,30 @@
package com.baeldung.version;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(classes = VersionObtainer.class)
public class VersionObtainerUnitTest {
public VersionObtainer version = new VersionObtainer();
@Test
public void testGetSpringVersion() {
String res = version.getSpringVersion();
assertThat(res).isNotEmpty();
}
@Test
public void testGetJdkVersion() {
String res = version.getJdkVersion();
assertThat(res).isNotEmpty();
}
@Test
public void testGetJavaVersion() {
String res = version.getJavaVersion();
assertThat(res).isNotEmpty();
}
}