2009-07-15 6 views
1

私たちのSpringアプリケーション用の統合テストスクリプトを開発中です。私がantからテストを実行すると、次のエラーメッセージが表示されます。Springとの統合テスト:タイプエラーの値を変換できません

テストケース:

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がクラス(ないインタフェース)である

私は、次のしている:

<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を持っています - それは、antからunit/intテストを実行する方法に違いがありますか? – boyd4715

答えて

0

あなたにCGLIB jarを追加する必要があるように見えますクラスパス。 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つのインターフェースを実装している場合、私はプロンプトでどちらを使用するかをSpringがどのように決定するかはわかりません。私はそれが2つのインターフェイスを実装するかもしれないと思うし、プロキシはもう一方に作成されています。

+0

私たちはJUnit 4.6でSpring 2.0.xを使用しています。私はそれをJUnit 3.8にドロップする必要がありますか? – boyd4715

+0

また、私が行っている統合テストは、バックエンドアプリケーションです - EJBが付いた耳 - – boyd4715

+0

ありがとうございました!ちょうど同じ問題にぶつかりました。インターフェイスを削除することができました。 – alf

関連する問題