2009-07-15 3 views
1

스프링 응용 프로그램 용 통합 테스트 스크립트를 개발하는 중입니다. 개미에서 테스트를 실행하면 다음과 같은 오류 메시지가 나타납니다. 이상적인 이유는 무엇입니까?스프링 통합 테스트 : 형식 오류 값을 변환 할 수 없습니다.

테스트 케이스는 :

testgetDefaultItemForStoreWithInvalidStoreId(com.xyz.business.admin.role.RoleUtilityUnitTest): 
Caused an ERROR Error creating bean with name 'groundingService' defined in URL 
[file:/C:/workspace/_EACE1_0_06/EB_Ace_Vob/Business/build/classess/businessContext.xml]: Error 
setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested 
PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: 
Failed to convert property value of type [$Proxy47] to required type 
[com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement'; nested exception 
is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy47] to required type 
[com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement': no matching editors or 
conversion strategy found org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'groundingService' defined in 
URL [file:/C:/workspace/_EACE1_0_06/EB_Ace_Vob/Business/build/classess/businessContext.xml]: Error 
setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested 
PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: 
Failed to convert property value of type [$Proxy47] to required type 
[com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement'; 
nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy47] to 
required type [com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement': 
no matching editors or conversion strategy found Caused by: 
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: 
PropertyAccessException 1: 

OdometerPDFStatement는 클래스 (안 인터페이스)

나는 다음이 있습니다 : 당신이에 CGLIB 항아리를 추가 할 필요가 같은

<bean id="odometerPdfStatement" class="com.xyz.business.grounding.service.OdometerPdfStatement"/> 


<bean id="groundingService" class="com.xyz.business.grounding.service.GroundingServiceImpl"> 
    <property name="groundingInformationManager" ref="groundingInformationManager"/> 
    <property name="codeManager" ref="codeManager"/> 
    <property name="userManager" ref="userManager"/> 
    <property name="configurator" ref="groundingConfigurator"/> 
    <property name="velocityPropertyFilePath" value="velocity.properties"/> 
    <property name="velocityTemplate" value="OdometerStatement.vm"/> 
    <property name="odometerStatementXSLResourceFile" value="classpath:OdometerStatement2xsl-fo.xsl"/> 
    <property name="imagePropertyFile" value="classpath:images.properties"/> 
    <property name="odometerPdfStatement" ref="odometerPdfStatement"/> 
    <property name="inspectionInformationManager" ref="inspectionInformationManager"/> 
    <property name="saleEventManager" ref="saleEventManager"/> 
    <property name="vehicleHistoryManager" ref="vehicleHistoryManager"/> 
</bean> 
+1

어디서나 AOP를 사용하고 있습니까? "$ Proxy47"의심 스럽네요. –

+0

boyd4715 : 그렇습니다. 우리는 AOP를 가지고 있습니다 - 개미를 테스트하는 방법에 차이가 있습니까? – boyd4715

답변

0

같습니다 당신의 classpath. Cglib은 Spring이 인터페이스가 아닌 구체적인 클래스를 프록시 할 수 있도록 보장합니다.

+0

클래스 경로에 다음과 같은 내용이 있습니다. cglib-nodep-2.1_3.jar. IDE에서 문제없이 테스트 스크립트를 실행할 수 있습니다. RAD 7.0.X를 IDE로 사용. – boyd4715

+0

사실, [[$ Proxy47]'은 cglib가 사용 가능하다는 것을 보여줍니다; 그것은 정확히 정확히 무엇이 프록시되고 있는지 잘못 판단합니다. – alf

+0

@alf 그 클래스 이름은 고전적인 Java 프록시가 사용됨을 나타냅니다. cglib 프록시 클래스에는 EnhancedByCGLIB (http://osdir.com/ml/java.cglib.devel/2005-06/msg00025.html) –

1

나는 이것을 몇 번이나 가지고 있습니다. 이것은 생성 된 프록시가 올바른 인터페이스를 구현하지 못한다는 것을 의미합니다.

주사기에 중단 점을 넣고 $ Proxy47이 실행 중인지 확인하기 위해 검사하십시오.

om.xyz.business.grounding.service.OdometerPdfStatement 클래스가 2 개의 인터페이스를 구현하는 경우, 나는 스프링이 프록시 할 때 어느 것을 사용할 지 결정하지 못합니다. 나는 그것이 두 개의 인터페이스를 구현할 수도 있고 다른 하나에서 프록시가 생성되고 있다고 생각한다.

+0

우리는 JUnit 4.6에서 Spring 2.0.x를 사용하고 있습니다. JUnit 3.8에 놓아야합니까? – boyd4715

+0

또한, 내가하고있는 통합 테스트는 백엔드 어플리케이션입니다 - EJB가있는 귀 - – boyd4715

+0

해답을 찾아 주셔서 대단히 감사합니다! 그냥 똑같은 문제에 부딪 혔습니다. 인터페이스 삭제가 도움이되었습니다. – alf

관련 문제