본문 바로가기

Programing/OpenSource

[Spring Boot] 2.0.2 -> 2.1.4 업데이트 후 TC 깨짐

다행히 많은 테스트 코드가 깨지지는 않았으나

RestTemplate 로깅을 위해 추가한 인터셉터 쪽이 깨졌다.

"HEADERS": "({})"
=>
"HEADERS": "([])"

org.springframework.http.HttpHeaders 의 구현 방법이 바뀐 것 같았다.

즉 맵에서 배열로 바뀐 것이다.

이전 5.0 대 스프링 버전에서는 생성자가 아래와 같았다.

public HttpHeaders() {
	this(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH), false);
}

5.2.0 대 스프링 버전은 아래와 같이 바뀌었다.

public static <K, V> MultiValueMap<K, V> toMultiValueMap(Map<K, List<V>> map) {
	return new MultiValueMapAdapter<>(map);
}

 

이것은 쉽게 바꿀 수 있는데 다음과 같은 에러가 있었다.

java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.tistory.payment.TiPaymentApiApplicationFunctionalTest]:
 [@org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.context.SpringBootTestContextBootstrapper),
 @org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper)]

SpringBootTestContextBootstrapper 와 DataJpaTestContextBootstrapper 두 개가 동시에 설정이 되어 있어서 발생한 것으로 보인다.

 

@SpringBootTest 와 @DataJpaTest 를 같이 쓰면 위와 같은 현상이 발생한다.

@SpringBootTest 를 지워주었다.