Browse Source

Merge branch '2.7.x'

pull/29263/head
Stephane Nicoll 4 years ago
parent
commit
b214841e2c
  1. 43
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/JavaInfo.java
  2. 7
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/info/JavaInfoTests.java

43
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/JavaInfo.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,29 +25,29 @@ package org.springframework.boot.info; @@ -25,29 +25,29 @@ package org.springframework.boot.info;
*/
public class JavaInfo {
private final String vendor;
private final String version;
private final JavaVendorInfo vendor;
private final JavaRuntimeEnvironmentInfo runtime;
private final JavaVirtualMachineInfo jvm;
public JavaInfo() {
this.vendor = System.getProperty("java.vendor");
this.version = System.getProperty("java.version");
this.vendor = new JavaVendorInfo();
this.runtime = new JavaRuntimeEnvironmentInfo();
this.jvm = new JavaVirtualMachineInfo();
}
public String getVendor() {
return this.vendor;
}
public String getVersion() {
return this.version;
}
public JavaVendorInfo getVendor() {
return this.vendor;
}
public JavaRuntimeEnvironmentInfo getRuntime() {
return this.runtime;
}
@ -56,6 +56,33 @@ public class JavaInfo { @@ -56,6 +56,33 @@ public class JavaInfo {
return this.jvm;
}
/**
* Information about the Java Vendor of the Java Runtime the application is running
* in.
*
* @since 2.7.0
*/
public static class JavaVendorInfo {
private final String name;
private final String version;
public JavaVendorInfo() {
this.name = System.getProperty("java.vendor");
this.version = System.getProperty("java.vendor.version");
}
public String getName() {
return this.name;
}
public String getVersion() {
return this.version;
}
}
/**
* Information about the Java Runtime Environment the application is running in.
*/

7
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/info/JavaInfoTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,8 +31,11 @@ class JavaInfoTests { @@ -31,8 +31,11 @@ class JavaInfoTests {
@Test
void javaInfoIsAvailable() {
JavaInfo javaInfo = new JavaInfo();
assertThat(javaInfo.getVendor()).isEqualTo(System.getProperty("java.vendor"));
assertThat(javaInfo.getVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(javaInfo.getVendor()).satisfies((vendorInfo) -> {
assertThat(vendorInfo.getName()).isEqualTo(System.getProperty("java.vendor"));
assertThat(vendorInfo.getVersion()).isEqualTo(System.getProperty("java.vendor.version"));
});
assertThat(javaInfo.getRuntime()).satisfies((jreInfo) -> {
assertThat(jreInfo.getName()).isEqualTo(System.getProperty("java.runtime.name"));
assertThat(jreInfo.getVersion()).isEqualTo(System.getProperty("java.runtime.version"));

Loading…
Cancel
Save