|
| 1 | +/* |
| 2 | + * Copyright 2012-2024 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.diagnostics.analyzer; |
| 18 | + |
| 19 | +import org.junit.jupiter.api.Test; |
| 20 | + |
| 21 | +import org.springframework.boot.AotInitializerNotFoundException; |
| 22 | +import org.springframework.boot.diagnostics.FailureAnalysis; |
| 23 | + |
| 24 | +import static org.assertj.core.api.Assertions.assertThat; |
| 25 | + |
| 26 | +/** |
| 27 | + * Tests for {@link AotInitializerNotFoundFailureAnalyzer}. |
| 28 | + * |
| 29 | + * @author Moritz Halbritter |
| 30 | + */ |
| 31 | +class AotInitializerNotFoundFailureAnalyzerTests { |
| 32 | + |
| 33 | + @Test |
| 34 | + void shouldAnalyze() { |
| 35 | + FailureAnalysis analysis = analyze(); |
| 36 | + assertThat(analysis.getDescription()).isEqualTo( |
| 37 | + "Startup with AOT mode enabled failed: AOT initializer class org.springframework.boot.diagnostics.analyzer.AotInitializerNotFoundFailureAnalyzerTests__ApplicationContextInitializer could not be found"); |
| 38 | + assertThat(analysis.getAction()).isEqualTo( |
| 39 | + """ |
| 40 | + Consider the following: |
| 41 | + \tDid you build the application with enabled AOT processing? |
| 42 | + \tIs the main class org.springframework.boot.diagnostics.analyzer.AotInitializerNotFoundFailureAnalyzerTests correct? |
| 43 | + \tIf you want to run the application in regular mode, remove the system property 'spring.aot.enabled'"""); |
| 44 | + } |
| 45 | + |
| 46 | + private FailureAnalysis analyze() { |
| 47 | + return new AotInitializerNotFoundFailureAnalyzer() |
| 48 | + .analyze(new AotInitializerNotFoundException(AotInitializerNotFoundFailureAnalyzerTests.class, |
| 49 | + AotInitializerNotFoundFailureAnalyzerTests.class + "__ApplicationContextInitializer")); |
| 50 | + } |
| 51 | + |
| 52 | +} |
0 commit comments