BAEL-5951: Spring Boot 3 Sample for Native Image builds incl. Runtime Hints (#13047)
* Update Spring Boot, Spring Native and Native Maven Plugin versions * BAEL-5951: Spring Boot 3 Sample for Native Image builds incl. Runtime Hints * BAEL-5951: Configure POMs and add Swagger UI runtime hints * BAEL-5951: Remove Swagger UI runtime hints * BAEL-5951: Remove Spring Boot3 parent POM from profiles because of JDK17 dependency during build (building the parent POM is even not necessary) * BAEL-5951: Add tests * BAEL-5951: Fix tests (PMD naming conventions)
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.sample;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest
|
||||
class JacksonAutoConfigurationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
ObjectMapper mapper;
|
||||
|
||||
@Test
|
||||
void shouldUseSnakeCasePropertyNamingStrategy() {
|
||||
assertThat(mapper.getPropertyNamingStrategy())
|
||||
.isSameAs(PropertyNamingStrategies.SNAKE_CASE);
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.sample;
|
||||
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
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;
|
||||
|
||||
class JacksonRuntimeHintsUnitTest {
|
||||
|
||||
@Test
|
||||
void shouldRegisterSnakeCasePropertyNamingStrategy() {
|
||||
// arrange
|
||||
final var hints = new RuntimeHints();
|
||||
final var expectSnakeCaseHint = RuntimeHintsPredicates
|
||||
.reflection()
|
||||
.onField(PropertyNamingStrategies.class, "SNAKE_CASE");
|
||||
// act
|
||||
new JacksonRuntimeHints.PropertyNamingStrategyRegistrar()
|
||||
.registerHints(hints, getClass().getClassLoader());
|
||||
// assert
|
||||
assertThat(expectSnakeCaseHint).accepts(hints);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user