• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

한글 인코딩 관련 질문입니다.

21.08.07 10:59 작성 조회수 1.76k

16

ms.getMessage("hello", null, null)을 넣고 테스트를 돌렸을 때 아래와 같이 뜨면서 테스트가 실패합니다.

Expecting:
 <"??">
to be equal to:
 <"안녕">
but was not.
org.opentest4j.AssertionFailedError: 
Expecting:
 <"??">
to be equal to:
 <"안녕">
but was not.
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at hello.itemservice.message.MessageSourceTest.helloMessage(MessageSourceTest.java:19)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy2.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:133)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.base/java.lang.Thread.run(Thread.java:834)


2021-08-07 10:51:06.397  INFO 12216 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
MessageSourceTest > helloMessage() FAILED
    org.opentest4j.AssertionFailedError at MessageSourceTest.java:19
1 test completed, 1 failed
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///C:/Users/dpffp/Desktop/STUDY/message/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
4 actionable tasks: 1 executed, 3 up-to-date

오류 메세지를 읽어 봤는데 messages.properties 파일에 hello=안녕 이 hello=??으로 바뀌어서 그런 것 같았습니다.

위는 제 messages.properties 파일의 현재 상태입니다.

그래서 인코딩 문제인가보다 하고 인텔리제이 인코딩을 다시 해 주었습니다.

1. Help >> Edit Custom VM Options 클릭해서

파일에 -Dfile.encoding=UTF-8 추가 후 인텔리제이 껐다 켜기

2. Settings >> Editor >> File Encodings >> Global, Project Encoding, Properties Files 설정을 UTF-8로 변경

이후 인텔리제이 껐다 켜기

이 두 가지 방법을 해 보았는데도 여전히 messages.properties파일에 한글이 ?? 으로 깨집니다. 이걸 다시 제가 한글로 수정 후 저장을 하면 다시 ?? 으로  돌아와 버리네요. 어떻게 해결하면 좋을까요?

답변 11

·

답변을 작성해보세요.

57

joonsang님의 프로필

joonsang

2021.08.07

안녕하세요 ~

똑같은 로그가 나와 공유 드립니다.

질문자님 말처럼, 아래 3개를 UTF-8 로 바꿉니다.

File >> Settings >> Editor >> File Encodings >> Global
File >> Settings >> Editor >> File Encodings >> Project Encoding
File >> Settings >> Editor >> File Encodings >> Properties File

변경 후, properties 파일을 확인해보면 한글이 "??" 으로 바뀌어 있을거에요.

?? 을 다시 "안녕" 으로 수정하여 테스트 돌려보시면 될것 같네요.

참고로 UTF-8 로 변경해도 변화가 없으실 경우

File >> Invaildate Caches >> Reset

한 번 해주시면 좋을듯 하네요.

그럼 열공하세요.

yeon _leaf님의 프로필

yeon _leaf

질문자

2021.08.07

Invalidate Caches를 하니 작동이 됩니다. 대체 왜 이런 것인지는 이해를 못 하겠지만 일단은 진도를 계속 나갈 수 있으니 기쁘네요. 좋은 방법 공유해주셔서 감사드립니다.

강성욱님의 프로필

강성욱

2021.08.25

저도 해결했습니다. 감사합니다

이재윤님의 프로필

이재윤

2021.10.28

잘됩니다 감사합니다^^

qzxy812님의 프로필

qzxy812

2022.03.14

감사합니다 덕분에 해결했어요ㅎㅎ

에반황님의 프로필

에반황

2022.03.20

감사합니다 !!

김태윤님의 프로필

김태윤

2022.05.30

저도 해결했습니다 감사합니다!

성문님의 프로필

성문

2022.07.04

감사합니다 

jinkoo906님의 프로필

jinkoo906

2022.08.18

덕분에 살았습니다 !!!!

7

chlwnsdud121님의 프로필

chlwnsdud121

2022.01.13

저는 File Encodings에서 Transparent native-to-ascii conversion 체크하니깐 정상 동작 했습니다.

ChangDoit님의 프로필

ChangDoit

2022.01.25

위 UTF-8 3개 변경 후 실행했을 때도 테스트 코드 안됬었는데 conversion 체크하니 잘되네요ㅎㅎ 감사합니다!

0

은인이십니다 ㅎㅎ

0

식빵님의 프로필

식빵

2021.12.04

감사합니다 ^^

0

덕분에 해결 했습니다 ^^ 

0

먼길님의 프로필

먼길

2021.11.06

감사합니다. 이것을 하니까 다음 강의의 메세지 적용에서 ??? 문제는 해결되었는데 테스트 코드는 여전히 에러를 뿜내요....

0

namhkim님의 프로필

namhkim

2021.11.05

여기 글 때문에 성불했습니다.

영한님 강의자료는 정상작동해서 비교하면서 왜 제꺼는 정상 작동 안될까 하고 삽질했는데...

역시 구글링 또는 검색이 최고네요

0

B#님의 프로필

B#

2021.09.09

저도 같은 문제가 발생했는데 덕분에 해결했습니다.. 감사합니다^^

0

필로님의 프로필

필로

2021.09.04

덕분에 해결되었어요 ㅎㅎ 감사합니다

0

Hero님의 프로필

Hero

2021.08.19

저도 같은 문제가 생겼는데, 해결했습니다 감사합니다.

0

OMG님의 프로필

OMG

2021.08.07

안녕하세요. yeon _leaf님, 공식 서포터즈 OMG입니다.

인텔리제이 인코딩 관련 질문이군요.

인터넷 검색하면 나오는 일반적인 방법은 시도해보신거 같으신데요. 우선 2가지 방법을 제안드릴 수 있습니다.

-

1. 영한님이 제공해주신 강의 프로젝트로 시도해보시겠어요?

message-start, message 두 개의 폴더가 존재합니다. 완성본으로 테스트 해보시고, 정상작동하면 message 폴더로 진행. 해당 프로젝트를 다운받아서 진행중이셨다면 새로 받아서 해보셔도 좋습니다.

2. 인텔리제이를 완전히 삭제 후 재설치

1번에서 성공하면 1번에서 진행하셔도 되지만 1번에서 안된다면 재설치 후 결과를 공유해주세요.

감사합니다. 

yeon _leaf님의 프로필

yeon _leaf

질문자

2021.08.07

안녕하세요. 영한님이 공유해주신 message 폴더가 정상 작동됩니다. 하지만 혹시나 해서 아래에 글 남겨주신 분의 방법대로 Invaildate Caches -> Reset을 해봤더니 제가 만든 프로젝트도 정상적으로 작동이 됩니다...? 그 외에 아무 설정도 변경한 게 없고요... 프로그래밍은 참 신비하네요... OMG님 항상 답변 감사드립니다.