2013-11-25 4 views
0

Spring과의 통합 테스트를 작성하기 위해 커스텀 클래스 로더로 테스트 애플리케이션 컨텍스트를로드하려고한다. 그 이유는 LoadTimeWeaver (org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver 또는 org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver)를 사용하기 때문입니다. 불행히도 기본 Sun classLoader는 LoadTimeWeaver에 필요한 필수 addTransformer 메소드를 제공하지 않습니다. vm 시작시 sprint-instrument.jar와 함께 javaagent를 사용하면 모든 것이 잘 동작합니다.Instrumentation을 사용한 Spring 통합 테스트 컨텍스트로드하기

하지만 내가 GenericXmlContextLoader을 확장하고 내 상황에 맞는 로더에 대한 SimpleInstrumentableClassLoader을 설정하여 간단한 솔루션을 시도

다른 컴퓨터에서 실행해야한다 테스트, IDE에 대한 유효한 옵션 등되지 않습니다 :

@ContextConfiguration(locations = { "classpath:/spring/_context.xml" }, loader = CustomApplicationContextLoader.class) 

public class CustomApplicationContextLoader extends GenericXmlContextLoader { 

    @Override 
    protected void prepareContext(final GenericApplicationContext context) { 
     super.prepareContext(context); 
     context.setClassLoader(new SimpleInstrumentableClassLoader(ClassUtils.getDefaultClassLoader())); 
    } 
} 

같은 오류의 결과 0
Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface 

아마도 일부 클래스는 기본 클래스 로더에 의해로드되고 일부 클래스는 계측 클래스 로더에 의해로드되기 때문에 가능합니다.

좋은 해결책이 있습니까?

도움 주셔서 감사합니다. 크리스

+0

클래스 패스에 모든 Spring jar가 있습니까? 어떤 분이 계세요? –

+0

아마도 모든 것이 관련이있는 것은 아니지만 : 스프링 컨텍스트, 스프링 웹, 스프링 jms, 스프링 테스트, 스프링 보안 코어, 스프링 보안 웹, 스프링 보안 구성, 스프링 데이터 jpa, 스프링 -datacommons-cor, spring-tx, spring-webmvc, spring-instrument, spring-instrument-tomcat – user3022028

답변