나는 이것으로 철저히 혼란 스럽다. 나는 단위 테스트의 전체 패키지를 실행 중입니다. 여기에 JUnit 테스트들에 의해 관련 공유 코드 사용됩니다있어 어떤 :HashMap containsKey()가 String을 키로 사용하지 못하게 할 수있는 원인은 무엇입니까?
private static Map<String, JAXBContext> jaxbContexts =
new HashMap<String, JAXBContext>();
private synchronized JAXBContext getJAXBContext(Class clazz) throws JAXBException {
JAXBContext context = null;
if (jaxbContexts.containsKey(clazz.getName())) {
context = jaxbContexts.get(clazz.getName());
} else {
context = JAXBContext.newInstance(clazz);
System.out.println("Created new context for '" + clazz.getName() + "'");
jaxbContexts.put(clazz.getName(), context);
}
return context;
}
의 JUnit 실행에서 콘솔 출력은 다음과 같은 두 개의 연속적인 항목을 포함 : 나는 무엇을 놓치고
Created new context for 'com.somecompany.xmlschema.providepensionpaymentinfo.Interface'
Created new context for 'com.somecompany.xmlschema.providepensionpaymentinfo.Interface'
를? jaxbContexts.containsKey()
이 JUnit 실행 중 다른 46 번과 달리 String 기반 키에 대해이 인스턴스에서 작동하지 않는 이유는 무엇입니까? 우리는 테스트를 평행하게 진행하지는 않지만 차이가 나는 경우에는 측면을 사용합니다.
두 줄 사이에 JVM을 중지/시작하지 않았습니까? – Pointy