Polish "Add AOT support for actuator"

See gh-31671
This commit is contained in:
Stephane Nicoll
2022-07-19 11:52:39 +02:00
parent 584b7d1343
commit 51cba6ec72
56 changed files with 387 additions and 939 deletions

View File

@@ -1,44 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.info;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.info.BuildProperties.BuildPropertiesRuntimeHints;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link BuildPropertiesRuntimeHints}.
*
* @author Moritz Halbritter
*/
class BuildPropertiesRuntimeHintsTests {
private final BuildPropertiesRuntimeHints sut = new BuildPropertiesRuntimeHints();
@Test
void shouldRegisterHints() {
RuntimeHints runtimeHints = new RuntimeHints();
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.resource().forResource("META-INF/build-info.properties"))
.accepts(runtimeHints);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -23,12 +23,16 @@ import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link BuildProperties}.
*
* @author Stephane Nicoll
* @author Moritz Halbritter
*/
class BuildPropertiesTests {
@@ -53,6 +57,14 @@ class BuildPropertiesTests {
assertThat(properties.getTime()).isNull();
}
@Test
void shouldRegisterHints() {
RuntimeHints runtimeHints = new RuntimeHints();
new BuildProperties.BuildPropertiesRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.resource().forResource("META-INF/build-info.properties"))
.accepts(runtimeHints);
}
private static Properties createProperties(String group, String artifact, String version, String buildTime) {
Properties properties = new Properties();
properties.put("group", group);

View File

@@ -1,43 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.info;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.info.GitProperties.GitPropertiesRuntimeHints;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link GitPropertiesRuntimeHints}.
*
* @author Moritz Halbritter
*/
class GitPropertiesRuntimeHintsTests {
private final GitPropertiesRuntimeHints sut = new GitPropertiesRuntimeHints();
@Test
void shouldRegisterHints() {
RuntimeHints runtimeHints = new RuntimeHints();
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.resource().forResource("git.properties")).accepts(runtimeHints);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -20,12 +20,16 @@ import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link GitProperties}.
*
* @author Stephane Nicoll
* @author Moritz Halbritter
*/
class GitPropertiesTests {
@@ -94,6 +98,13 @@ class GitPropertiesTests {
assertThat(properties.getShortCommitId()).isEqualTo("abcdefg");
}
@Test
void shouldRegisterHints() {
RuntimeHints runtimeHints = new RuntimeHints();
new GitProperties.GitPropertiesRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.resource().forResource("git.properties")).accepts(runtimeHints);
}
private static Properties createProperties(String branch, String commitId, String commitIdAbbrev,
String commitTime) {
Properties properties = new Properties();